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

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

Issue 11414083: Remove PrefObserver usage, batch 9. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to sort-of good revision (r169014). 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
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 24 matching lines...) Expand all
35 // BrowserInstantController, public: 35 // BrowserInstantController, public:
36 36
37 BrowserInstantController::BrowserInstantController(Browser* browser) 37 BrowserInstantController::BrowserInstantController(Browser* browser)
38 : browser_(browser), 38 : browser_(browser),
39 instant_(ALLOW_THIS_IN_INITIALIZER_LIST(this), 39 instant_(ALLOW_THIS_IN_INITIALIZER_LIST(this),
40 chrome::search::IsInstantExtendedAPIEnabled(browser->profile())), 40 chrome::search::IsInstantExtendedAPIEnabled(browser->profile())),
41 instant_unload_handler_(browser), 41 instant_unload_handler_(browser),
42 initialized_theme_info_(false), 42 initialized_theme_info_(false),
43 theme_area_height_(0) { 43 theme_area_height_(0) {
44 profile_pref_registrar_.Init(browser_->profile()->GetPrefs()); 44 profile_pref_registrar_.Init(browser_->profile()->GetPrefs());
45 profile_pref_registrar_.Add(prefs::kInstantEnabled, this); 45 profile_pref_registrar_.Add(
46 instant_.SetInstantEnabled(IsInstantEnabled(browser_->profile())); 46 prefs::kInstantEnabled,
47 base::Bind(&BrowserInstantController::ResetInstant,
48 base::Unretained(this)));
49 ResetInstant();
47 browser_->search_model()->AddObserver(this); 50 browser_->search_model()->AddObserver(this);
48 51
49 #if defined(ENABLE_THEMES) 52 #if defined(ENABLE_THEMES)
50 // Listen for theme installation. 53 // Listen for theme installation.
51 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 54 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
52 content::Source<ThemeService>( 55 content::Source<ThemeService>(
53 ThemeServiceFactory::GetForProfile(browser_->profile()))); 56 ThemeServiceFactory::GetForProfile(browser_->profile())));
54 #endif // defined(ENABLE_THEMES) 57 #endif // defined(ENABLE_THEMES)
55 } 58 }
56 59
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 void BrowserInstantController::UpdateThemeInfoForPreview() { 144 void BrowserInstantController::UpdateThemeInfoForPreview() {
142 // Update theme background info and theme area height. 145 // Update theme background info and theme area height.
143 // Initialize |theme_info| if necessary. 146 // Initialize |theme_info| if necessary.
144 // |OnThemeChanged| also updates theme area height if necessary. 147 // |OnThemeChanged| also updates theme area height if necessary.
145 if (!initialized_theme_info_) 148 if (!initialized_theme_info_)
146 OnThemeChanged(ThemeServiceFactory::GetForProfile(browser_->profile())); 149 OnThemeChanged(ThemeServiceFactory::GetForProfile(browser_->profile()));
147 else 150 else
148 OnThemeChanged(NULL); 151 OnThemeChanged(NULL);
149 } 152 }
150 153
151 //////////////////////////////////////////////////////////////////////////////// 154 void BrowserInstantController::ResetInstant() {
152 // BrowserInstantController, PrefObserver implementation:
153
154 void BrowserInstantController::OnPreferenceChanged(
155 PrefServiceBase* service,
156 const std::string& pref_name) {
157 instant_.SetInstantEnabled(IsInstantEnabled(browser_->profile())); 155 instant_.SetInstantEnabled(IsInstantEnabled(browser_->profile()));
158 } 156 }
159 157
160 //////////////////////////////////////////////////////////////////////////////// 158 ////////////////////////////////////////////////////////////////////////////////
161 // BrowserInstantController, search::SearchModelObserver implementation: 159 // BrowserInstantController, search::SearchModelObserver implementation:
162 160
163 void BrowserInstantController::ModeChanged(const search::Mode& old_mode, 161 void BrowserInstantController::ModeChanged(const search::Mode& old_mode,
164 const search::Mode& new_mode) { 162 const search::Mode& new_mode) {
165 // If mode is now |NTP|, send theme-related information to instant. 163 // If mode is now |NTP|, send theme-related information to instant.
166 if (new_mode.is_ntp()) 164 if (new_mode.is_ntp())
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // part of the image overlay should draw, 'cos the origin is top-left. 268 // part of the image overlay should draw, 'cos the origin is top-left.
271 if (!browser_->search_model()->mode().is_ntp() || 269 if (!browser_->search_model()->mode().is_ntp() ||
272 theme_info_.theme_id.empty() || 270 theme_info_.theme_id.empty() ||
273 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) { 271 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) {
274 return; 272 return;
275 } 273 }
276 instant_.ThemeAreaHeightChanged(theme_area_height_); 274 instant_.ThemeAreaHeightChanged(theme_area_height_);
277 } 275 }
278 276
279 } // namespace chrome 277 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698