| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/webui/theme_handler.h" | 5 #include "chrome/browser/ui/webui/theme_handler.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/themes/theme_service.h" | 10 #include "chrome/browser/themes/theme_service.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 32 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 33 content::Source<ThemeService>( | 33 content::Source<ThemeService>( |
| 34 ThemeServiceFactory::GetForProfile(GetProfile()))); | 34 ThemeServiceFactory::GetForProfile(GetProfile()))); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void ThemeHandler::Observe(int type, | 37 void ThemeHandler::Observe(int type, |
| 38 const content::NotificationSource& source, | 38 const content::NotificationSource& source, |
| 39 const content::NotificationDetails& details) { | 39 const content::NotificationDetails& details) { |
| 40 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); | 40 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); |
| 41 InitializeCSSCaches(); | 41 InitializeCSSCaches(); |
| 42 bool has_custom_bg = ThemeServiceFactory::GetForProfile(GetProfile()) | 42 bool has_custom_bg = ThemeService::GetThemeProviderForProfile(GetProfile()) |
| 43 ->HasCustomImage(IDR_THEME_NTP_BACKGROUND); | 43 .HasCustomImage(IDR_THEME_NTP_BACKGROUND); |
| 44 base::DictionaryValue dictionary; | 44 base::DictionaryValue dictionary; |
| 45 dictionary.SetBoolean("hasCustomBackground", has_custom_bg); | 45 dictionary.SetBoolean("hasCustomBackground", has_custom_bg); |
| 46 web_ui()->CallJavascriptFunction("ntp.themeChanged", dictionary); | 46 web_ui()->CallJavascriptFunction("ntp.themeChanged", dictionary); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ThemeHandler::InitializeCSSCaches() { | 49 void ThemeHandler::InitializeCSSCaches() { |
| 50 Profile* profile = GetProfile(); | 50 Profile* profile = GetProfile(); |
| 51 ThemeSource* theme = new ThemeSource(profile); | 51 ThemeSource* theme = new ThemeSource(profile); |
| 52 content::URLDataSource::Add(profile, theme); | 52 content::URLDataSource::Add(profile, theme); |
| 53 } | 53 } |
| 54 | 54 |
| 55 Profile* ThemeHandler::GetProfile() const { | 55 Profile* ThemeHandler::GetProfile() const { |
| 56 return Profile::FromWebUI(web_ui()); | 56 return Profile::FromWebUI(web_ui()); |
| 57 } | 57 } |
| OLD | NEW |