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

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

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: response to sky Created 8 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
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/sequenced_task_runner.h" 9 #include "base/sequenced_task_runner.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 BuildFromExtension(extension); 352 BuildFromExtension(extension);
353 SaveThemeID(extension->id()); 353 SaveThemeID(extension->id());
354 354
355 NotifyThemeChanged(); 355 NotifyThemeChanged();
356 content::RecordAction(UserMetricsAction("Themes_Installed")); 356 content::RecordAction(UserMetricsAction("Themes_Installed"));
357 } 357 }
358 358
359 void ThemeService::RemoveUnusedThemes() { 359 void ThemeService::RemoveUnusedThemes() {
360 if (!profile_) 360 if (!profile_)
361 return; 361 return;
362 ExtensionService* service = profile_->GetExtensionService(); 362 ExtensionService* service =
363 extensions::ExtensionSystem::Get(profile_)->extension_service();
363 if (!service) 364 if (!service)
364 return; 365 return;
365 std::string current_theme = GetThemeID(); 366 std::string current_theme = GetThemeID();
366 std::vector<std::string> remove_list; 367 std::vector<std::string> remove_list;
367 const ExtensionSet* extensions = service->extensions(); 368 const ExtensionSet* extensions = service->extensions();
368 for (ExtensionSet::const_iterator it = extensions->begin(); 369 for (ExtensionSet::const_iterator it = extensions->begin();
369 it != extensions->end(); ++it) { 370 it != extensions->end(); ++it) {
370 if ((*it)->is_theme() && (*it)->id() != current_theme) { 371 if ((*it)->is_theme() && (*it)->id() != current_theme) {
371 remove_list.push_back((*it)->id()); 372 remove_list.push_back((*it)->id());
372 } 373 }
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 if (path != FilePath()) { 607 if (path != FilePath()) {
607 theme_pack_ = BrowserThemePack::BuildFromDataPack(path, current_id); 608 theme_pack_ = BrowserThemePack::BuildFromDataPack(path, current_id);
608 loaded_pack = theme_pack_.get() != NULL; 609 loaded_pack = theme_pack_.get() != NULL;
609 } 610 }
610 611
611 if (loaded_pack) { 612 if (loaded_pack) {
612 content::RecordAction(UserMetricsAction("Themes.Loaded")); 613 content::RecordAction(UserMetricsAction("Themes.Loaded"));
613 } else { 614 } else {
614 // TODO(erg): We need to pop up a dialog informing the user that their 615 // TODO(erg): We need to pop up a dialog informing the user that their
615 // theme is being migrated. 616 // theme is being migrated.
616 ExtensionService* service = profile_->GetExtensionService(); 617 ExtensionService* service =
618 extensions::ExtensionSystem::Get(profile_)->extension_service();
617 if (service) { 619 if (service) {
618 const Extension* extension = 620 const Extension* extension =
619 service->GetExtensionById(current_id, false); 621 service->GetExtensionById(current_id, false);
620 if (extension) { 622 if (extension) {
621 DLOG(ERROR) << "Migrating theme"; 623 DLOG(ERROR) << "Migrating theme";
622 BuildFromExtension(extension); 624 BuildFromExtension(extension);
623 content::RecordAction(UserMetricsAction("Themes.Migrated")); 625 content::RecordAction(UserMetricsAction("Themes.Migrated"));
624 } else { 626 } else {
625 DLOG(ERROR) << "Theme is mysteriously gone."; 627 DLOG(ERROR) << "Theme is mysteriously gone.";
626 ClearAllThemeData(); 628 ClearAllThemeData();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 void ThemeService::OnInfobarDestroyed() { 709 void ThemeService::OnInfobarDestroyed() {
708 number_of_infobars_--; 710 number_of_infobars_--;
709 711
710 if (number_of_infobars_ == 0) 712 if (number_of_infobars_ == 0)
711 RemoveUnusedThemes(); 713 RemoveUnusedThemes();
712 } 714 }
713 715
714 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { 716 ThemeSyncableService* ThemeService::GetThemeSyncableService() const {
715 return theme_syncable_service_.get(); 717 return theme_syncable_service_.get();
716 } 718 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698