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

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

Issue 22578004: Check if theme is ready. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Writes the theme pack to disk on a separate thread. 74 // Writes the theme pack to disk on a separate thread.
75 void WritePackToDiskCallback(BrowserThemePack* pack, 75 void WritePackToDiskCallback(BrowserThemePack* pack,
76 const base::FilePath& path) { 76 const base::FilePath& path) {
77 if (!pack->WriteToDisk(path)) 77 if (!pack->WriteToDisk(path))
78 NOTREACHED() << "Could not write theme pack to disk"; 78 NOTREACHED() << "Could not write theme pack to disk";
79 } 79 }
80 80
81 } // namespace 81 } // namespace
82 82
83 ThemeService::ThemeService() 83 ThemeService::ThemeService()
84 : rb_(ResourceBundle::GetSharedInstance()), 84 : ready_(false),
85 rb_(ResourceBundle::GetSharedInstance()),
85 profile_(NULL), 86 profile_(NULL),
86 ready_(false),
87 installed_pending_load_id_(kDefaultThemeID), 87 installed_pending_load_id_(kDefaultThemeID),
88 number_of_infobars_(0), 88 number_of_infobars_(0),
89 weak_ptr_factory_(this) { 89 weak_ptr_factory_(this) {
90 } 90 }
91 91
92 ThemeService::~ThemeService() { 92 ThemeService::~ThemeService() {
93 FreePlatformCaches(); 93 FreePlatformCaches();
94 } 94 }
95 95
96 void ThemeService::Init(Profile* profile) { 96 void ThemeService::Init(Profile* profile) {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 service->UninstallExtension(remove_list[i], false, NULL); 336 service->UninstallExtension(remove_list[i], false, NULL);
337 } 337 }
338 338
339 void ThemeService::UseDefaultTheme() { 339 void ThemeService::UseDefaultTheme() {
340 if (ready_) 340 if (ready_)
341 content::RecordAction(UserMetricsAction("Themes_Reset")); 341 content::RecordAction(UserMetricsAction("Themes_Reset"));
342 if (IsManagedUser()) { 342 if (IsManagedUser()) {
343 SetManagedUserTheme(); 343 SetManagedUserTheme();
344 return; 344 return;
345 } 345 }
346 if (ready_) { 346 ClearAllThemeData();
347 ClearAllThemeData(); 347 NotifyThemeChanged();
348 NotifyThemeChanged();
349 }
350 } 348 }
351 349
352 void ThemeService::SetNativeTheme() { 350 void ThemeService::SetNativeTheme() {
353 UseDefaultTheme(); 351 UseDefaultTheme();
354 } 352 }
355 353
356 bool ThemeService::UsingDefaultTheme() const { 354 bool ThemeService::UsingDefaultTheme() const {
357 std::string id = GetThemeID(); 355 std::string id = GetThemeID();
358 return id == ThemeService::kDefaultThemeID || 356 return id == ThemeService::kDefaultThemeID ||
359 (id == kDefaultThemeGalleryID && !IsManagedUser()); 357 (id == kDefaultThemeGalleryID && !IsManagedUser());
(...skipping 11 matching lines...) Expand all
371 DCHECK(CalledOnValidThread()); 369 DCHECK(CalledOnValidThread());
372 370
373 color_utils::HSL hsl; 371 color_utils::HSL hsl;
374 if (theme_supplier_.get() && theme_supplier_->GetTint(id, &hsl)) 372 if (theme_supplier_.get() && theme_supplier_->GetTint(id, &hsl))
375 return hsl; 373 return hsl;
376 374
377 return ThemeProperties::GetDefaultTint(id); 375 return ThemeProperties::GetDefaultTint(id);
378 } 376 }
379 377
380 void ThemeService::ClearAllThemeData() { 378 void ThemeService::ClearAllThemeData() {
379 if (!ready_)
380 return;
381
381 SwapThemeSupplier(NULL); 382 SwapThemeSupplier(NULL);
382 383
383 // Clear our image cache. 384 // Clear our image cache.
384 FreePlatformCaches(); 385 FreePlatformCaches();
385 386
386 profile_->GetPrefs()->ClearPref(prefs::kCurrentThemePackFilename); 387 profile_->GetPrefs()->ClearPref(prefs::kCurrentThemePackFilename);
387 SaveThemeID(kDefaultThemeID); 388 SaveThemeID(kDefaultThemeID);
388 389
389 // There should be no more infobars. This may not be the case because of 390 // There should be no more infobars. This may not be the case because of
390 // http://crbug.com/62154 391 // http://crbug.com/62154
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 void ThemeService::OnInfobarDestroyed() { 566 void ThemeService::OnInfobarDestroyed() {
566 number_of_infobars_--; 567 number_of_infobars_--;
567 568
568 if (number_of_infobars_ == 0) 569 if (number_of_infobars_ == 0)
569 RemoveUnusedThemes(false); 570 RemoveUnusedThemes(false);
570 } 571 }
571 572
572 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { 573 ThemeSyncableService* ThemeService::GetThemeSyncableService() const {
573 return theme_syncable_service_.get(); 574 return theme_syncable_service_.get();
574 } 575 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698