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/ui/browser_instant_controller.h" | 5 #include "chrome/browser/ui/browser_instant_controller.h" |
6 | 6 |
7 #include "chrome/browser/browser_shutdown.h" | 7 #include "chrome/browser/browser_shutdown.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/instant/instant_controller.h" | 9 #include "chrome/browser/instant/instant_controller.h" |
10 #include "chrome/browser/instant/instant_unload_handler.h" | 10 #include "chrome/browser/instant/instant_unload_handler.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 //////////////////////////////////////////////////////////////////////////////// | 85 //////////////////////////////////////////////////////////////////////////////// |
86 // BrowserInstantController, InstantControllerDelegate implementation: | 86 // BrowserInstantController, InstantControllerDelegate implementation: |
87 | 87 |
88 void BrowserInstantController::ShowInstant(TabContents* preview_contents) { | 88 void BrowserInstantController::ShowInstant(TabContents* preview_contents) { |
89 browser_->window()->ShowInstant(preview_contents); | 89 browser_->window()->ShowInstant(preview_contents); |
90 | 90 |
91 // TODO(beng): investigate if we can avoid this and instead rely on the | 91 // TODO(beng): investigate if we can avoid this and instead rely on the |
92 // visibility of the WebContentsView | 92 // visibility of the WebContentsView |
93 chrome::GetActiveWebContents(browser_)->WasHidden(); | 93 chrome::GetActiveWebContents(browser_)->WasHidden(); |
94 preview_contents->web_contents()->WasRestored(); | 94 preview_contents->web_contents()->WasShown(); |
95 } | 95 } |
96 | 96 |
97 void BrowserInstantController::HideInstant() { | 97 void BrowserInstantController::HideInstant() { |
98 browser_->window()->HideInstant(); | 98 browser_->window()->HideInstant(); |
99 if (chrome::GetActiveWebContents(browser_)) | 99 if (chrome::GetActiveWebContents(browser_)) |
100 chrome::GetActiveWebContents(browser_)->WasRestored(); | 100 chrome::GetActiveWebContents(browser_)->WasShown(); |
101 if (instant_->GetPreviewContents()) | 101 if (instant_->GetPreviewContents()) |
102 instant_->GetPreviewContents()->web_contents()->WasHidden(); | 102 instant_->GetPreviewContents()->web_contents()->WasHidden(); |
103 } | 103 } |
104 | 104 |
105 void BrowserInstantController::CommitInstant(TabContents* preview_contents) { | 105 void BrowserInstantController::CommitInstant(TabContents* preview_contents) { |
106 TabContents* tab_contents = chrome::GetActiveTabContents(browser_); | 106 TabContents* tab_contents = chrome::GetActiveTabContents(browser_); |
107 int index = browser_->tab_strip_model()->GetIndexOfTabContents(tab_contents); | 107 int index = browser_->tab_strip_model()->GetIndexOfTabContents(tab_contents); |
108 DCHECK_NE(TabStripModel::kNoTab, index); | 108 DCHECK_NE(TabStripModel::kNoTab, index); |
109 // TabStripModel takes ownership of preview_contents. | 109 // TabStripModel takes ownership of preview_contents. |
110 browser_->tab_strip_model()->ReplaceTabContentsAt(index, preview_contents); | 110 browser_->tab_strip_model()->ReplaceTabContentsAt(index, preview_contents); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 void BrowserInstantController::CreateInstantIfNecessary() { | 177 void BrowserInstantController::CreateInstantIfNecessary() { |
178 if (browser_->is_type_tabbed() && | 178 if (browser_->is_type_tabbed() && |
179 InstantController::IsEnabled(browser_->profile()) && | 179 InstantController::IsEnabled(browser_->profile()) && |
180 !browser_->profile()->IsOffTheRecord()) { | 180 !browser_->profile()->IsOffTheRecord()) { |
181 instant_.reset(new InstantController(this, InstantController::INSTANT)); | 181 instant_.reset(new InstantController(this, InstantController::INSTANT)); |
182 instant_unload_handler_.reset(new InstantUnloadHandler(browser_)); | 182 instant_unload_handler_.reset(new InstantUnloadHandler(browser_)); |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 } // namespace chrome | 186 } // namespace chrome |
OLD | NEW |