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

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

Issue 11416324: Revert changes to have ExtensionService notify ThemeService directly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 #include "chrome/browser/extensions/unpacked_installer.h" 73 #include "chrome/browser/extensions/unpacked_installer.h"
74 #include "chrome/browser/extensions/updater/extension_updater.h" 74 #include "chrome/browser/extensions/updater/extension_updater.h"
75 #include "chrome/browser/extensions/window_event_router.h" 75 #include "chrome/browser/extensions/window_event_router.h"
76 #include "chrome/browser/history/history_extension_api.h" 76 #include "chrome/browser/history/history_extension_api.h"
77 #include "chrome/browser/net/chrome_url_request_context.h" 77 #include "chrome/browser/net/chrome_url_request_context.h"
78 #include "chrome/browser/prefs/pref_service.h" 78 #include "chrome/browser/prefs/pref_service.h"
79 #include "chrome/browser/profiles/profile.h" 79 #include "chrome/browser/profiles/profile.h"
80 #include "chrome/browser/profiles/profile_manager.h" 80 #include "chrome/browser/profiles/profile_manager.h"
81 #include "chrome/browser/search_engines/template_url_service.h" 81 #include "chrome/browser/search_engines/template_url_service.h"
82 #include "chrome/browser/search_engines/template_url_service_factory.h" 82 #include "chrome/browser/search_engines/template_url_service_factory.h"
83 #include "chrome/browser/themes/theme_service.h"
84 #include "chrome/browser/themes/theme_service_factory.h"
83 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 85 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
84 #include "chrome/browser/ui/webui/favicon_source.h" 86 #include "chrome/browser/ui/webui/favicon_source.h"
85 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 87 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
86 #include "chrome/browser/ui/webui/theme_source.h" 88 #include "chrome/browser/ui/webui/theme_source.h"
87 #include "chrome/common/child_process_logging.h" 89 #include "chrome/common/child_process_logging.h"
88 #include "chrome/common/chrome_notification_types.h" 90 #include "chrome/common/chrome_notification_types.h"
89 #include "chrome/common/chrome_paths.h" 91 #include "chrome/common/chrome_paths.h"
90 #include "chrome/common/chrome_switches.h" 92 #include "chrome/common/chrome_switches.h"
91 #include "chrome/common/chrome_version_info.h" 93 #include "chrome/common/chrome_version_info.h"
92 #include "chrome/common/extensions/extension.h" 94 #include "chrome/common/extensions/extension.h"
(...skipping 16 matching lines...) Expand all
109 #include "content/public/common/pepper_plugin_info.h" 111 #include "content/public/common/pepper_plugin_info.h"
110 #include "extensions/common/error_utils.h" 112 #include "extensions/common/error_utils.h"
111 #include "googleurl/src/gurl.h" 113 #include "googleurl/src/gurl.h"
112 #include "grit/generated_resources.h" 114 #include "grit/generated_resources.h"
113 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 115 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
114 #include "sync/api/sync_change.h" 116 #include "sync/api/sync_change.h"
115 #include "sync/api/sync_error_factory.h" 117 #include "sync/api/sync_error_factory.h"
116 #include "webkit/database/database_tracker.h" 118 #include "webkit/database/database_tracker.h"
117 #include "webkit/database/database_util.h" 119 #include "webkit/database/database_util.h"
118 120
119 #if defined(ENABLE_THEMES)
120 #include "chrome/browser/themes/theme_service.h"
121 #include "chrome/browser/themes/theme_service_factory.h"
122 #endif
123
124 #if defined(OS_CHROMEOS) 121 #if defined(OS_CHROMEOS)
125 #include "chrome/browser/chromeos/cros/cros_library.h" 122 #include "chrome/browser/chromeos/cros/cros_library.h"
126 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" 123 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h"
127 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" 124 #include "chrome/browser/chromeos/extensions/input_method_event_router.h"
128 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" 125 #include "chrome/browser/chromeos/extensions/media_player_event_router.h"
129 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 126 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
130 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" 127 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
131 #include "content/public/browser/storage_partition.h" 128 #include "content/public/browser/storage_partition.h"
132 #include "webkit/fileapi/file_system_context.h" 129 #include "webkit/fileapi/file_system_context.h"
133 #include "webkit/fileapi/file_system_mount_point_provider.h" 130 #include "webkit/fileapi/file_system_mount_point_provider.h"
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 1024
1028 void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { 1025 void ExtensionService::NotifyExtensionLoaded(const Extension* extension) {
1029 // The ChromeURLRequestContexts need to be first to know that the extension 1026 // The ChromeURLRequestContexts need to be first to know that the extension
1030 // was loaded, otherwise a race can arise where a renderer that is created 1027 // was loaded, otherwise a race can arise where a renderer that is created
1031 // for the extension may try to load an extension URL with an extension id 1028 // for the extension may try to load an extension URL with an extension id
1032 // that the request context doesn't yet know about. The profile is responsible 1029 // that the request context doesn't yet know about. The profile is responsible
1033 // for ensuring its URLRequestContexts appropriately discover the loaded 1030 // for ensuring its URLRequestContexts appropriately discover the loaded
1034 // extension. 1031 // extension.
1035 system_->RegisterExtensionWithRequestContexts(extension); 1032 system_->RegisterExtensionWithRequestContexts(extension);
1036 1033
1034 // Tell renderers about the new extension, unless it's a theme (renderers
1035 // don't need to know about themes).
1037 if (!extension->is_theme()) { 1036 if (!extension->is_theme()) {
1038 // Tell renderers about non-theme extensions (renderers don't need
1039 // to know about themes).
1040 for (content::RenderProcessHost::iterator i( 1037 for (content::RenderProcessHost::iterator i(
1041 content::RenderProcessHost::AllHostsIterator()); 1038 content::RenderProcessHost::AllHostsIterator());
1042 !i.IsAtEnd(); i.Advance()) { 1039 !i.IsAtEnd(); i.Advance()) {
1043 content::RenderProcessHost* host = i.GetCurrentValue(); 1040 content::RenderProcessHost* host = i.GetCurrentValue();
1044 Profile* host_profile = 1041 Profile* host_profile =
1045 Profile::FromBrowserContext(host->GetBrowserContext()); 1042 Profile::FromBrowserContext(host->GetBrowserContext());
1046 if (host_profile->GetOriginalProfile() == 1043 if (host_profile->GetOriginalProfile() ==
1047 profile_->GetOriginalProfile()) { 1044 profile_->GetOriginalProfile()) {
1048 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions( 1045 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions(
1049 1, ExtensionMsg_Loaded_Params(extension)); 1046 1, ExtensionMsg_Loaded_Params(extension));
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 install_directory_, 2019 install_directory_,
2023 extension_paths))) { 2020 extension_paths))) {
2024 NOTREACHED(); 2021 NOTREACHED();
2025 } 2022 }
2026 2023
2027 #if defined(ENABLE_THEMES) 2024 #if defined(ENABLE_THEMES)
2028 // Also garbage-collect themes. We check |profile_| to be 2025 // Also garbage-collect themes. We check |profile_| to be
2029 // defensive; in the future, we may call GarbageCollectExtensions() 2026 // defensive; in the future, we may call GarbageCollectExtensions()
2030 // from somewhere other than Init() (e.g., in a timer). 2027 // from somewhere other than Init() (e.g., in a timer).
2031 if (profile_) { 2028 if (profile_) {
2032 ThemeService::RemoveUnusedThemesForProfile(profile_); 2029 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes();
2033 } 2030 }
2034 #endif 2031 #endif
2035 } 2032 }
2036 2033
2037 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { 2034 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
2038 if (app_sync_bundle_.HandlesApp(extension)) { 2035 if (app_sync_bundle_.HandlesApp(extension)) {
2039 app_sync_bundle_.SyncChangeIfNeeded(extension); 2036 app_sync_bundle_.SyncChangeIfNeeded(extension);
2040 } else if (extension_sync_bundle_.HandlesExtension(extension)) { 2037 } else if (extension_sync_bundle_.HandlesExtension(extension)) {
2041 extension_sync_bundle_.SyncChangeIfNeeded(extension); 2038 extension_sync_bundle_.SyncChangeIfNeeded(extension);
2042 } 2039 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 // so we must ensure they have valid ordinals. 2100 // so we must ensure they have valid ordinals.
2104 if (extension->RequiresSortOrdinal()) { 2101 if (extension->RequiresSortOrdinal()) {
2105 extension_prefs_->extension_sorting()->EnsureValidOrdinals( 2102 extension_prefs_->extension_sorting()->EnsureValidOrdinals(
2106 extension->id(), syncer::StringOrdinal()); 2103 extension->id(), syncer::StringOrdinal());
2107 } 2104 }
2108 2105
2109 extensions_.Insert(extension); 2106 extensions_.Insert(extension);
2110 SyncExtensionChangeIfNeeded(*extension); 2107 SyncExtensionChangeIfNeeded(*extension);
2111 NotifyExtensionLoaded(extension); 2108 NotifyExtensionLoaded(extension);
2112 DoPostLoadTasks(extension); 2109 DoPostLoadTasks(extension);
2113
2114 #if defined(ENABLE_THEMES)
2115 if (extension->is_theme()) {
2116 // Notify the ThemeService about the newly-installed theme.
2117 ThemeServiceFactory::SetThemeForProfile(profile_, extension);
2118 }
2119 #endif
2120 } 2110 }
2121 2111
2122 void ExtensionService::AddComponentExtension(const Extension* extension) { 2112 void ExtensionService::AddComponentExtension(const Extension* extension) {
2123 const std::string old_version_string( 2113 const std::string old_version_string(
2124 extension_prefs_->GetVersionString(extension->id())); 2114 extension_prefs_->GetVersionString(extension->id()));
2125 const Version old_version(old_version_string); 2115 const Version old_version(old_version_string);
2126 2116
2127 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { 2117 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) {
2128 VLOG(1) << "Component extension " << extension->name() << " (" 2118 VLOG(1) << "Component extension " << extension->name() << " ("
2129 << extension->id() << ") installing/upgrading from '" 2119 << extension->id() << ") installing/upgrading from '"
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
3032 extension_id, kOnUpdateAvailableEvent); 3022 extension_id, kOnUpdateAvailableEvent);
3033 } else { 3023 } else {
3034 // Delay installation if the extension is not idle. 3024 // Delay installation if the extension is not idle.
3035 return !IsExtensionIdle(extension_id); 3025 return !IsExtensionIdle(extension_id);
3036 } 3026 }
3037 } 3027 }
3038 3028
3039 void ExtensionService::OnBlacklistUpdated() { 3029 void ExtensionService::OnBlacklistUpdated() {
3040 CheckManagementPolicy(); 3030 CheckManagementPolicy();
3041 } 3031 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_ui_default.cc ('k') | chrome/browser/themes/theme_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698