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 25 matching lines...) Expand all Loading... |
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 = ThemeService::GetThemeProviderForProfile(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()->CallJavascriptFunctionUnsafe("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 |