| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/instant/instant_unload_handler.h" | 5 #include "chrome/browser/instant/instant_unload_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 // TODO: Decide if we really want false here; false is used for tab closes, | 88 // TODO: Decide if we really want false here; false is used for tab closes, |
| 89 // and is needed so that the tab correctly closes but it doesn't really match | 89 // and is needed so that the tab correctly closes but it doesn't really match |
| 90 // what's logically happening. | 90 // what's logically happening. |
| 91 tab->web_contents()->GetRenderViewHost()->FirePageBeforeUnload(false); | 91 tab->web_contents()->GetRenderViewHost()->FirePageBeforeUnload(false); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void InstantUnloadHandler::Activate(WebContentsDelegateImpl* delegate) { | 94 void InstantUnloadHandler::Activate(WebContentsDelegateImpl* delegate) { |
| 95 // Take ownership of the TabContents from the delegate. | 95 // Take ownership of the TabContents from the delegate. |
| 96 TabContents* tab = delegate->ReleaseTab(); | 96 TabContents* tab = delegate->ReleaseTab(); |
| 97 browser::NavigateParams params(browser_, tab); | 97 chrome::NavigateParams params(browser_, tab); |
| 98 params.disposition = NEW_FOREGROUND_TAB; | 98 params.disposition = NEW_FOREGROUND_TAB; |
| 99 params.tabstrip_index = delegate->index(); | 99 params.tabstrip_index = delegate->index(); |
| 100 | 100 |
| 101 // Remove (and delete) the delegate. | 101 // Remove (and delete) the delegate. |
| 102 ScopedVector<WebContentsDelegateImpl>::iterator i = | 102 ScopedVector<WebContentsDelegateImpl>::iterator i = |
| 103 std::find(delegates_.begin(), delegates_.end(), delegate); | 103 std::find(delegates_.begin(), delegates_.end(), delegate); |
| 104 DCHECK(i != delegates_.end()); | 104 DCHECK(i != delegates_.end()); |
| 105 delegates_.erase(i); | 105 delegates_.erase(i); |
| 106 delegate = NULL; | 106 delegate = NULL; |
| 107 | 107 |
| 108 // Add the tab back in. | 108 // Add the tab back in. |
| 109 browser::Navigate(¶ms); | 109 chrome::Navigate(¶ms); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void InstantUnloadHandler::Destroy(WebContentsDelegateImpl* delegate) { | 112 void InstantUnloadHandler::Destroy(WebContentsDelegateImpl* delegate) { |
| 113 ScopedVector<WebContentsDelegateImpl>::iterator i = | 113 ScopedVector<WebContentsDelegateImpl>::iterator i = |
| 114 std::find(delegates_.begin(), delegates_.end(), delegate); | 114 std::find(delegates_.begin(), delegates_.end(), delegate); |
| 115 DCHECK(i != delegates_.end()); | 115 DCHECK(i != delegates_.end()); |
| 116 delegates_.erase(i); | 116 delegates_.erase(i); |
| 117 } | 117 } |
| OLD | NEW |