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

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

Issue 6766004: Create a ProfileDependencyManager to order ProfileKeyedService destruction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix improper usage of static_cast<> in existing mac code. Created 9 years, 8 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
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/themes/theme_service_factory.h » ('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) 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"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 203
204 ThemeService::~ThemeService() { 204 ThemeService::~ThemeService() {
205 FreePlatformCaches(); 205 FreePlatformCaches();
206 } 206 }
207 207
208 void ThemeService::Init(Profile* profile) { 208 void ThemeService::Init(Profile* profile) {
209 DCHECK(CalledOnValidThread()); 209 DCHECK(CalledOnValidThread());
210 profile_ = profile; 210 profile_ = profile;
211 211
212 registrar_.Add(this,
213 NotificationType::THEME_INSTALLED,
214 Source<Profile>(profile_));
215
212 LoadThemePrefs(); 216 LoadThemePrefs();
213 } 217 }
214 218
215 SkBitmap* ThemeService::GetBitmapNamed(int id) const { 219 SkBitmap* ThemeService::GetBitmapNamed(int id) const {
216 DCHECK(CalledOnValidThread()); 220 DCHECK(CalledOnValidThread());
217 221
218 SkBitmap* bitmap = NULL; 222 SkBitmap* bitmap = NULL;
219 223
220 if (theme_pack_.get()) 224 if (theme_pack_.get())
221 bitmap = theme_pack_->GetBitmapNamed(id); 225 bitmap = theme_pack_->GetBitmapNamed(id);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 NotifyPlatformThemeChanged(); 601 NotifyPlatformThemeChanged();
598 #endif // OS_MACOSX 602 #endif // OS_MACOSX
599 } 603 }
600 604
601 #if defined(OS_WIN) 605 #if defined(OS_WIN)
602 void ThemeService::FreePlatformCaches() { 606 void ThemeService::FreePlatformCaches() {
603 // Views (Skia) has no platform image cache to clear. 607 // Views (Skia) has no platform image cache to clear.
604 } 608 }
605 #endif 609 #endif
606 610
611 void ThemeService::Observe(NotificationType type,
612 const NotificationSource& source,
613 const NotificationDetails& details) {
614 DCHECK(type == NotificationType::THEME_INSTALLED);
615 const Extension* extension = Details<const Extension>(details).ptr();
616 SetTheme(extension);
617 }
618
607 void ThemeService::SavePackName(const FilePath& pack_path) { 619 void ThemeService::SavePackName(const FilePath& pack_path) {
608 profile_->GetPrefs()->SetFilePath( 620 profile_->GetPrefs()->SetFilePath(
609 prefs::kCurrentThemePackFilename, pack_path); 621 prefs::kCurrentThemePackFilename, pack_path);
610 } 622 }
611 623
612 void ThemeService::SaveThemeID(const std::string& id) { 624 void ThemeService::SaveThemeID(const std::string& id) {
613 profile_->GetPrefs()->SetString(prefs::kCurrentThemeID, id); 625 profile_->GetPrefs()->SetString(prefs::kCurrentThemeID, id);
614 } 626 }
615 627
616 void ThemeService::BuildFromExtension(const Extension* extension) { 628 void ThemeService::BuildFromExtension(const Extension* extension) {
(...skipping 18 matching lines...) Expand all
635 void ThemeService::OnInfobarDisplayed() { 647 void ThemeService::OnInfobarDisplayed() {
636 number_of_infobars_++; 648 number_of_infobars_++;
637 } 649 }
638 650
639 void ThemeService::OnInfobarDestroyed() { 651 void ThemeService::OnInfobarDestroyed() {
640 number_of_infobars_--; 652 number_of_infobars_--;
641 653
642 if (number_of_infobars_ == 0) 654 if (number_of_infobars_ == 0)
643 RemoveUnusedThemes(); 655 RemoveUnusedThemes();
644 } 656 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/themes/theme_service_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698