Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 | 1027 |
| 1028 void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { | 1028 void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { |
| 1029 // The ChromeURLRequestContexts need to be first to know that the extension | 1029 // 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 | 1030 // 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 | 1031 // 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 | 1032 // that the request context doesn't yet know about. The profile is responsible |
| 1033 // for ensuring its URLRequestContexts appropriately discover the loaded | 1033 // for ensuring its URLRequestContexts appropriately discover the loaded |
| 1034 // extension. | 1034 // extension. |
| 1035 system_->RegisterExtensionWithRequestContexts(extension); | 1035 system_->RegisterExtensionWithRequestContexts(extension); |
| 1036 | 1036 |
| 1037 if (extension->is_theme()) { | 1037 if (!extension->is_theme()) { |
| 1038 #if defined(ENABLE_THEMES) | |
| 1039 ThemeServiceFactory::SetThemeForProfile(profile_, extension); | |
| 1040 #endif | |
| 1041 } else { | |
| 1042 // Tell renderers about non-theme extensions (renderers don't need | 1038 // Tell renderers about non-theme extensions (renderers don't need |
| 1043 // to know about themes). | 1039 // to know about themes). |
| 1044 for (content::RenderProcessHost::iterator i( | 1040 for (content::RenderProcessHost::iterator i( |
| 1045 content::RenderProcessHost::AllHostsIterator()); | 1041 content::RenderProcessHost::AllHostsIterator()); |
| 1046 !i.IsAtEnd(); i.Advance()) { | 1042 !i.IsAtEnd(); i.Advance()) { |
| 1047 content::RenderProcessHost* host = i.GetCurrentValue(); | 1043 content::RenderProcessHost* host = i.GetCurrentValue(); |
| 1048 Profile* host_profile = | 1044 Profile* host_profile = |
| 1049 Profile::FromBrowserContext(host->GetBrowserContext()); | 1045 Profile::FromBrowserContext(host->GetBrowserContext()); |
| 1050 if (host_profile->GetOriginalProfile() == | 1046 if (host_profile->GetOriginalProfile() == |
| 1051 profile_->GetOriginalProfile()) { | 1047 profile_->GetOriginalProfile()) { |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2107 // so we must ensure they have valid ordinals. | 2103 // so we must ensure they have valid ordinals. |
| 2108 if (extension->RequiresSortOrdinal()) { | 2104 if (extension->RequiresSortOrdinal()) { |
| 2109 extension_prefs_->extension_sorting()->EnsureValidOrdinals( | 2105 extension_prefs_->extension_sorting()->EnsureValidOrdinals( |
| 2110 extension->id(), syncer::StringOrdinal()); | 2106 extension->id(), syncer::StringOrdinal()); |
| 2111 } | 2107 } |
| 2112 | 2108 |
| 2113 extensions_.Insert(extension); | 2109 extensions_.Insert(extension); |
| 2114 SyncExtensionChangeIfNeeded(*extension); | 2110 SyncExtensionChangeIfNeeded(*extension); |
| 2115 NotifyExtensionLoaded(extension); | 2111 NotifyExtensionLoaded(extension); |
| 2116 DoPostLoadTasks(extension); | 2112 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 | |
|
asargent_no_longer_on_chrome
2012/12/01 00:54:56
Perhaps this should go inside DoPostLoadTasks ?
akalin
2012/12/01 01:07:00
Per our chat, looks like I shouldn't do this!
| |
| 2117 } | 2120 } |
| 2118 | 2121 |
| 2119 void ExtensionService::AddComponentExtension(const Extension* extension) { | 2122 void ExtensionService::AddComponentExtension(const Extension* extension) { |
| 2120 const std::string old_version_string( | 2123 const std::string old_version_string( |
| 2121 extension_prefs_->GetVersionString(extension->id())); | 2124 extension_prefs_->GetVersionString(extension->id())); |
| 2122 const Version old_version(old_version_string); | 2125 const Version old_version(old_version_string); |
| 2123 | 2126 |
| 2124 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { | 2127 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { |
| 2125 VLOG(1) << "Component extension " << extension->name() << " (" | 2128 VLOG(1) << "Component extension " << extension->name() << " (" |
| 2126 << extension->id() << ") installing/upgrading from '" | 2129 << extension->id() << ") installing/upgrading from '" |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3029 extension_id, kOnUpdateAvailableEvent); | 3032 extension_id, kOnUpdateAvailableEvent); |
| 3030 } else { | 3033 } else { |
| 3031 // Delay installation if the extension is not idle. | 3034 // Delay installation if the extension is not idle. |
| 3032 return !IsExtensionIdle(extension_id); | 3035 return !IsExtensionIdle(extension_id); |
| 3033 } | 3036 } |
| 3034 } | 3037 } |
| 3035 | 3038 |
| 3036 void ExtensionService::OnBlacklistUpdated() { | 3039 void ExtensionService::OnBlacklistUpdated() { |
| 3037 CheckManagementPolicy(); | 3040 CheckManagementPolicy(); |
| 3038 } | 3041 } |
| OLD | NEW |