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 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2121 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) | 2121 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) |
2122 extension_ids.insert(extension->id()); | 2122 extension_ids.insert(extension->id()); |
2123 } | 2123 } |
2124 | 2124 |
2125 child_process_logging::SetActiveExtensions(extension_ids); | 2125 child_process_logging::SetActiveExtensions(extension_ids); |
2126 } | 2126 } |
2127 | 2127 |
2128 void ExtensionService::OnExtensionInstalled( | 2128 void ExtensionService::OnExtensionInstalled( |
2129 const Extension* extension, | 2129 const Extension* extension, |
2130 bool from_webstore, | 2130 bool from_webstore, |
2131 const syncer::StringOrdinal& page_ordinal) { | 2131 const syncer::StringOrdinal& page_ordinal, |
| 2132 bool has_requirement_errors) { |
2132 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2133 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2133 | 2134 |
2134 // Ensure extension is deleted unless we transfer ownership. | 2135 // Ensure extension is deleted unless we transfer ownership. |
2135 scoped_refptr<const Extension> scoped_extension(extension); | 2136 scoped_refptr<const Extension> scoped_extension(extension); |
2136 const std::string& id = extension->id(); | 2137 const std::string& id = extension->id(); |
2137 // Extensions installed by policy can't be disabled. So even if a previous | 2138 // Extensions installed by policy can't be disabled. So even if a previous |
2138 // installation disabled the extension, make sure it is now enabled. | 2139 // installation disabled the extension, make sure it is now enabled. |
2139 bool initial_enable = | 2140 bool initial_enable = |
2140 !extension_prefs_->IsExtensionDisabled(id) || | 2141 !extension_prefs_->IsExtensionDisabled(id) || |
2141 system_->management_policy()->MustRemainEnabled(extension, NULL); | 2142 system_->management_policy()->MustRemainEnabled(extension, NULL); |
(...skipping 26 matching lines...) Expand all Loading... |
2168 pending_extension_manager()->Remove(id); | 2169 pending_extension_manager()->Remove(id); |
2169 } else { | 2170 } else { |
2170 // We explicitly want to re-enable an uninstalled external | 2171 // We explicitly want to re-enable an uninstalled external |
2171 // extension; if we're here, that means the user is manually | 2172 // extension; if we're here, that means the user is manually |
2172 // installing the extension. | 2173 // installing the extension. |
2173 if (IsExternalExtensionUninstalled(id)) { | 2174 if (IsExternalExtensionUninstalled(id)) { |
2174 initial_enable = true; | 2175 initial_enable = true; |
2175 } | 2176 } |
2176 } | 2177 } |
2177 | 2178 |
| 2179 // Unsupported requirements overrides the management policy. |
| 2180 if (has_requirement_errors) { |
| 2181 initial_enable = false; |
| 2182 extension_prefs_->AddDisableReason( |
| 2183 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT); |
| 2184 // If the extension was disabled because of unsupported requirements but |
| 2185 // now supports all requirements after an update and there are not other |
| 2186 // disable reasons, enable it. |
| 2187 } else if (extension_prefs_->GetDisableReasons(id) == |
| 2188 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) { |
| 2189 initial_enable = true; |
| 2190 extension_prefs_->ClearDisableReasons(id); |
| 2191 } |
| 2192 |
2178 int include_mask = INCLUDE_ENABLED; | 2193 int include_mask = INCLUDE_ENABLED; |
2179 include_mask |= INCLUDE_DISABLED; | 2194 include_mask |= INCLUDE_DISABLED; |
2180 // Do not record the install histograms for upgrades. | 2195 // Do not record the install histograms for upgrades. |
2181 if (!GetExtensionByIdInternal(extension->id(), include_mask)) { | 2196 if (!GetExtensionByIdInternal(extension->id(), include_mask)) { |
2182 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", | 2197 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", |
2183 extension->GetType(), 100); | 2198 extension->GetType(), 100); |
2184 RecordPermissionMessagesHistogram( | 2199 RecordPermissionMessagesHistogram( |
2185 extension, "Extensions.Permissions_Install"); | 2200 extension, "Extensions.Permissions_Install"); |
2186 } | 2201 } |
2187 | 2202 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2625 extensions::ExtensionHost* extension_host) { | 2640 extensions::ExtensionHost* extension_host) { |
2626 if (!extension_host) | 2641 if (!extension_host) |
2627 return; | 2642 return; |
2628 | 2643 |
2629 #if !defined(OS_ANDROID) | 2644 #if !defined(OS_ANDROID) |
2630 extensions::LaunchPlatformApp(extension_host->profile(), | 2645 extensions::LaunchPlatformApp(extension_host->profile(), |
2631 extension_host->extension(), | 2646 extension_host->extension(), |
2632 NULL, FilePath()); | 2647 NULL, FilePath()); |
2633 #endif | 2648 #endif |
2634 } | 2649 } |
OLD | NEW |