OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/themes/theme_service.h" | 5 #include "chrome/browser/themes/theme_service.h" |
6 | 6 |
7 #include "base/string_split.h" | 7 #include "base/string_split.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/themes/browser_theme_pack.h" | 12 #include "chrome/browser/themes/browser_theme_pack.h" |
13 #include "chrome/common/chrome_constants.h" | 13 #include "chrome/common/chrome_constants.h" |
| 14 #include "chrome/common/chrome_notification_types.h" |
14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
15 #include "content/browser/user_metrics.h" | 16 #include "content/browser/user_metrics.h" |
16 #include "content/common/notification_service.h" | 17 #include "content/common/notification_service.h" |
17 #include "content/common/notification_type.h" | |
18 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
19 #include "grit/theme_resources_standard.h" | 19 #include "grit/theme_resources_standard.h" |
20 #include "grit/ui_resources.h" | 20 #include "grit/ui_resources.h" |
21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
22 | 22 |
23 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
24 #include "views/widget/native_widget_win.h" | 24 #include "views/widget/native_widget_win.h" |
25 #endif | 25 #endif |
26 | 26 |
27 // Strings used in alignment properties. | 27 // Strings used in alignment properties. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 void ThemeService::Init(Profile* profile) { | 209 void ThemeService::Init(Profile* profile) { |
210 DCHECK(CalledOnValidThread()); | 210 DCHECK(CalledOnValidThread()); |
211 profile_ = profile; | 211 profile_ = profile; |
212 | 212 |
213 // Listen to EXTENSION_LOADED instead of EXTENSION_INSTALLED because | 213 // Listen to EXTENSION_LOADED instead of EXTENSION_INSTALLED because |
214 // the extension cannot yet be found via GetExtensionById() if it is | 214 // the extension cannot yet be found via GetExtensionById() if it is |
215 // installed but not loaded (which may confuse listeners to | 215 // installed but not loaded (which may confuse listeners to |
216 // BROWSER_THEME_CHANGED). | 216 // BROWSER_THEME_CHANGED). |
217 registrar_.Add(this, | 217 registrar_.Add(this, |
218 NotificationType::EXTENSION_LOADED, | 218 chrome::NOTIFICATION_EXTENSION_LOADED, |
219 Source<Profile>(profile_)); | 219 Source<Profile>(profile_)); |
220 | 220 |
221 LoadThemePrefs(); | 221 LoadThemePrefs(); |
222 } | 222 } |
223 | 223 |
224 SkBitmap* ThemeService::GetBitmapNamed(int id) const { | 224 SkBitmap* ThemeService::GetBitmapNamed(int id) const { |
225 DCHECK(CalledOnValidThread()); | 225 DCHECK(CalledOnValidThread()); |
226 | 226 |
227 SkBitmap* bitmap = NULL; | 227 SkBitmap* bitmap = NULL; |
228 | 228 |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 } | 595 } |
596 } | 596 } |
597 } | 597 } |
598 } | 598 } |
599 } | 599 } |
600 | 600 |
601 void ThemeService::NotifyThemeChanged() { | 601 void ThemeService::NotifyThemeChanged() { |
602 VLOG(1) << "Sending BROWSER_THEME_CHANGED"; | 602 VLOG(1) << "Sending BROWSER_THEME_CHANGED"; |
603 // Redraw! | 603 // Redraw! |
604 NotificationService* service = NotificationService::current(); | 604 NotificationService* service = NotificationService::current(); |
605 service->Notify(NotificationType::BROWSER_THEME_CHANGED, | 605 service->Notify(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
606 Source<ThemeService>(this), | 606 Source<ThemeService>(this), |
607 NotificationService::NoDetails()); | 607 NotificationService::NoDetails()); |
608 #if defined(OS_MACOSX) | 608 #if defined(OS_MACOSX) |
609 NotifyPlatformThemeChanged(); | 609 NotifyPlatformThemeChanged(); |
610 #endif // OS_MACOSX | 610 #endif // OS_MACOSX |
611 } | 611 } |
612 | 612 |
613 #if defined(OS_WIN) | 613 #if defined(OS_WIN) |
614 void ThemeService::FreePlatformCaches() { | 614 void ThemeService::FreePlatformCaches() { |
615 // Views (Skia) has no platform image cache to clear. | 615 // Views (Skia) has no platform image cache to clear. |
616 } | 616 } |
617 #endif | 617 #endif |
618 | 618 |
619 void ThemeService::Observe(NotificationType type, | 619 void ThemeService::Observe(int type, |
620 const NotificationSource& source, | 620 const NotificationSource& source, |
621 const NotificationDetails& details) { | 621 const NotificationDetails& details) { |
622 DCHECK(type == NotificationType::EXTENSION_LOADED); | 622 DCHECK(type == chrome::NOTIFICATION_EXTENSION_LOADED); |
623 const Extension* extension = Details<const Extension>(details).ptr(); | 623 const Extension* extension = Details<const Extension>(details).ptr(); |
624 if (!extension->is_theme()) { | 624 if (!extension->is_theme()) { |
625 return; | 625 return; |
626 } | 626 } |
627 SetTheme(extension); | 627 SetTheme(extension); |
628 } | 628 } |
629 | 629 |
630 void ThemeService::SavePackName(const FilePath& pack_path) { | 630 void ThemeService::SavePackName(const FilePath& pack_path) { |
631 profile_->GetPrefs()->SetFilePath( | 631 profile_->GetPrefs()->SetFilePath( |
632 prefs::kCurrentThemePackFilename, pack_path); | 632 prefs::kCurrentThemePackFilename, pack_path); |
(...skipping 25 matching lines...) Expand all Loading... |
658 void ThemeService::OnInfobarDisplayed() { | 658 void ThemeService::OnInfobarDisplayed() { |
659 number_of_infobars_++; | 659 number_of_infobars_++; |
660 } | 660 } |
661 | 661 |
662 void ThemeService::OnInfobarDestroyed() { | 662 void ThemeService::OnInfobarDestroyed() { |
663 number_of_infobars_--; | 663 number_of_infobars_--; |
664 | 664 |
665 if (number_of_infobars_ == 0) | 665 if (number_of_infobars_ == 0) |
666 RemoveUnusedThemes(); | 666 RemoveUnusedThemes(); |
667 } | 667 } |
OLD | NEW |