Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Side by Side Diff: chrome/browser/ui/browser_instant_controller.cc

Issue 10915217: Hook up SetInstantPreviewHeight for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't cache height in InstantController. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.h ('k') | chrome/browser/ui/browser_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // The omnibox currently doesn't use other dispositions, so we don't attempt 70 // The omnibox currently doesn't use other dispositions, so we don't attempt
71 // to handle them. If you hit this NOTREACHED file a bug and I'll (sky) add 71 // to handle them. If you hit this NOTREACHED file a bug and I'll (sky) add
72 // support for the new disposition. 72 // support for the new disposition.
73 NOTREACHED(); 73 NOTREACHED();
74 return false; 74 return false;
75 } 75 }
76 76
77 //////////////////////////////////////////////////////////////////////////////// 77 ////////////////////////////////////////////////////////////////////////////////
78 // BrowserInstantController, InstantControllerDelegate implementation: 78 // BrowserInstantController, InstantControllerDelegate implementation:
79 79
80 void BrowserInstantController::ShowInstant() { 80 void BrowserInstantController::ShowInstant(int height, InstantSizeUnits units) {
81 // Call ShowInstant() first, before WasShown(), so that the preview is added 81 // Call ShowInstant() first, before WasShown(), so that the preview is added
82 // to the window hierarchy before it's painted. http://crbug.com/145568 82 // to the window hierarchy before it's painted. http://crbug.com/145568
83 TabContents* preview = instant_->GetPreviewContents(); 83 TabContents* preview = instant_->GetPreviewContents();
84 browser_->window()->ShowInstant(preview); 84 browser_->window()->ShowInstant(preview, height, units);
85 85
86 // TODO(beng): Investigate if we can avoid this and instead rely on the 86 // TODO(beng): Investigate if we can avoid this and instead rely on the
87 // visibility of the WebContentsView. 87 // visibility of the WebContentsView.
88 preview->web_contents()->WasShown(); 88 preview->web_contents()->WasShown();
89 chrome::GetActiveWebContents(browser_)->WasHidden(); 89 chrome::GetActiveWebContents(browser_)->WasHidden();
90
91 content::NotificationService::current()->Notify(
92 chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN,
93 content::Source<InstantController>(instant()),
94 content::NotificationService::NoDetails());
95 } 90 }
96 91
97 void BrowserInstantController::HideInstant() { 92 void BrowserInstantController::HideInstant() {
98 browser_->window()->HideInstant(); 93 browser_->window()->HideInstant();
99 94
100 if (chrome::GetActiveWebContents(browser_)) 95 if (chrome::GetActiveWebContents(browser_))
101 chrome::GetActiveWebContents(browser_)->WasShown(); 96 chrome::GetActiveWebContents(browser_)->WasShown();
102 if (TabContents* preview = instant_->GetPreviewContents()) 97 if (TabContents* preview = instant_->GetPreviewContents())
103 preview->web_contents()->WasHidden(); 98 preview->web_contents()->WasHidden();
104 99
105 content::NotificationService::current()->Notify( 100 content::NotificationService::current()->Notify(
106 chrome::NOTIFICATION_INSTANT_CONTROLLER_HIDDEN, 101 chrome::NOTIFICATION_INSTANT_CONTROLLER_HIDDEN,
107 content::Source<InstantController>(instant()), 102 content::Source<InstantController>(instant()),
108 content::NotificationService::NoDetails()); 103 content::NotificationService::NoDetails());
sreeram 2012/09/19 20:52:03 For consistency, let's move this notification also
Jered 2012/09/19 21:18:14 Done.
109 } 104 }
110 105
111 void BrowserInstantController::CommitInstant(TabContents* preview) { 106 void BrowserInstantController::CommitInstant(TabContents* preview) {
112 TabContents* active_tab = chrome::GetActiveTabContents(browser_); 107 TabContents* active_tab = chrome::GetActiveTabContents(browser_);
113 int index = browser_->tab_strip_model()->GetIndexOfTabContents(active_tab); 108 int index = browser_->tab_strip_model()->GetIndexOfTabContents(active_tab);
114 DCHECK_NE(TabStripModel::kNoTab, index); 109 DCHECK_NE(TabStripModel::kNoTab, index);
115 // TabStripModel takes ownership of |preview|. 110 // TabStripModel takes ownership of |preview|.
116 browser_->tab_strip_model()->ReplaceTabContentsAt(index, preview); 111 browser_->tab_strip_model()->ReplaceTabContentsAt(index, preview);
117 // InstantUnloadHandler takes ownership of |active_tab|. 112 // InstantUnloadHandler takes ownership of |active_tab|.
118 instant_unload_handler_->RunUnloadListenersOrDestroy(active_tab, index); 113 instant_unload_handler_->RunUnloadListenersOrDestroy(active_tab, index);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 void BrowserInstantController::ResetInstant() { 168 void BrowserInstantController::ResetInstant() {
174 instant_.reset( 169 instant_.reset(
175 !browser_shutdown::ShuttingDownWithoutClosingBrowsers() && 170 !browser_shutdown::ShuttingDownWithoutClosingBrowsers() &&
176 browser_->is_type_tabbed() ? 171 browser_->is_type_tabbed() ?
177 InstantController::CreateInstant(browser_->profile(), this) : NULL); 172 InstantController::CreateInstant(browser_->profile(), this) : NULL);
178 instant_unload_handler_.reset(instant() ? 173 instant_unload_handler_.reset(instant() ?
179 new InstantUnloadHandler(browser_) : NULL); 174 new InstantUnloadHandler(browser_) : NULL);
180 } 175 }
181 176
182 } // namespace chrome 177 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.h ('k') | chrome/browser/ui/browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698