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

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

Issue 11364196: Remove TabContents from TabStripModelObserver::ActiveTabChanged. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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
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/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 25
26 namespace { 26 namespace {
27 27
28 // Returns true iff the search model for |tab| is in an NTP state, that is, a 28 // Returns true iff the search model for |tab| is in an NTP state, that is, a
29 // state in which the Instant overlay may be showing custom NTP content in 29 // state in which the Instant overlay may be showing custom NTP content in
30 // EXTENDED mode. 30 // EXTENDED mode.
31 bool IsSearchModelNTP(TabContents* tab) { 31 bool IsSearchModelNTP(content::WebContents* tab) {
32 if (!tab || !tab->web_contents()) 32 if (!tab)
33 return false; 33 return false;
34 content::WebContents* web_contents = tab->web_contents();
35 chrome::search::SearchModel* model = 34 chrome::search::SearchModel* model =
36 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model(); 35 chrome::search::SearchTabHelper::FromWebContents(tab)->model();
37 return model && model->mode().is_ntp(); 36 return model && model->mode().is_ntp();
38 } 37 }
39 38
40 } // namespace 39 } // namespace
41 40
42 namespace chrome { 41 namespace chrome {
43 42
44 //////////////////////////////////////////////////////////////////////////////// 43 ////////////////////////////////////////////////////////////////////////////////
45 // BrowserInstantController, public: 44 // BrowserInstantController, public:
46 45
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 PrefServiceBase* service, 126 PrefServiceBase* service,
128 const std::string& pref_name) { 127 const std::string& pref_name) {
129 DCHECK_EQ(std::string(prefs::kInstantEnabled), pref_name); 128 DCHECK_EQ(std::string(prefs::kInstantEnabled), pref_name);
130 ResetInstant(); 129 ResetInstant();
131 } 130 }
132 131
133 //////////////////////////////////////////////////////////////////////////////// 132 ////////////////////////////////////////////////////////////////////////////////
134 // BrowserInstantController, TabStripModelObserver implementation: 133 // BrowserInstantController, TabStripModelObserver implementation:
135 134
136 void BrowserInstantController::ActiveTabChanged( 135 void BrowserInstantController::ActiveTabChanged(
137 TabContents* old_contents, 136 content::WebContents* old_contents,
138 TabContents* new_contents, 137 content::WebContents* new_contents,
139 int index, 138 int index,
140 bool user_gesture) { 139 bool user_gesture) {
141 if (instant()) { 140 if (instant()) {
142 const bool old_is_ntp = IsSearchModelNTP(old_contents); 141 const bool old_is_ntp = IsSearchModelNTP(old_contents);
143 const bool new_is_ntp = IsSearchModelNTP(new_contents); 142 const bool new_is_ntp = IsSearchModelNTP(new_contents);
144 // Do not hide Instant if switching from an NTP to another NTP since that 143 // Do not hide Instant if switching from an NTP to another NTP since that
145 // would cause custom NTP content to flicker. 144 // would cause custom NTP content to flicker.
146 if (!(old_is_ntp && new_is_ntp)) 145 if (!(old_is_ntp && new_is_ntp))
147 instant()->Hide(); 146 instant()->Hide();
148 } 147 }
(...skipping 18 matching lines...) Expand all
167 InstantController::CreateInstant(browser_->profile(), this) : NULL); 166 InstantController::CreateInstant(browser_->profile(), this) : NULL);
168 167
169 // Notify any observers that they need to reset. 168 // Notify any observers that they need to reset.
170 content::NotificationService::current()->Notify( 169 content::NotificationService::current()->Notify(
171 chrome::NOTIFICATION_BROWSER_INSTANT_RESET, 170 chrome::NOTIFICATION_BROWSER_INSTANT_RESET,
172 content::Source<BrowserInstantController>(this), 171 content::Source<BrowserInstantController>(this),
173 content::NotificationService::NoDetails()); 172 content::NotificationService::NoDetails());
174 } 173 }
175 174
176 } // namespace chrome 175 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.h ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698