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

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 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 1114
1117 void ExtensionService::NotifyExtensionUnloaded( 1115 void ExtensionService::NotifyExtensionUnloaded(
1118 const Extension* extension, 1116 const Extension* extension,
1119 extension_misc::UnloadedExtensionReason reason) { 1117 extension_misc::UnloadedExtensionReason reason) {
1120 UnloadedExtensionInfo details(extension, reason); 1118 UnloadedExtensionInfo details(extension, reason);
1121 content::NotificationService::current()->Notify( 1119 content::NotificationService::current()->Notify(
1122 chrome::NOTIFICATION_EXTENSION_UNLOADED, 1120 chrome::NOTIFICATION_EXTENSION_UNLOADED,
1123 content::Source<Profile>(profile_), 1121 content::Source<Profile>(profile_),
1124 content::Details<UnloadedExtensionInfo>(&details)); 1122 content::Details<UnloadedExtensionInfo>(&details));
1125 1123
1126 #if defined(ENABLE_THEMES)
1127 // If the current theme is being unloaded, tell ThemeService to revert back
1128 // to the default theme.
1129 if (reason != extension_misc::UNLOAD_REASON_UPDATE && extension->is_theme()) {
1130 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_);
1131 if (extension->id() == theme_service->GetThemeID())
1132 theme_service->UseDefaultTheme();
1133 }
1134 #endif
1135
1136 for (content::RenderProcessHost::iterator i( 1124 for (content::RenderProcessHost::iterator i(
1137 content::RenderProcessHost::AllHostsIterator()); 1125 content::RenderProcessHost::AllHostsIterator());
1138 !i.IsAtEnd(); i.Advance()) { 1126 !i.IsAtEnd(); i.Advance()) {
1139 content::RenderProcessHost* host = i.GetCurrentValue(); 1127 content::RenderProcessHost* host = i.GetCurrentValue();
1140 Profile* host_profile = 1128 Profile* host_profile =
1141 Profile::FromBrowserContext(host->GetBrowserContext()); 1129 Profile::FromBrowserContext(host->GetBrowserContext());
1142 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) 1130 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile())
1143 host->Send(new ExtensionMsg_Unloaded(extension->id())); 1131 host->Send(new ExtensionMsg_Unloaded(extension->id()));
1144 } 1132 }
1145 1133
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 info->at(i)->extension_path)); 1935 info->at(i)->extension_path));
1948 1936
1949 if (!GetFileTaskRunner()->PostTask( 1937 if (!GetFileTaskRunner()->PostTask(
1950 FROM_HERE, 1938 FROM_HERE,
1951 base::Bind( 1939 base::Bind(
1952 &extension_file_util::GarbageCollectExtensions, 1940 &extension_file_util::GarbageCollectExtensions,
1953 install_directory_, 1941 install_directory_,
1954 extension_paths))) { 1942 extension_paths))) {
1955 NOTREACHED(); 1943 NOTREACHED();
1956 } 1944 }
1957
1958 #if defined(ENABLE_THEMES)
1959 // Also garbage-collect themes. We check |profile_| to be
1960 // defensive; in the future, we may call GarbageCollectExtensions()
1961 // from somewhere other than Init() (e.g., in a timer).
1962 if (profile_) {
1963 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes();
1964 }
1965 #endif
1966 } 1945 }
1967 1946
1968 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { 1947 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
1969 if (extensions::sync_helper::IsSyncableApp(&extension)) { 1948 if (extensions::sync_helper::IsSyncableApp(&extension)) {
1970 if (app_sync_bundle_.IsSyncing()) 1949 if (app_sync_bundle_.IsSyncing())
1971 app_sync_bundle_.SyncChangeIfNeeded(extension); 1950 app_sync_bundle_.SyncChangeIfNeeded(extension);
1972 else if (is_ready() && !flare_.is_null()) 1951 else if (is_ready() && !flare_.is_null())
1973 flare_.Run(syncer::APPS); 1952 flare_.Run(syncer::APPS);
1974 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { 1953 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) {
1975 if (extension_sync_bundle_.IsSyncing()) 1954 if (extension_sync_bundle_.IsSyncing())
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 2499
2521 // Unpacked extensions default to allowing file access, but if that has been 2500 // Unpacked extensions default to allowing file access, but if that has been
2522 // overridden, don't reset the value. 2501 // overridden, don't reset the value.
2523 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && 2502 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) &&
2524 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { 2503 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) {
2525 extension_prefs_->SetAllowFileAccess(extension->id(), true); 2504 extension_prefs_->SetAllowFileAccess(extension->id(), true);
2526 } 2505 }
2527 2506
2528 AddExtension(extension); 2507 AddExtension(extension);
2529 2508
2530 #if defined(ENABLE_THEMES)
2531 // We do this here since AddExtension() is always called on browser startup,
2532 // and we only really care about the last theme installed.
2533 // If that ever changes and we have to move this code somewhere
2534 // else, it should be somewhere that's not in the startup path.
2535 if (extension->is_theme() && extensions_.GetByID(extension->id())) {
2536 DCHECK_EQ(extensions_.GetByID(extension->id()), extension);
2537 // Now that the theme extension is visible from outside the
2538 // ExtensionService, notify the ThemeService about the
2539 // newly-installed theme.
2540 ThemeServiceFactory::GetForProfile(profile_)->SetTheme(extension);
2541 }
2542 #endif
2543
2544 // If this is a new external extension that was disabled, alert the user 2509 // If this is a new external extension that was disabled, alert the user
2545 // so he can reenable it. We do this last so that it has already been 2510 // so he can reenable it. We do this last so that it has already been
2546 // added to our list of extensions. 2511 // added to our list of extensions.
2547 if (unacknowledged_external) { 2512 if (unacknowledged_external) {
2548 UpdateExternalExtensionAlert(); 2513 UpdateExternalExtensionAlert();
2549 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", 2514 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent",
2550 EXTERNAL_EXTENSION_INSTALLED, 2515 EXTERNAL_EXTENSION_INSTALLED,
2551 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); 2516 EXTERNAL_EXTENSION_BUCKET_BOUNDARY);
2552 } 2517 }
2553 2518
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 } 3047 }
3083 3048
3084 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 3049 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
3085 update_observers_.AddObserver(observer); 3050 update_observers_.AddObserver(observer);
3086 } 3051 }
3087 3052
3088 void ExtensionService::RemoveUpdateObserver( 3053 void ExtensionService::RemoveUpdateObserver(
3089 extensions::UpdateObserver* observer) { 3054 extensions::UpdateObserver* observer) {
3090 update_observers_.RemoveObserver(observer); 3055 update_observers_.RemoveObserver(observer);
3091 } 3056 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698