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

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 6546072: Clean up how we handle themes in the extensions system and management API.... Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_service.cc
===================================================================
--- chrome/browser/extensions/extension_service.cc (revision 75613)
+++ chrome/browser/extensions/extension_service.cc (working copy)
@@ -432,6 +432,10 @@
registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED,
NotificationService::AllSources());
+
+ registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
+ NotificationService::AllSources());
+
pref_change_registrar_.Init(profile->GetPrefs());
pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, this);
pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, this);
@@ -504,7 +508,10 @@
ExtensionBookmarkEventRouter::GetInstance()->Observe(
profile_->GetBookmarkModel());
ExtensionCookiesEventRouter::GetInstance()->Init();
- ExtensionManagementEventRouter::GetInstance()->Init();
+
+ management_event_router_.reset(new ExtensionManagementEventRouter());
+ management_event_router_->Init();
+
ExtensionProcessesEventRouter::GetInstance()->ObserveProfile(profile_);
ExtensionWebNavigationEventRouter::GetInstance()->Init();
event_routers_initialized_ = true;
@@ -1252,6 +1259,7 @@
updater_->Stop();
}
browser_event_router_.reset();
+ management_event_router_.reset();
pref_change_registrar_.RemoveAll();
profile_ = NULL;
toolbar_model_.DestroyingProfile();
@@ -1705,9 +1713,9 @@
// Make sure we preserve enabled/disabled states.
Extension::State existing_state =
extension_prefs_->GetExtensionState(extension->id());
- initial_state =
- (existing_state == Extension::DISABLED) ?
- Extension::DISABLED : Extension::ENABLED;
+ initial_state = Extension::ENABLED;
+ if (!extension->is_theme() && existing_state == Extension::DISABLED)
+ initial_state = Extension::DISABLED;
initial_enable_incognito =
extension_prefs_->IsIncognitoEnabled(extension->id());
}
@@ -1723,19 +1731,10 @@
if (extension->location() == Extension::LOAD)
extension_prefs_->SetAllowFileAccess(extension->id(), true);
- // If the extension is a theme, tell the profile (and therefore ThemeProvider)
- // to apply it.
- if (extension->is_theme()) {
- NotificationService::current()->Notify(
- NotificationType::THEME_INSTALLED,
- Source<Profile>(profile_),
- Details<const Extension>(extension));
- } else {
- NotificationService::current()->Notify(
- NotificationType::EXTENSION_INSTALLED,
- Source<Profile>(profile_),
- Details<const Extension>(extension));
- }
+ NotificationService::current()->Notify(
+ NotificationType::EXTENSION_INSTALLED,
+ Source<Profile>(profile_),
+ Details<const Extension>(extension));
if (extension->is_app()) {
ExtensionIdSet installed_ids = GetAppIds();
@@ -1919,6 +1918,29 @@
const NotificationSource& source,
const NotificationDetails& details) {
switch (type.value) {
+ case NotificationType::BROWSER_THEME_CHANGED: {
+ // Disable any other enabled themes.
+ std::string new_theme_id;
+ const Extension* theme = Details<const Extension>(details).ptr();
+ if (theme)
+ new_theme_id = theme->id();
+
+ std::set<std::string> disable_list;
+ for (ExtensionList::iterator i = extensions_.begin();
+ i != extensions_.end(); ++i) {
+ const Extension* extension = i->get();
+ if (extension->is_theme() && extension->id() != new_theme_id)
+ disable_list.insert(extension->id());
+ }
+
+ for (std::set<std::string>::iterator i = disable_list.begin();
+ i != disable_list.end(); ++i) {
+ DisableExtension(*i);
+ }
+
+ break;
+ }
+
case NotificationType::EXTENSION_PROCESS_TERMINATED: {
if (profile_ != Source<Profile>(source).ptr()->GetOriginalProfile())
break;
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698