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

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

Issue 19462009: [DRAFT] Allow a user to revert to their previous theme without closing infobar (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) 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/platform_app_launcher.h" 62 #include "chrome/browser/extensions/platform_app_launcher.h"
63 #include "chrome/browser/extensions/shell_window_registry.h" 63 #include "chrome/browser/extensions/shell_window_registry.h"
64 #include "chrome/browser/extensions/unpacked_installer.h" 64 #include "chrome/browser/extensions/unpacked_installer.h"
65 #include "chrome/browser/extensions/update_observer.h" 65 #include "chrome/browser/extensions/update_observer.h"
66 #include "chrome/browser/extensions/updater/extension_updater.h" 66 #include "chrome/browser/extensions/updater/extension_updater.h"
67 #include "chrome/browser/profiles/profile.h" 67 #include "chrome/browser/profiles/profile.h"
68 #include "chrome/browser/profiles/profile_manager.h" 68 #include "chrome/browser/profiles/profile_manager.h"
69 #include "chrome/browser/themes/theme_service.h"
70 #include "chrome/browser/themes/theme_service_factory.h"
71 #include "chrome/browser/ui/webui/favicon_source.h" 69 #include "chrome/browser/ui/webui/favicon_source.h"
72 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 70 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
73 #include "chrome/browser/ui/webui/theme_source.h" 71 #include "chrome/browser/ui/webui/theme_source.h"
74 #include "chrome/common/child_process_logging.h" 72 #include "chrome/common/child_process_logging.h"
75 #include "chrome/common/chrome_switches.h" 73 #include "chrome/common/chrome_switches.h"
76 #include "chrome/common/chrome_version_info.h" 74 #include "chrome/common/chrome_version_info.h"
77 #include "chrome/common/extensions/background_info.h" 75 #include "chrome/common/extensions/background_info.h"
78 #include "chrome/common/extensions/extension.h" 76 #include "chrome/common/extensions/extension.h"
79 #include "chrome/common/extensions/extension_constants.h" 77 #include "chrome/common/extensions/extension_constants.h"
80 #include "chrome/common/extensions/extension_file_util.h" 78 #include "chrome/common/extensions/extension_file_util.h"
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 1110
1113 void ExtensionService::NotifyExtensionUnloaded( 1111 void ExtensionService::NotifyExtensionUnloaded(
1114 const Extension* extension, 1112 const Extension* extension,
1115 extension_misc::UnloadedExtensionReason reason) { 1113 extension_misc::UnloadedExtensionReason reason) {
1116 UnloadedExtensionInfo details(extension, reason); 1114 UnloadedExtensionInfo details(extension, reason);
1117 content::NotificationService::current()->Notify( 1115 content::NotificationService::current()->Notify(
1118 chrome::NOTIFICATION_EXTENSION_UNLOADED, 1116 chrome::NOTIFICATION_EXTENSION_UNLOADED,
1119 content::Source<Profile>(profile_), 1117 content::Source<Profile>(profile_),
1120 content::Details<UnloadedExtensionInfo>(&details)); 1118 content::Details<UnloadedExtensionInfo>(&details));
1121 1119
1122 #if defined(ENABLE_THEMES)
1123 // If the current theme is being unloaded, tell ThemeService to revert back
1124 // to the default theme.
1125 if (reason != extension_misc::UNLOAD_REASON_UPDATE && extension->is_theme()) {
1126 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_);
1127 if (extension->id() == theme_service->GetThemeID())
1128 theme_service->UseDefaultTheme();
1129 }
1130 #endif
1131
1132 for (content::RenderProcessHost::iterator i( 1120 for (content::RenderProcessHost::iterator i(
1133 content::RenderProcessHost::AllHostsIterator()); 1121 content::RenderProcessHost::AllHostsIterator());
1134 !i.IsAtEnd(); i.Advance()) { 1122 !i.IsAtEnd(); i.Advance()) {
1135 content::RenderProcessHost* host = i.GetCurrentValue(); 1123 content::RenderProcessHost* host = i.GetCurrentValue();
1136 Profile* host_profile = 1124 Profile* host_profile =
1137 Profile::FromBrowserContext(host->GetBrowserContext()); 1125 Profile::FromBrowserContext(host->GetBrowserContext());
1138 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) 1126 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile())
1139 host->Send(new ExtensionMsg_Unloaded(extension->id())); 1127 host->Send(new ExtensionMsg_Unloaded(extension->id()));
1140 } 1128 }
1141 1129
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 info->at(i)->extension_path)); 1925 info->at(i)->extension_path));
1938 1926
1939 if (!GetFileTaskRunner()->PostTask( 1927 if (!GetFileTaskRunner()->PostTask(
1940 FROM_HERE, 1928 FROM_HERE,
1941 base::Bind( 1929 base::Bind(
1942 &extension_file_util::GarbageCollectExtensions, 1930 &extension_file_util::GarbageCollectExtensions,
1943 install_directory_, 1931 install_directory_,
1944 extension_paths))) { 1932 extension_paths))) {
1945 NOTREACHED(); 1933 NOTREACHED();
1946 } 1934 }
1947
1948 #if defined(ENABLE_THEMES)
1949 // Also garbage-collect themes. We check |profile_| to be
1950 // defensive; in the future, we may call GarbageCollectExtensions()
1951 // from somewhere other than Init() (e.g., in a timer).
1952 if (profile_) {
1953 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes();
1954 }
1955 #endif
1956 } 1935 }
1957 1936
1958 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { 1937 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
1959 if (extensions::sync_helper::IsSyncableApp(&extension)) { 1938 if (extensions::sync_helper::IsSyncableApp(&extension)) {
1960 if (app_sync_bundle_.IsSyncing()) 1939 if (app_sync_bundle_.IsSyncing())
1961 app_sync_bundle_.SyncChangeIfNeeded(extension); 1940 app_sync_bundle_.SyncChangeIfNeeded(extension);
1962 else if (is_ready() && !flare_.is_null()) 1941 else if (is_ready() && !flare_.is_null())
1963 flare_.Run(syncer::APPS); 1942 flare_.Run(syncer::APPS);
1964 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { 1943 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) {
1965 if (extension_sync_bundle_.IsSyncing()) 1944 if (extension_sync_bundle_.IsSyncing())
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 2487
2509 // Unpacked extensions default to allowing file access, but if that has been 2488 // Unpacked extensions default to allowing file access, but if that has been
2510 // overridden, don't reset the value. 2489 // overridden, don't reset the value.
2511 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && 2490 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) &&
2512 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { 2491 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) {
2513 extension_prefs_->SetAllowFileAccess(extension->id(), true); 2492 extension_prefs_->SetAllowFileAccess(extension->id(), true);
2514 } 2493 }
2515 2494
2516 AddExtension(extension); 2495 AddExtension(extension);
2517 2496
2518 #if defined(ENABLE_THEMES)
2519 // We do this here since AddExtension() is always called on browser startup,
2520 // and we only really care about the last theme installed.
2521 // If that ever changes and we have to move this code somewhere
2522 // else, it should be somewhere that's not in the startup path.
2523 if (extension->is_theme() && extensions_.GetByID(extension->id())) {
2524 DCHECK_EQ(extensions_.GetByID(extension->id()), extension);
2525 // Now that the theme extension is visible from outside the
2526 // ExtensionService, notify the ThemeService about the
2527 // newly-installed theme.
2528 ThemeServiceFactory::GetForProfile(profile_)->SetTheme(extension);
2529 }
2530 #endif
2531
2532 // If this is a new external extension that was disabled, alert the user 2497 // If this is a new external extension that was disabled, alert the user
2533 // so he can reenable it. We do this last so that it has already been 2498 // so he can reenable it. We do this last so that it has already been
2534 // added to our list of extensions. 2499 // added to our list of extensions.
2535 if (unacknowledged_external) { 2500 if (unacknowledged_external) {
2536 UpdateExternalExtensionAlert(); 2501 UpdateExternalExtensionAlert();
2537 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", 2502 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent",
2538 EXTERNAL_EXTENSION_INSTALLED, 2503 EXTERNAL_EXTENSION_INSTALLED,
2539 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); 2504 EXTERNAL_EXTENSION_BUCKET_BOUNDARY);
2540 } 2505 }
2541 2506
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
3070 } 3035 }
3071 3036
3072 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 3037 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
3073 update_observers_.AddObserver(observer); 3038 update_observers_.AddObserver(observer);
3074 } 3039 }
3075 3040
3076 void ExtensionService::RemoveUpdateObserver( 3041 void ExtensionService::RemoveUpdateObserver(
3077 extensions::UpdateObserver* observer) { 3042 extensions::UpdateObserver* observer) {
3078 update_observers_.RemoveObserver(observer); 3043 update_observers_.RemoveObserver(observer);
3079 } 3044 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698