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

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: 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 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 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 info->at(i)->extension_path)); 1932 info->at(i)->extension_path));
1945 1933
1946 if (!GetFileTaskRunner()->PostTask( 1934 if (!GetFileTaskRunner()->PostTask(
1947 FROM_HERE, 1935 FROM_HERE,
1948 base::Bind( 1936 base::Bind(
1949 &extension_file_util::GarbageCollectExtensions, 1937 &extension_file_util::GarbageCollectExtensions,
1950 install_directory_, 1938 install_directory_,
1951 extension_paths))) { 1939 extension_paths))) {
1952 NOTREACHED(); 1940 NOTREACHED();
1953 } 1941 }
1954
1955 #if defined(ENABLE_THEMES)
1956 // Also garbage-collect themes. We check |profile_| to be
1957 // defensive; in the future, we may call GarbageCollectExtensions()
1958 // from somewhere other than Init() (e.g., in a timer).
1959 if (profile_) {
1960 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes();
1961 }
1962 #endif
1963 } 1942 }
1964 1943
1965 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { 1944 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
1966 if (extensions::sync_helper::IsSyncableApp(&extension)) { 1945 if (extensions::sync_helper::IsSyncableApp(&extension)) {
1967 if (app_sync_bundle_.IsSyncing()) 1946 if (app_sync_bundle_.IsSyncing())
1968 app_sync_bundle_.SyncChangeIfNeeded(extension); 1947 app_sync_bundle_.SyncChangeIfNeeded(extension);
1969 else if (is_ready() && !flare_.is_null()) 1948 else if (is_ready() && !flare_.is_null())
1970 flare_.Run(syncer::APPS); 1949 flare_.Run(syncer::APPS);
1971 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { 1950 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) {
1972 if (extension_sync_bundle_.IsSyncing()) 1951 if (extension_sync_bundle_.IsSyncing())
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 2523
2545 // Unpacked extensions default to allowing file access, but if that has been 2524 // Unpacked extensions default to allowing file access, but if that has been
2546 // overridden, don't reset the value. 2525 // overridden, don't reset the value.
2547 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && 2526 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) &&
2548 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { 2527 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) {
2549 extension_prefs_->SetAllowFileAccess(extension->id(), true); 2528 extension_prefs_->SetAllowFileAccess(extension->id(), true);
2550 } 2529 }
2551 2530
2552 AddExtension(extension); 2531 AddExtension(extension);
2553 2532
2554 #if defined(ENABLE_THEMES)
2555 // We do this here since AddExtension() is always called on browser startup,
2556 // and we only really care about the last theme installed.
2557 // If that ever changes and we have to move this code somewhere
2558 // else, it should be somewhere that's not in the startup path.
2559 if (extension->is_theme() && extensions_.GetByID(extension->id())) {
2560 DCHECK_EQ(extensions_.GetByID(extension->id()), extension);
2561 // Now that the theme extension is visible from outside the
2562 // ExtensionService, notify the ThemeService about the
2563 // newly-installed theme.
2564 ThemeServiceFactory::GetForProfile(profile_)->SetTheme(extension);
2565 }
2566 #endif
2567
2568 // If this is a new external extension that was disabled, alert the user 2533 // If this is a new external extension that was disabled, alert the user
2569 // so he can reenable it. We do this last so that it has already been 2534 // so he can reenable it. We do this last so that it has already been
2570 // added to our list of extensions. 2535 // added to our list of extensions.
2571 if (unacknowledged_external) { 2536 if (unacknowledged_external) {
2572 UpdateExternalExtensionAlert(); 2537 UpdateExternalExtensionAlert();
2573 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", 2538 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent",
2574 EXTERNAL_EXTENSION_INSTALLED, 2539 EXTERNAL_EXTENSION_INSTALLED,
2575 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); 2540 EXTERNAL_EXTENSION_BUCKET_BOUNDARY);
2576 } 2541 }
2577 2542
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
3115 } 3080 }
3116 3081
3117 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 3082 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
3118 update_observers_.AddObserver(observer); 3083 update_observers_.AddObserver(observer);
3119 } 3084 }
3120 3085
3121 void ExtensionService::RemoveUpdateObserver( 3086 void ExtensionService::RemoveUpdateObserver(
3122 extensions::UpdateObserver* observer) { 3087 extensions::UpdateObserver* observer) {
3123 update_observers_.RemoveObserver(observer); 3088 update_observers_.RemoveObserver(observer);
3124 } 3089 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698