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

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

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h"
10 #include "base/memory/ref_counted_memory.h" 11 #include "base/memory/ref_counted_memory.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
14 #include "base/single_thread_task_runner.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/thread_task_runner_handle.h"
16 #include "chrome/browser/chrome_notification_types.h" 18 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/themes/browser_theme_pack.h" 21 #include "chrome/browser/themes/browser_theme_pack.h"
20 #include "chrome/browser/themes/custom_theme_supplier.h" 22 #include "chrome/browser/themes/custom_theme_supplier.h"
21 #include "chrome/browser/themes/theme_properties.h" 23 #include "chrome/browser/themes/theme_properties.h"
22 #include "chrome/browser/themes/theme_syncable_service.h" 24 #include "chrome/browser/themes/theme_syncable_service.h"
23 #include "chrome/common/chrome_constants.h" 25 #include "chrome/common/chrome_constants.h"
24 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
25 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 // Clear our image cache. 490 // Clear our image cache.
489 FreePlatformCaches(); 491 FreePlatformCaches();
490 492
491 profile_->GetPrefs()->ClearPref(prefs::kCurrentThemePackFilename); 493 profile_->GetPrefs()->ClearPref(prefs::kCurrentThemePackFilename);
492 SaveThemeID(kDefaultThemeID); 494 SaveThemeID(kDefaultThemeID);
493 495
494 // There should be no more infobars. This may not be the case because of 496 // There should be no more infobars. This may not be the case because of
495 // http://crbug.com/62154 497 // http://crbug.com/62154
496 // RemoveUnusedThemes is called on a task because ClearAllThemeData() may 498 // RemoveUnusedThemes is called on a task because ClearAllThemeData() may
497 // be called as a result of NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED. 499 // be called as a result of NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED.
498 base::MessageLoop::current()->PostTask(FROM_HERE, 500 base::ThreadTaskRunnerHandle::Get()->PostTask(
499 base::Bind(&ThemeService::RemoveUnusedThemes, 501 FROM_HERE, base::Bind(&ThemeService::RemoveUnusedThemes,
500 weak_ptr_factory_.GetWeakPtr(), 502 weak_ptr_factory_.GetWeakPtr(), true));
501 true));
502 } 503 }
503 504
504 void ThemeService::LoadThemePrefs() { 505 void ThemeService::LoadThemePrefs() {
505 PrefService* prefs = profile_->GetPrefs(); 506 PrefService* prefs = profile_->GetPrefs();
506 507
507 std::string current_id = GetThemeID(); 508 std::string current_id = GetThemeID();
508 if (current_id == kDefaultThemeID) { 509 if (current_id == kDefaultThemeID) {
509 #if defined(ENABLE_SUPERVISED_USERS) 510 #if defined(ENABLE_SUPERVISED_USERS)
510 // Supervised users have a different default theme. 511 // Supervised users have a different default theme.
511 if (IsSupervisedUser()) { 512 if (IsSupervisedUser()) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 } 580 }
580 581
581 #if defined(ENABLE_EXTENSIONS) 582 #if defined(ENABLE_EXTENSIONS)
582 theme_observer_.reset(new ThemeObserver(this)); 583 theme_observer_.reset(new ThemeObserver(this));
583 #endif 584 #endif
584 585
585 registrar_.Add(this, 586 registrar_.Add(this,
586 extensions::NOTIFICATION_EXTENSION_ENABLED, 587 extensions::NOTIFICATION_EXTENSION_ENABLED,
587 content::Source<Profile>(profile_)); 588 content::Source<Profile>(profile_));
588 589
589 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, 590 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
590 base::Bind(&ThemeService::RemoveUnusedThemes, 591 FROM_HERE, base::Bind(&ThemeService::RemoveUnusedThemes,
591 weak_ptr_factory_.GetWeakPtr(), 592 weak_ptr_factory_.GetWeakPtr(), false),
592 false),
593 base::TimeDelta::FromSeconds(kRemoveUnusedThemesStartupDelay)); 593 base::TimeDelta::FromSeconds(kRemoveUnusedThemesStartupDelay));
594 } 594 }
595 595
596 void ThemeService::MigrateTheme() { 596 void ThemeService::MigrateTheme() {
597 // TODO(erg): We need to pop up a dialog informing the user that their 597 // TODO(erg): We need to pop up a dialog informing the user that their
598 // theme is being migrated. 598 // theme is being migrated.
599 ExtensionService* service = 599 ExtensionService* service =
600 extensions::ExtensionSystem::Get(profile_)->extension_service(); 600 extensions::ExtensionSystem::Get(profile_)->extension_service();
601 const Extension* extension = 601 const Extension* extension =
602 service ? service->GetExtensionById(GetThemeID(), false) : nullptr; 602 service ? service->GetExtensionById(GetThemeID(), false) : nullptr;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 void ThemeService::OnInfobarDestroyed() { 672 void ThemeService::OnInfobarDestroyed() {
673 number_of_infobars_--; 673 number_of_infobars_--;
674 674
675 if (number_of_infobars_ == 0) 675 if (number_of_infobars_ == 0)
676 RemoveUnusedThemes(false); 676 RemoveUnusedThemes(false);
677 } 677 }
678 678
679 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { 679 ThemeSyncableService* ThemeService::GetThemeSyncableService() const {
680 return theme_syncable_service_.get(); 680 return theme_syncable_service_.get();
681 } 681 }
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/task_manager_browsertest_util.cc ('k') | chrome/browser/web_resource/promo_resource_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698