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 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2093 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) | 2093 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) |
2094 extension_ids.insert(extension->id()); | 2094 extension_ids.insert(extension->id()); |
2095 } | 2095 } |
2096 | 2096 |
2097 child_process_logging::SetActiveExtensions(extension_ids); | 2097 child_process_logging::SetActiveExtensions(extension_ids); |
2098 } | 2098 } |
2099 | 2099 |
2100 void ExtensionService::OnExtensionInstalled( | 2100 void ExtensionService::OnExtensionInstalled( |
2101 const Extension* extension, | 2101 const Extension* extension, |
2102 bool from_webstore, | 2102 bool from_webstore, |
2103 const StringOrdinal& page_ordinal) { | 2103 const StringOrdinal& page_ordinal, |
| 2104 const std::vector<std::string>& requirement_errors) { |
2104 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2105 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2105 | 2106 |
2106 // Ensure extension is deleted unless we transfer ownership. | 2107 // Ensure extension is deleted unless we transfer ownership. |
2107 scoped_refptr<const Extension> scoped_extension(extension); | 2108 scoped_refptr<const Extension> scoped_extension(extension); |
2108 const std::string& id = extension->id(); | 2109 const std::string& id = extension->id(); |
2109 // Extensions installed by policy can't be disabled. So even if a previous | 2110 // Extensions installed by policy can't be disabled. So even if a previous |
2110 // installation disabled the extension, make sure it is now enabled. | 2111 // installation disabled the extension, make sure it is now enabled. |
2111 bool initial_enable = | 2112 bool initial_enable = |
2112 !extension_prefs_->IsExtensionDisabled(id) || | 2113 !extension_prefs_->IsExtensionDisabled(id) || |
2113 system_->management_policy()->MustRemainEnabled(extension, NULL); | 2114 system_->management_policy()->MustRemainEnabled(extension, NULL); |
(...skipping 26 matching lines...) Expand all Loading... |
2140 pending_extension_manager()->Remove(id); | 2141 pending_extension_manager()->Remove(id); |
2141 } else { | 2142 } else { |
2142 // We explicitly want to re-enable an uninstalled external | 2143 // We explicitly want to re-enable an uninstalled external |
2143 // extension; if we're here, that means the user is manually | 2144 // extension; if we're here, that means the user is manually |
2144 // installing the extension. | 2145 // installing the extension. |
2145 if (IsExternalExtensionUninstalled(id)) { | 2146 if (IsExternalExtensionUninstalled(id)) { |
2146 initial_enable = true; | 2147 initial_enable = true; |
2147 } | 2148 } |
2148 } | 2149 } |
2149 | 2150 |
| 2151 // Unsupported requirements overrides the management policy. |
| 2152 if (!requirement_errors.empty()) { |
| 2153 initial_enable = false; |
| 2154 // If the extension was disabled because of unsupported requirements but |
| 2155 // now supports all requirements after an update, enable it and clear |
| 2156 // the errors. The case where the extension has different requirement errors |
| 2157 // will be handled later. |
| 2158 } else if (extension_prefs_->HasUnsupportedRequirements(id)) { |
| 2159 initial_enable = true; |
| 2160 extension_prefs_->ClearUnsupportedRequirements(id); |
| 2161 } |
| 2162 |
2150 // Do not record the install histograms for upgrades. | 2163 // Do not record the install histograms for upgrades. |
2151 if (!GetExtensionByIdInternal(extension->id(), true, true, false)) { | 2164 if (!GetExtensionByIdInternal(extension->id(), true, true, false)) { |
2152 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", | 2165 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", |
2153 extension->GetType(), 100); | 2166 extension->GetType(), 100); |
2154 RecordPermissionMessagesHistogram( | 2167 RecordPermissionMessagesHistogram( |
2155 extension, "Extensions.Permissions_Install"); | 2168 extension, "Extensions.Permissions_Install"); |
2156 } | 2169 } |
2157 | 2170 |
2158 // Certain extension locations are specific enough that we can | 2171 // Certain extension locations are specific enough that we can |
2159 // auto-acknowledge any extension that came from one of them. | 2172 // auto-acknowledge any extension that came from one of them. |
2160 if (extension->location() == Extension::EXTERNAL_POLICY_DOWNLOAD) { | 2173 if (extension->location() == Extension::EXTERNAL_POLICY_DOWNLOAD) { |
2161 AcknowledgeExternalExtension(extension->id()); | 2174 AcknowledgeExternalExtension(extension->id()); |
2162 } | 2175 } |
2163 | 2176 |
2164 extension_prefs_->OnExtensionInstalled( | 2177 extension_prefs_->OnExtensionInstalled( |
2165 extension, | 2178 extension, |
2166 initial_enable ? Extension::ENABLED : Extension::DISABLED, | 2179 initial_enable ? Extension::ENABLED : Extension::DISABLED, |
2167 from_webstore, | 2180 from_webstore, |
2168 page_ordinal); | 2181 page_ordinal); |
2169 | 2182 |
| 2183 if (!requirement_errors.empty()) { |
| 2184 extension_prefs_->SetDisableReason( |
| 2185 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT); |
| 2186 extension_prefs_->SetUnsupportedRequirements(id, requirement_errors); |
| 2187 } |
| 2188 |
2170 // Unpacked extensions default to allowing file access, but if that has been | 2189 // Unpacked extensions default to allowing file access, but if that has been |
2171 // overridden, don't reset the value. | 2190 // overridden, don't reset the value. |
2172 if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) && | 2191 if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) && |
2173 !extension_prefs_->HasAllowFileAccessSetting(id)) { | 2192 !extension_prefs_->HasAllowFileAccessSetting(id)) { |
2174 extension_prefs_->SetAllowFileAccess(id, true); | 2193 extension_prefs_->SetAllowFileAccess(id, true); |
2175 } | 2194 } |
2176 | 2195 |
2177 content::NotificationService::current()->Notify( | 2196 content::NotificationService::current()->Notify( |
2178 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 2197 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
2179 content::Source<Profile>(profile_), | 2198 content::Source<Profile>(profile_), |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2548 | 2567 |
2549 ExtensionService::NaClModuleInfoList::iterator | 2568 ExtensionService::NaClModuleInfoList::iterator |
2550 ExtensionService::FindNaClModule(const GURL& url) { | 2569 ExtensionService::FindNaClModule(const GURL& url) { |
2551 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2570 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
2552 iter != nacl_module_list_.end(); ++iter) { | 2571 iter != nacl_module_list_.end(); ++iter) { |
2553 if (iter->url == url) | 2572 if (iter->url == url) |
2554 return iter; | 2573 return iter; |
2555 } | 2574 } |
2556 return nacl_module_list_.end(); | 2575 return nacl_module_list_.end(); |
2557 } | 2576 } |
OLD | NEW |