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

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_ui.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 242 }
243 243
244 void NewTabUI::RenderViewReused(RenderViewHost* render_view_host) { 244 void NewTabUI::RenderViewReused(RenderViewHost* render_view_host) {
245 StartTimingPaint(render_view_host); 245 StartTimingPaint(render_view_host);
246 } 246 }
247 247
248 void NewTabUI::Observe(int type, 248 void NewTabUI::Observe(int type,
249 const content::NotificationSource& source, 249 const content::NotificationSource& source,
250 const content::NotificationDetails& details) { 250 const content::NotificationDetails& details) {
251 switch (type) { 251 switch (type) {
252 case chrome::NOTIFICATION_PREF_CHANGED: { // kShowBookmarkBar
253 StringValue attached(
254 GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ?
255 "true" : "false");
256 web_ui()->CallJavascriptFunction("ntp.setBookmarkBarAttached", attached);
257 break;
258 }
259 #if defined(ENABLE_THEMES) 252 #if defined(ENABLE_THEMES)
260 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { 253 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: {
261 InitializeCSSCaches(); 254 InitializeCSSCaches();
262 StringValue attribution( 255 StringValue attribution(
263 ThemeServiceFactory::GetForProfile(GetProfile())->HasCustomImage( 256 ThemeServiceFactory::GetForProfile(GetProfile())->HasCustomImage(
264 IDR_THEME_NTP_ATTRIBUTION) ? "true" : "false"); 257 IDR_THEME_NTP_ATTRIBUTION) ? "true" : "false");
265 web_ui()->CallJavascriptFunction("ntp.themeChanged", attribution); 258 web_ui()->CallJavascriptFunction("ntp.themeChanged", attribution);
266 break; 259 break;
267 } 260 }
268 case chrome::NOTIFICATION_NTP_BACKGROUND_THEME_Y_POS_CHANGED: { 261 case chrome::NOTIFICATION_NTP_BACKGROUND_THEME_Y_POS_CHANGED: {
(...skipping 12 matching lines...) Expand all
281 #endif 274 #endif
282 case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE: { 275 case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE: {
283 last_paint_ = base::TimeTicks::Now(); 276 last_paint_ = base::TimeTicks::Now();
284 break; 277 break;
285 } 278 }
286 default: 279 default:
287 CHECK(false) << "Unexpected notification: " << type; 280 CHECK(false) << "Unexpected notification: " << type;
288 } 281 }
289 } 282 }
290 283
284 void NewTabUI::OnPreferenceChanged(PrefServiceBase* service,
285 const std::string& pref_name) {
286 StringValue attached(
287 GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ?
288 "true" : "false");
289 web_ui()->CallJavascriptFunction("ntp.setBookmarkBarAttached", attached);
290 }
291
291 void NewTabUI::InitializeCSSCaches() { 292 void NewTabUI::InitializeCSSCaches() {
292 #if defined(ENABLE_THEMES) 293 #if defined(ENABLE_THEMES)
293 Profile* profile = GetProfile(); 294 Profile* profile = GetProfile();
294 ThemeSource* theme = new ThemeSource(profile); 295 ThemeSource* theme = new ThemeSource(profile);
295 ChromeURLDataManager::AddDataSource(profile, theme); 296 ChromeURLDataManager::AddDataSource(profile, theme);
296 #endif 297 #endif
297 } 298 }
298 299
299 // static 300 // static
300 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { 301 void NewTabUI::RegisterUserPrefs(PrefService* prefs) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, 436 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource,
436 const char* mime_type, 437 const char* mime_type,
437 int resource_id) { 438 int resource_id) {
438 DCHECK(resource); 439 DCHECK(resource);
439 DCHECK(mime_type); 440 DCHECK(mime_type);
440 resource_map_[std::string(resource)] = 441 resource_map_[std::string(resource)] =
441 std::make_pair(std::string(mime_type), resource_id); 442 std::make_pair(std::string(mime_type), resource_id);
442 } 443 }
443 444
444 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} 445 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {}
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.h ('k') | chrome/browser/ui/webui/ntp/ntp_login_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698