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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 22755003: Reland: Chrome side work for allowing a user to revert to their previous theme without closing ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/extensions/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "chrome/browser/extensions/installed_loader.h" 57 #include "chrome/browser/extensions/installed_loader.h"
58 #include "chrome/browser/extensions/lazy_background_task_queue.h" 58 #include "chrome/browser/extensions/lazy_background_task_queue.h"
59 #include "chrome/browser/extensions/management_policy.h" 59 #include "chrome/browser/extensions/management_policy.h"
60 #include "chrome/browser/extensions/pending_extension_manager.h" 60 #include "chrome/browser/extensions/pending_extension_manager.h"
61 #include "chrome/browser/extensions/permissions_updater.h" 61 #include "chrome/browser/extensions/permissions_updater.h"
62 #include "chrome/browser/extensions/unpacked_installer.h" 62 #include "chrome/browser/extensions/unpacked_installer.h"
63 #include "chrome/browser/extensions/update_observer.h" 63 #include "chrome/browser/extensions/update_observer.h"
64 #include "chrome/browser/extensions/updater/extension_updater.h" 64 #include "chrome/browser/extensions/updater/extension_updater.h"
65 #include "chrome/browser/profiles/profile.h" 65 #include "chrome/browser/profiles/profile.h"
66 #include "chrome/browser/profiles/profile_manager.h" 66 #include "chrome/browser/profiles/profile_manager.h"
67 #include "chrome/browser/themes/theme_service.h"
68 #include "chrome/browser/themes/theme_service_factory.h"
69 #include "chrome/browser/ui/webui/favicon_source.h" 67 #include "chrome/browser/ui/webui/favicon_source.h"
70 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 68 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
71 #include "chrome/browser/ui/webui/theme_source.h" 69 #include "chrome/browser/ui/webui/theme_source.h"
72 #include "chrome/common/child_process_logging.h" 70 #include "chrome/common/child_process_logging.h"
73 #include "chrome/common/chrome_switches.h" 71 #include "chrome/common/chrome_switches.h"
74 #include "chrome/common/chrome_version_info.h" 72 #include "chrome/common/chrome_version_info.h"
75 #include "chrome/common/extensions/background_info.h" 73 #include "chrome/common/extensions/background_info.h"
76 #include "chrome/common/extensions/extension.h" 74 #include "chrome/common/extensions/extension.h"
77 #include "chrome/common/extensions/extension_constants.h" 75 #include "chrome/common/extensions/extension_constants.h"
78 #include "chrome/common/extensions/extension_file_util.h" 76 #include "chrome/common/extensions/extension_file_util.h"
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 1135
1138 void ExtensionService::NotifyExtensionUnloaded( 1136 void ExtensionService::NotifyExtensionUnloaded(
1139 const Extension* extension, 1137 const Extension* extension,
1140 extension_misc::UnloadedExtensionReason reason) { 1138 extension_misc::UnloadedExtensionReason reason) {
1141 UnloadedExtensionInfo details(extension, reason); 1139 UnloadedExtensionInfo details(extension, reason);
1142 content::NotificationService::current()->Notify( 1140 content::NotificationService::current()->Notify(
1143 chrome::NOTIFICATION_EXTENSION_UNLOADED, 1141 chrome::NOTIFICATION_EXTENSION_UNLOADED,
1144 content::Source<Profile>(profile_), 1142 content::Source<Profile>(profile_),
1145 content::Details<UnloadedExtensionInfo>(&details)); 1143 content::Details<UnloadedExtensionInfo>(&details));
1146 1144
1147 #if defined(ENABLE_THEMES)
1148 // If the current theme is being unloaded, tell ThemeService to revert back
1149 // to the default theme.
1150 if (reason != extension_misc::UNLOAD_REASON_UPDATE && extension->is_theme()) {
1151 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_);
1152 if (extension->id() == theme_service->GetThemeID())
1153 theme_service->UseDefaultTheme();
1154 }
1155 #endif
1156
1157 for (content::RenderProcessHost::iterator i( 1145 for (content::RenderProcessHost::iterator i(
1158 content::RenderProcessHost::AllHostsIterator()); 1146 content::RenderProcessHost::AllHostsIterator());
1159 !i.IsAtEnd(); i.Advance()) { 1147 !i.IsAtEnd(); i.Advance()) {
1160 content::RenderProcessHost* host = i.GetCurrentValue(); 1148 content::RenderProcessHost* host = i.GetCurrentValue();
1161 Profile* host_profile = 1149 Profile* host_profile =
1162 Profile::FromBrowserContext(host->GetBrowserContext()); 1150 Profile::FromBrowserContext(host->GetBrowserContext());
1163 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) 1151 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile())
1164 host->Send(new ExtensionMsg_Unloaded(extension->id())); 1152 host->Send(new ExtensionMsg_Unloaded(extension->id()));
1165 } 1153 }
1166 1154
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 info->at(i)->extension_path)); 1964 info->at(i)->extension_path));
1977 1965
1978 if (!GetFileTaskRunner()->PostTask( 1966 if (!GetFileTaskRunner()->PostTask(
1979 FROM_HERE, 1967 FROM_HERE,
1980 base::Bind( 1968 base::Bind(
1981 &extension_file_util::GarbageCollectExtensions, 1969 &extension_file_util::GarbageCollectExtensions,
1982 install_directory_, 1970 install_directory_,
1983 extension_paths))) { 1971 extension_paths))) {
1984 NOTREACHED(); 1972 NOTREACHED();
1985 } 1973 }
1986
1987 #if defined(ENABLE_THEMES)
1988 // Also garbage-collect themes. We check |profile_| to be
1989 // defensive; in the future, we may call GarbageCollectExtensions()
1990 // from somewhere other than Init() (e.g., in a timer).
1991 if (profile_) {
1992 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes();
1993 }
1994 #endif
1995 } 1974 }
1996 1975
1997 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { 1976 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
1998 if (extensions::sync_helper::IsSyncableApp(&extension)) { 1977 if (extensions::sync_helper::IsSyncableApp(&extension)) {
1999 if (app_sync_bundle_.IsSyncing()) 1978 if (app_sync_bundle_.IsSyncing())
2000 app_sync_bundle_.SyncChangeIfNeeded(extension); 1979 app_sync_bundle_.SyncChangeIfNeeded(extension);
2001 else if (is_ready() && !flare_.is_null()) 1980 else if (is_ready() && !flare_.is_null())
2002 flare_.Run(syncer::APPS); 1981 flare_.Run(syncer::APPS);
2003 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { 1982 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) {
2004 if (extension_sync_bundle_.IsSyncing()) 1983 if (extension_sync_bundle_.IsSyncing())
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 2554
2576 // Unpacked extensions default to allowing file access, but if that has been 2555 // Unpacked extensions default to allowing file access, but if that has been
2577 // overridden, don't reset the value. 2556 // overridden, don't reset the value.
2578 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && 2557 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) &&
2579 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { 2558 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) {
2580 extension_prefs_->SetAllowFileAccess(extension->id(), true); 2559 extension_prefs_->SetAllowFileAccess(extension->id(), true);
2581 } 2560 }
2582 2561
2583 AddExtension(extension); 2562 AddExtension(extension);
2584 2563
2585 #if defined(ENABLE_THEMES)
2586 // We do this here since AddExtension() is always called on browser startup,
2587 // and we only really care about the last theme installed.
2588 // If that ever changes and we have to move this code somewhere
2589 // else, it should be somewhere that's not in the startup path.
2590 if (extension->is_theme() && extensions_.GetByID(extension->id())) {
2591 DCHECK_EQ(extensions_.GetByID(extension->id()), extension);
2592 // Now that the theme extension is visible from outside the
2593 // ExtensionService, notify the ThemeService about the
2594 // newly-installed theme.
2595 ThemeServiceFactory::GetForProfile(profile_)->SetTheme(extension);
2596 }
2597 #endif
2598
2599 // If this is a new external extension that was disabled, alert the user 2564 // If this is a new external extension that was disabled, alert the user
2600 // so he can reenable it. We do this last so that it has already been 2565 // so he can reenable it. We do this last so that it has already been
2601 // added to our list of extensions. 2566 // added to our list of extensions.
2602 if (unacknowledged_external) { 2567 if (unacknowledged_external) {
2603 UpdateExternalExtensionAlert(); 2568 UpdateExternalExtensionAlert();
2604 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", 2569 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent",
2605 EXTERNAL_EXTENSION_INSTALLED, 2570 EXTERNAL_EXTENSION_INSTALLED,
2606 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); 2571 EXTERNAL_EXTENSION_BUCKET_BOUNDARY);
2607 if (extensions::ManifestURL::UpdatesFromGallery(extension)) { 2572 if (extensions::ManifestURL::UpdatesFromGallery(extension)) {
2608 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEventWebstore", 2573 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEventWebstore",
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
3155 } 3120 }
3156 3121
3157 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 3122 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
3158 update_observers_.AddObserver(observer); 3123 update_observers_.AddObserver(observer);
3159 } 3124 }
3160 3125
3161 void ExtensionService::RemoveUpdateObserver( 3126 void ExtensionService::RemoveUpdateObserver(
3162 extensions::UpdateObserver* observer) { 3127 extensions::UpdateObserver* observer) {
3163 update_observers_.RemoveObserver(observer); 3128 update_observers_.RemoveObserver(observer);
3164 } 3129 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_ui_browsertest.cc ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698