OLD | NEW |
---|---|
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 "chrome/browser/themes/theme_service.h" | 5 #include "chrome/browser/themes/theme_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
16 #include "chrome/browser/managed_mode/managed_user_theme.h" | |
17 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/themes/browser_theme_pack.h" | 17 #include "chrome/browser/themes/browser_theme_pack.h" |
19 #include "chrome/browser/themes/custom_theme_supplier.h" | 18 #include "chrome/browser/themes/custom_theme_supplier.h" |
20 #include "chrome/browser/themes/theme_properties.h" | 19 #include "chrome/browser/themes/theme_properties.h" |
21 #include "chrome/browser/themes/theme_syncable_service.h" | 20 #include "chrome/browser/themes/theme_syncable_service.h" |
22 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
23 #include "chrome/common/extensions/extension_manifest_constants.h" | 22 #include "chrome/common/extensions/extension_manifest_constants.h" |
24 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
25 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
26 #include "content/public/browser/user_metrics.h" | 25 #include "content/public/browser/user_metrics.h" |
27 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
28 #include "grit/ui_resources.h" | 27 #include "grit/ui_resources.h" |
29 #include "ui/base/layout.h" | 28 #include "ui/base/layout.h" |
30 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
31 #include "ui/gfx/image/image_skia.h" | 30 #include "ui/gfx/image/image_skia.h" |
32 | 31 |
32 #if defined(ENABLE_MANAGED_USERS) | |
33 #include "chrome/browser/managed_mode/managed_user_service.h" | |
34 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | |
35 #include "chrome/browser/managed_mode/managed_user_theme.h" | |
Bernhard Bauer
2013/08/08 15:12:45
I'm pretty sure this is never built on a platform
Adrian Kuegel
2013/08/08 15:26:35
Right, I didn't notice that the ManagedUserTheme i
| |
36 #endif | |
37 | |
33 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
34 #include "ui/base/win/shell.h" | 39 #include "ui/base/win/shell.h" |
35 #endif | 40 #endif |
36 | 41 |
37 using content::BrowserThread; | 42 using content::BrowserThread; |
38 using content::UserMetricsAction; | 43 using content::UserMetricsAction; |
39 using extensions::Extension; | 44 using extensions::Extension; |
40 using ui::ResourceBundle; | 45 using ui::ResourceBundle; |
41 | 46 |
42 typedef ThemeProperties Properties; | 47 typedef ThemeProperties Properties; |
(...skipping 27 matching lines...) Expand all Loading... | |
70 if (!pack->WriteToDisk(path)) | 75 if (!pack->WriteToDisk(path)) |
71 NOTREACHED() << "Could not write theme pack to disk"; | 76 NOTREACHED() << "Could not write theme pack to disk"; |
72 } | 77 } |
73 | 78 |
74 } // namespace | 79 } // namespace |
75 | 80 |
76 ThemeService::ThemeService() | 81 ThemeService::ThemeService() |
77 : ready_(false), | 82 : ready_(false), |
78 rb_(ResourceBundle::GetSharedInstance()), | 83 rb_(ResourceBundle::GetSharedInstance()), |
79 profile_(NULL), | 84 profile_(NULL), |
80 number_of_infobars_(0) { | 85 number_of_infobars_(0), |
86 weak_ptr_factory_(this) { | |
81 } | 87 } |
82 | 88 |
83 ThemeService::~ThemeService() { | 89 ThemeService::~ThemeService() { |
84 FreePlatformCaches(); | 90 FreePlatformCaches(); |
85 } | 91 } |
86 | 92 |
87 void ThemeService::Init(Profile* profile) { | 93 void ThemeService::Init(Profile* profile) { |
88 DCHECK(CalledOnValidThread()); | 94 DCHECK(CalledOnValidThread()); |
89 profile_ = profile; | 95 profile_ = profile; |
96 #if defined(ENABLE_MANAGED_USERS) | |
97 ManagedUserServiceFactory::GetForProfile(profile)->AddManagedUserInitCallback( | |
98 base::Bind(&ThemeService::SetManagedUserTheme, | |
99 weak_ptr_factory_.GetWeakPtr())); | |
100 #endif | |
90 | 101 |
91 LoadThemePrefs(); | 102 LoadThemePrefs(); |
92 | 103 |
93 if (!ready_) { | 104 if (!ready_) { |
94 registrar_.Add(this, | 105 registrar_.Add(this, |
95 chrome::NOTIFICATION_EXTENSIONS_READY, | 106 chrome::NOTIFICATION_EXTENSIONS_READY, |
96 content::Source<Profile>(profile_)); | 107 content::Source<Profile>(profile_)); |
97 } | 108 } |
98 | 109 |
99 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this)); | 110 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this)); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 void ThemeService::OnInfobarDestroyed() { | 473 void ThemeService::OnInfobarDestroyed() { |
463 number_of_infobars_--; | 474 number_of_infobars_--; |
464 | 475 |
465 if (number_of_infobars_ == 0) | 476 if (number_of_infobars_ == 0) |
466 RemoveUnusedThemes(); | 477 RemoveUnusedThemes(); |
467 } | 478 } |
468 | 479 |
469 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { | 480 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { |
470 return theme_syncable_service_.get(); | 481 return theme_syncable_service_.get(); |
471 } | 482 } |
OLD | NEW |