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

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

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase Created 6 years, 4 months 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 | Annotate | Revision Log
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 "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/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 FreePlatformCaches(); 94 FreePlatformCaches();
95 } 95 }
96 96
97 void ThemeService::Init(Profile* profile) { 97 void ThemeService::Init(Profile* profile) {
98 DCHECK(CalledOnValidThread()); 98 DCHECK(CalledOnValidThread());
99 profile_ = profile; 99 profile_ = profile;
100 100
101 LoadThemePrefs(); 101 LoadThemePrefs();
102 102
103 registrar_.Add(this, 103 registrar_.Add(this,
104 chrome::NOTIFICATION_EXTENSIONS_READY, 104 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
105 content::Source<Profile>(profile_)); 105 content::Source<Profile>(profile_));
106 106
107 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this)); 107 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this));
108 } 108 }
109 109
110 gfx::Image ThemeService::GetImageNamed(int id) const { 110 gfx::Image ThemeService::GetImageNamed(int id) const {
111 DCHECK(CalledOnValidThread()); 111 DCHECK(CalledOnValidThread());
112 112
113 gfx::Image image; 113 gfx::Image image;
114 if (theme_supplier_.get()) 114 if (theme_supplier_.get())
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 data = rb_.LoadDataResourceBytesForScale(id, ui::SCALE_FACTOR_100P); 240 data = rb_.LoadDataResourceBytesForScale(id, ui::SCALE_FACTOR_100P);
241 241
242 return data; 242 return data;
243 } 243 }
244 244
245 void ThemeService::Observe(int type, 245 void ThemeService::Observe(int type,
246 const content::NotificationSource& source, 246 const content::NotificationSource& source,
247 const content::NotificationDetails& details) { 247 const content::NotificationDetails& details) {
248 using content::Details; 248 using content::Details;
249 switch (type) { 249 switch (type) {
250 case chrome::NOTIFICATION_EXTENSIONS_READY: 250 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED:
251 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY, 251 registrar_.Remove(this,
252 content::Source<Profile>(profile_)); 252 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
253 content::Source<Profile>(profile_));
253 OnExtensionServiceReady(); 254 OnExtensionServiceReady();
254 break; 255 break;
255 case chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED: { 256 case extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED: {
256 // The theme may be initially disabled. Wait till it is loaded (if ever). 257 // The theme may be initially disabled. Wait till it is loaded (if ever).
257 Details<const extensions::InstalledExtensionInfo> installed_details( 258 Details<const extensions::InstalledExtensionInfo> installed_details(
258 details); 259 details);
259 if (installed_details->extension->is_theme()) 260 if (installed_details->extension->is_theme())
260 installed_pending_load_id_ = installed_details->extension->id(); 261 installed_pending_load_id_ = installed_details->extension->id();
261 break; 262 break;
262 } 263 }
263 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: 264 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
264 {
265 const Extension* extension = Details<const Extension>(details).ptr(); 265 const Extension* extension = Details<const Extension>(details).ptr();
266 if (extension->is_theme() && 266 if (extension->is_theme() &&
267 installed_pending_load_id_ != kDefaultThemeID && 267 installed_pending_load_id_ != kDefaultThemeID &&
268 installed_pending_load_id_ == extension->id()) { 268 installed_pending_load_id_ == extension->id()) {
269 SetTheme(extension); 269 SetTheme(extension);
270 } 270 }
271 installed_pending_load_id_ = kDefaultThemeID; 271 installed_pending_load_id_ = kDefaultThemeID;
272 break; 272 break;
273 } 273 }
274 case chrome::NOTIFICATION_EXTENSION_ENABLED: 274 case extensions::NOTIFICATION_EXTENSION_ENABLED: {
275 {
276 const Extension* extension = Details<const Extension>(details).ptr(); 275 const Extension* extension = Details<const Extension>(details).ptr();
277 if (extension->is_theme()) 276 if (extension->is_theme())
278 SetTheme(extension); 277 SetTheme(extension);
279 break; 278 break;
280 } 279 }
281 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: 280 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
282 {
283 Details<const UnloadedExtensionInfo> unloaded_details(details); 281 Details<const UnloadedExtensionInfo> unloaded_details(details);
284 if (unloaded_details->reason != UnloadedExtensionInfo::REASON_UPDATE && 282 if (unloaded_details->reason != UnloadedExtensionInfo::REASON_UPDATE &&
285 unloaded_details->extension->is_theme() && 283 unloaded_details->extension->is_theme() &&
286 unloaded_details->extension->id() == GetThemeID()) { 284 unloaded_details->extension->id() == GetThemeID()) {
287 UseDefaultTheme(); 285 UseDefaultTheme();
288 } 286 }
289 break; 287 break;
290 } 288 }
291 } 289 }
292 } 290 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 // If the ThemeService is not ready yet, the custom theme data pack needs to 499 // If the ThemeService is not ready yet, the custom theme data pack needs to
502 // be recreated from the extension. 500 // be recreated from the extension.
503 MigrateTheme(); 501 MigrateTheme();
504 set_ready(); 502 set_ready();
505 503
506 // Send notification in case anyone requested data and cached it when the 504 // Send notification in case anyone requested data and cached it when the
507 // theme service was not ready yet. 505 // theme service was not ready yet.
508 NotifyThemeChanged(); 506 NotifyThemeChanged();
509 } 507 }
510 508
509 registrar_.Add(
510 this,
511 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
512 content::Source<Profile>(profile_));
511 registrar_.Add(this, 513 registrar_.Add(this,
512 chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, 514 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
513 content::Source<Profile>(profile_)); 515 content::Source<Profile>(profile_));
514 registrar_.Add(this, 516 registrar_.Add(this,
515 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 517 extensions::NOTIFICATION_EXTENSION_ENABLED,
516 content::Source<Profile>(profile_)); 518 content::Source<Profile>(profile_));
517 registrar_.Add(this, 519 registrar_.Add(this,
518 chrome::NOTIFICATION_EXTENSION_ENABLED, 520 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
519 content::Source<Profile>(profile_));
520 registrar_.Add(this,
521 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
522 content::Source<Profile>(profile_)); 521 content::Source<Profile>(profile_));
523 522
524 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, 523 base::MessageLoop::current()->PostDelayedTask(FROM_HERE,
525 base::Bind(&ThemeService::RemoveUnusedThemes, 524 base::Bind(&ThemeService::RemoveUnusedThemes,
526 weak_ptr_factory_.GetWeakPtr(), 525 weak_ptr_factory_.GetWeakPtr(),
527 false), 526 false),
528 base::TimeDelta::FromSeconds(kRemoveUnusedThemesStartupDelay)); 527 base::TimeDelta::FromSeconds(kRemoveUnusedThemesStartupDelay));
529 } 528 }
530 529
531 void ThemeService::MigrateTheme() { 530 void ThemeService::MigrateTheme() {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 void ThemeService::OnInfobarDestroyed() { 604 void ThemeService::OnInfobarDestroyed() {
606 number_of_infobars_--; 605 number_of_infobars_--;
607 606
608 if (number_of_infobars_ == 0) 607 if (number_of_infobars_ == 0)
609 RemoveUnusedThemes(false); 608 RemoveUnusedThemes(false);
610 } 609 }
611 610
612 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { 611 ThemeSyncableService* ThemeService::GetThemeSyncableService() const {
613 return theme_syncable_service_.get(); 612 return theme_syncable_service_.get();
614 } 613 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/two_client_apps_sync_test.cc ('k') | chrome/browser/themes/theme_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698