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

Side by Side Diff: chrome/browser/themes/theme_service.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 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
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/themes/theme_service.h" 5 #include "chrome/browser/themes/theme_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 22 matching lines...) Expand all
33 #include "components/grit/components_scaled_resources.h" 33 #include "components/grit/components_scaled_resources.h"
34 #include "components/prefs/pref_service.h" 34 #include "components/prefs/pref_service.h"
35 #include "content/public/browser/notification_service.h" 35 #include "content/public/browser/notification_service.h"
36 #include "content/public/browser/user_metrics.h" 36 #include "content/public/browser/user_metrics.h"
37 #include "extensions/browser/extension_prefs.h" 37 #include "extensions/browser/extension_prefs.h"
38 #include "extensions/browser/extension_registry.h" 38 #include "extensions/browser/extension_registry.h"
39 #include "extensions/browser/extension_system.h" 39 #include "extensions/browser/extension_system.h"
40 #include "extensions/browser/uninstall_reason.h" 40 #include "extensions/browser/uninstall_reason.h"
41 #include "extensions/common/extension.h" 41 #include "extensions/common/extension.h"
42 #include "extensions/common/extension_set.h" 42 #include "extensions/common/extension_set.h"
43 #include "extensions/features/features.h"
43 #include "ui/base/layout.h" 44 #include "ui/base/layout.h"
44 #include "ui/base/resource/resource_bundle.h" 45 #include "ui/base/resource/resource_bundle.h"
45 #include "ui/gfx/color_palette.h" 46 #include "ui/gfx/color_palette.h"
46 #include "ui/gfx/image/image_skia.h" 47 #include "ui/gfx/image/image_skia.h"
47 #include "ui/native_theme/common_theme.h" 48 #include "ui/native_theme/common_theme.h"
48 #include "ui/native_theme/native_theme.h" 49 #include "ui/native_theme/native_theme.h"
49 50
50 #if defined(ENABLE_EXTENSIONS) 51 #if BUILDFLAG(ENABLE_EXTENSIONS)
51 #include "extensions/browser/extension_registry_observer.h" 52 #include "extensions/browser/extension_registry_observer.h"
52 #endif 53 #endif
53 54
54 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) 55 #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
55 #include "chrome/browser/supervised_user/supervised_user_theme.h" 56 #include "chrome/browser/supervised_user/supervised_user_theme.h"
56 #endif 57 #endif
57 58
58 using base::UserMetricsAction; 59 using base::UserMetricsAction;
59 using content::BrowserThread; 60 using content::BrowserThread;
60 using extensions::Extension; 61 using extensions::Extension;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 150
150 base::RefCountedMemory* ThemeService::BrowserThemeProvider::GetRawData( 151 base::RefCountedMemory* ThemeService::BrowserThemeProvider::GetRawData(
151 int id, 152 int id,
152 ui::ScaleFactor scale_factor) const { 153 ui::ScaleFactor scale_factor) const {
153 return theme_service_.GetRawData(id, scale_factor); 154 return theme_service_.GetRawData(id, scale_factor);
154 } 155 }
155 156
156 157
157 // ThemeService::ThemeObserver ------------------------------------------------ 158 // ThemeService::ThemeObserver ------------------------------------------------
158 159
159 #if defined(ENABLE_EXTENSIONS) 160 #if BUILDFLAG(ENABLE_EXTENSIONS)
160 class ThemeService::ThemeObserver 161 class ThemeService::ThemeObserver
161 : public extensions::ExtensionRegistryObserver { 162 : public extensions::ExtensionRegistryObserver {
162 public: 163 public:
163 explicit ThemeObserver(ThemeService* service) : theme_service_(service) { 164 explicit ThemeObserver(ThemeService* service) : theme_service_(service) {
164 extensions::ExtensionRegistry::Get(theme_service_->profile_) 165 extensions::ExtensionRegistry::Get(theme_service_->profile_)
165 ->AddObserver(this); 166 ->AddObserver(this);
166 } 167 }
167 168
168 ~ThemeObserver() override { 169 ~ThemeObserver() override {
169 extensions::ExtensionRegistry::Get(theme_service_->profile_) 170 extensions::ExtensionRegistry::Get(theme_service_->profile_)
(...skipping 28 matching lines...) Expand all
198 if (reason != extensions::UnloadedExtensionInfo::REASON_UPDATE && 199 if (reason != extensions::UnloadedExtensionInfo::REASON_UPDATE &&
199 reason != extensions::UnloadedExtensionInfo::REASON_LOCK_ALL && 200 reason != extensions::UnloadedExtensionInfo::REASON_LOCK_ALL &&
200 extension->is_theme() && 201 extension->is_theme() &&
201 extension->id() == theme_service_->GetThemeID()) { 202 extension->id() == theme_service_->GetThemeID()) {
202 theme_service_->UseDefaultTheme(); 203 theme_service_->UseDefaultTheme();
203 } 204 }
204 } 205 }
205 206
206 ThemeService* theme_service_; 207 ThemeService* theme_service_;
207 }; 208 };
208 #endif // defined(ENABLE_EXTENSIONS) 209 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
209 210
210 211
211 // ThemeService --------------------------------------------------------------- 212 // ThemeService ---------------------------------------------------------------
212 213
213 // The default theme if we haven't installed a theme yet or if we've clicked 214 // The default theme if we haven't installed a theme yet or if we've clicked
214 // the "Use Classic" button. 215 // the "Use Classic" button.
215 const char ThemeService::kDefaultThemeID[] = ""; 216 const char ThemeService::kDefaultThemeID[] = "";
216 217
217 ThemeService::ThemeService() 218 ThemeService::ThemeService()
218 : ready_(false), 219 : ready_(false),
(...skipping 16 matching lines...) Expand all
235 LoadThemePrefs(); 236 LoadThemePrefs();
236 237
237 registrar_.Add(this, 238 registrar_.Add(this,
238 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, 239 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
239 content::Source<Profile>(profile_)); 240 content::Source<Profile>(profile_));
240 241
241 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this)); 242 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this));
242 } 243 }
243 244
244 void ThemeService::Shutdown() { 245 void ThemeService::Shutdown() {
245 #if defined(ENABLE_EXTENSIONS) 246 #if BUILDFLAG(ENABLE_EXTENSIONS)
246 theme_observer_.reset(); 247 theme_observer_.reset();
247 #endif 248 #endif
248 } 249 }
249 250
250 void ThemeService::Observe(int type, 251 void ThemeService::Observe(int type,
251 const content::NotificationSource& source, 252 const content::NotificationSource& source,
252 const content::NotificationDetails& details) { 253 const content::NotificationDetails& details) {
253 using content::Details; 254 using content::Details;
254 switch (type) { 255 switch (type) {
255 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED: 256 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED:
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 // If the ThemeService is not ready yet, the custom theme data pack needs to 790 // If the ThemeService is not ready yet, the custom theme data pack needs to
790 // be recreated from the extension. 791 // be recreated from the extension.
791 MigrateTheme(); 792 MigrateTheme();
792 set_ready(); 793 set_ready();
793 794
794 // Send notification in case anyone requested data and cached it when the 795 // Send notification in case anyone requested data and cached it when the
795 // theme service was not ready yet. 796 // theme service was not ready yet.
796 NotifyThemeChanged(); 797 NotifyThemeChanged();
797 } 798 }
798 799
799 #if defined(ENABLE_EXTENSIONS) 800 #if BUILDFLAG(ENABLE_EXTENSIONS)
800 theme_observer_.reset(new ThemeObserver(this)); 801 theme_observer_.reset(new ThemeObserver(this));
801 #endif 802 #endif
802 803
803 registrar_.Add(this, 804 registrar_.Add(this,
804 extensions::NOTIFICATION_EXTENSION_ENABLED, 805 extensions::NOTIFICATION_EXTENSION_ENABLED,
805 content::Source<Profile>(profile_)); 806 content::Source<Profile>(profile_));
806 807
807 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 808 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
808 FROM_HERE, base::Bind(&ThemeService::RemoveUnusedThemes, 809 FROM_HERE, base::Bind(&ThemeService::RemoveUnusedThemes,
809 weak_ptr_factory_.GetWeakPtr(), false), 810 weak_ptr_factory_.GetWeakPtr(), false),
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 875
875 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) 876 #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
876 bool ThemeService::IsSupervisedUser() const { 877 bool ThemeService::IsSupervisedUser() const {
877 return profile_->IsSupervised(); 878 return profile_->IsSupervised();
878 } 879 }
879 880
880 void ThemeService::SetSupervisedUserTheme() { 881 void ThemeService::SetSupervisedUserTheme() {
881 SetCustomDefaultTheme(new SupervisedUserTheme); 882 SetCustomDefaultTheme(new SupervisedUserTheme);
882 } 883 }
883 #endif 884 #endif
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698