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 <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 #include "chrome/common/chrome_paths.h" | 79 #include "chrome/common/chrome_paths.h" |
80 #include "chrome/common/chrome_switches.h" | 80 #include "chrome/common/chrome_switches.h" |
81 #include "chrome/common/chrome_version_info.h" | 81 #include "chrome/common/chrome_version_info.h" |
82 #include "chrome/common/extensions/extension.h" | 82 #include "chrome/common/extensions/extension.h" |
83 #include "chrome/common/extensions/extension_file_util.h" | 83 #include "chrome/common/extensions/extension_file_util.h" |
84 #include "chrome/common/extensions/extension_manifest_constants.h" | 84 #include "chrome/common/extensions/extension_manifest_constants.h" |
85 #include "chrome/common/extensions/extension_messages.h" | 85 #include "chrome/common/extensions/extension_messages.h" |
86 #include "chrome/common/extensions/extension_resource.h" | 86 #include "chrome/common/extensions/extension_resource.h" |
87 #include "chrome/common/extensions/feature_switch.h" | 87 #include "chrome/common/extensions/feature_switch.h" |
88 #include "chrome/common/extensions/features/feature.h" | 88 #include "chrome/common/extensions/features/feature.h" |
89 #include "chrome/common/extensions/manifest.h" | |
90 #include "chrome/common/extensions/manifest_url_handler.h" | 89 #include "chrome/common/extensions/manifest_url_handler.h" |
91 #include "chrome/common/pref_names.h" | 90 #include "chrome/common/pref_names.h" |
92 #include "chrome/common/startup_metric_utils.h" | 91 #include "chrome/common/startup_metric_utils.h" |
93 #include "chrome/common/url_constants.h" | 92 #include "chrome/common/url_constants.h" |
94 #include "content/public/browser/browser_thread.h" | 93 #include "content/public/browser/browser_thread.h" |
95 #include "content/public/browser/devtools_agent_host.h" | 94 #include "content/public/browser/devtools_agent_host.h" |
96 #include "content/public/browser/devtools_manager.h" | 95 #include "content/public/browser/devtools_manager.h" |
97 #include "content/public/browser/notification_service.h" | 96 #include "content/public/browser/notification_service.h" |
98 #include "content/public/browser/notification_types.h" | 97 #include "content/public/browser/notification_types.h" |
99 #include "content/public/browser/plugin_service.h" | 98 #include "content/public/browser/plugin_service.h" |
(...skipping 19 matching lines...) Expand all Loading... |
119 | 118 |
120 using content::BrowserContext; | 119 using content::BrowserContext; |
121 using content::BrowserThread; | 120 using content::BrowserThread; |
122 using content::DevToolsAgentHost; | 121 using content::DevToolsAgentHost; |
123 using content::PluginService; | 122 using content::PluginService; |
124 using extensions::CrxInstaller; | 123 using extensions::CrxInstaller; |
125 using extensions::Extension; | 124 using extensions::Extension; |
126 using extensions::ExtensionIdSet; | 125 using extensions::ExtensionIdSet; |
127 using extensions::ExtensionInfo; | 126 using extensions::ExtensionInfo; |
128 using extensions::FeatureSwitch; | 127 using extensions::FeatureSwitch; |
| 128 using extensions::Manifest; |
129 using extensions::PermissionMessage; | 129 using extensions::PermissionMessage; |
130 using extensions::PermissionMessages; | 130 using extensions::PermissionMessages; |
131 using extensions::PermissionSet; | 131 using extensions::PermissionSet; |
132 using extensions::UnloadedExtensionInfo; | 132 using extensions::UnloadedExtensionInfo; |
133 | 133 |
134 namespace errors = extension_manifest_errors; | 134 namespace errors = extension_manifest_errors; |
135 | 135 |
136 namespace { | 136 namespace { |
137 | 137 |
138 // Histogram values for logging events related to externally installed | 138 // Histogram values for logging events related to externally installed |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 void ExtensionService::AddProviderForTesting( | 237 void ExtensionService::AddProviderForTesting( |
238 extensions::ExternalProviderInterface* test_provider) { | 238 extensions::ExternalProviderInterface* test_provider) { |
239 CHECK(test_provider); | 239 CHECK(test_provider); |
240 external_extension_providers_.push_back( | 240 external_extension_providers_.push_back( |
241 linked_ptr<extensions::ExternalProviderInterface>(test_provider)); | 241 linked_ptr<extensions::ExternalProviderInterface>(test_provider)); |
242 } | 242 } |
243 | 243 |
244 bool ExtensionService::OnExternalExtensionUpdateUrlFound( | 244 bool ExtensionService::OnExternalExtensionUpdateUrlFound( |
245 const std::string& id, | 245 const std::string& id, |
246 const GURL& update_url, | 246 const GURL& update_url, |
247 Extension::Location location) { | 247 Manifest::Location location) { |
248 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 248 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
249 CHECK(Extension::IdIsValid(id)); | 249 CHECK(Extension::IdIsValid(id)); |
250 | 250 |
251 const Extension* extension = GetExtensionById(id, true); | 251 const Extension* extension = GetExtensionById(id, true); |
252 if (extension) { | 252 if (extension) { |
253 // Already installed. Skip this install if the current location has | 253 // Already installed. Skip this install if the current location has |
254 // higher priority than |location|. | 254 // higher priority than |location|. |
255 Extension::Location current = extension->location(); | 255 Manifest::Location current = extension->location(); |
256 if (current == Extension::GetHigherPriorityLocation(current, location)) | 256 if (current == Manifest::GetHigherPriorityLocation(current, location)) |
257 return false; | 257 return false; |
258 // Otherwise, overwrite the current installation. | 258 // Otherwise, overwrite the current installation. |
259 } | 259 } |
260 | 260 |
261 // Add |id| to the set of pending extensions. If it can not be added, | 261 // Add |id| to the set of pending extensions. If it can not be added, |
262 // then there is already a pending record from a higher-priority install | 262 // then there is already a pending record from a higher-priority install |
263 // source. In this case, signal that this extension will not be | 263 // source. In this case, signal that this extension will not be |
264 // installed by returning false. | 264 // installed by returning false. |
265 if (!pending_extension_manager()->AddFromExternalUpdateUrl( | 265 if (!pending_extension_manager()->AddFromExternalUpdateUrl( |
266 id, update_url, location)) { | 266 id, update_url, location)) { |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 extension, "Extensions.Permissions_Uninstall"); | 813 extension, "Extensions.Permissions_Uninstall"); |
814 | 814 |
815 // Unload before doing more cleanup to ensure that nothing is hanging on to | 815 // Unload before doing more cleanup to ensure that nothing is hanging on to |
816 // any of these resources. | 816 // any of these resources. |
817 UnloadExtension(extension_id, extension_misc::UNLOAD_REASON_UNINSTALL); | 817 UnloadExtension(extension_id, extension_misc::UNLOAD_REASON_UNINSTALL); |
818 | 818 |
819 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(), | 819 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(), |
820 external_uninstall); | 820 external_uninstall); |
821 | 821 |
822 // Tell the backend to start deleting installed extensions on the file thread. | 822 // Tell the backend to start deleting installed extensions on the file thread. |
823 if (Extension::LOAD != extension->location()) { | 823 if (Manifest::LOAD != extension->location()) { |
824 if (!GetFileTaskRunner()->PostTask( | 824 if (!GetFileTaskRunner()->PostTask( |
825 FROM_HERE, | 825 FROM_HERE, |
826 base::Bind( | 826 base::Bind( |
827 &extension_file_util::UninstallExtension, | 827 &extension_file_util::UninstallExtension, |
828 install_directory_, | 828 install_directory_, |
829 extension_id))) | 829 extension_id))) |
830 NOTREACHED(); | 830 NOTREACHED(); |
831 } | 831 } |
832 | 832 |
833 GURL launch_web_url_origin(extension->launch_web_url()); | 833 GURL launch_web_url_origin(extension->launch_web_url()); |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 return true; | 1573 return true; |
1574 } | 1574 } |
1575 | 1575 |
1576 bool ExtensionService::IsIncognitoEnabled( | 1576 bool ExtensionService::IsIncognitoEnabled( |
1577 const std::string& extension_id) const { | 1577 const std::string& extension_id) const { |
1578 const Extension* extension = GetInstalledExtension(extension_id); | 1578 const Extension* extension = GetInstalledExtension(extension_id); |
1579 if (extension && !extension->can_be_incognito_enabled()) | 1579 if (extension && !extension->can_be_incognito_enabled()) |
1580 return false; | 1580 return false; |
1581 // If this is an existing component extension we always allow it to | 1581 // If this is an existing component extension we always allow it to |
1582 // work in incognito mode. | 1582 // work in incognito mode. |
1583 if (extension && extension->location() == Extension::COMPONENT) | 1583 if (extension && extension->location() == Manifest::COMPONENT) |
1584 return true; | 1584 return true; |
1585 | 1585 |
1586 // Check the prefs. | 1586 // Check the prefs. |
1587 return extension_prefs_->IsIncognitoEnabled(extension_id); | 1587 return extension_prefs_->IsIncognitoEnabled(extension_id); |
1588 } | 1588 } |
1589 | 1589 |
1590 void ExtensionService::SetIsIncognitoEnabled( | 1590 void ExtensionService::SetIsIncognitoEnabled( |
1591 const std::string& extension_id, bool enabled) { | 1591 const std::string& extension_id, bool enabled) { |
1592 const Extension* extension = GetInstalledExtension(extension_id); | 1592 const Extension* extension = GetInstalledExtension(extension_id); |
1593 if (extension && !extension->can_be_incognito_enabled()) | 1593 if (extension && !extension->can_be_incognito_enabled()) |
1594 return; | 1594 return; |
1595 if (extension && extension->location() == Extension::COMPONENT) { | 1595 if (extension && extension->location() == Manifest::COMPONENT) { |
1596 // This shouldn't be called for component extensions unless they are | 1596 // This shouldn't be called for component extensions unless they are |
1597 // syncable. | 1597 // syncable. |
1598 DCHECK(extension->IsSyncable()); | 1598 DCHECK(extension->IsSyncable()); |
1599 | 1599 |
1600 // If we are here, make sure the we aren't trying to change the value. | 1600 // If we are here, make sure the we aren't trying to change the value. |
1601 DCHECK_EQ(enabled, IsIncognitoEnabled(extension_id)); | 1601 DCHECK_EQ(enabled, IsIncognitoEnabled(extension_id)); |
1602 | 1602 |
1603 return; | 1603 return; |
1604 } | 1604 } |
1605 | 1605 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 if (update_once_all_providers_are_ready_ && updater()) { | 1774 if (update_once_all_providers_are_ready_ && updater()) { |
1775 update_once_all_providers_are_ready_ = false; | 1775 update_once_all_providers_are_ready_ = false; |
1776 updater()->CheckNow(extensions::ExtensionUpdater::CheckParams()); | 1776 updater()->CheckNow(extensions::ExtensionUpdater::CheckParams()); |
1777 } | 1777 } |
1778 | 1778 |
1779 // Uninstall all the unclaimed extensions. | 1779 // Uninstall all the unclaimed extensions. |
1780 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> extensions_info( | 1780 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> extensions_info( |
1781 extension_prefs_->GetInstalledExtensionsInfo()); | 1781 extension_prefs_->GetInstalledExtensionsInfo()); |
1782 for (size_t i = 0; i < extensions_info->size(); ++i) { | 1782 for (size_t i = 0; i < extensions_info->size(); ++i) { |
1783 ExtensionInfo* info = extensions_info->at(i).get(); | 1783 ExtensionInfo* info = extensions_info->at(i).get(); |
1784 if (Extension::IsExternalLocation(info->extension_location)) | 1784 if (Manifest::IsExternalLocation(info->extension_location)) |
1785 CheckExternalUninstall(info->extension_id); | 1785 CheckExternalUninstall(info->extension_id); |
1786 } | 1786 } |
1787 IdentifyAlertableExtensions(); | 1787 IdentifyAlertableExtensions(); |
1788 } | 1788 } |
1789 | 1789 |
1790 void ExtensionService::IdentifyAlertableExtensions() { | 1790 void ExtensionService::IdentifyAlertableExtensions() { |
1791 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1791 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1792 | 1792 |
1793 // Build up the lists of extensions that require acknowledgment. If this is | 1793 // Build up the lists of extensions that require acknowledgment. If this is |
1794 // the first time, grandfather extensions that would have caused | 1794 // the first time, grandfather extensions that would have caused |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 void ExtensionService::AcknowledgeExternalExtension(const std::string& id) { | 1861 void ExtensionService::AcknowledgeExternalExtension(const std::string& id) { |
1862 extension_prefs_->AcknowledgeExternalExtension(id); | 1862 extension_prefs_->AcknowledgeExternalExtension(id); |
1863 UpdateExternalExtensionAlert(); | 1863 UpdateExternalExtensionAlert(); |
1864 } | 1864 } |
1865 | 1865 |
1866 bool ExtensionService::IsUnacknowledgedExternalExtension( | 1866 bool ExtensionService::IsUnacknowledgedExternalExtension( |
1867 const Extension* extension) { | 1867 const Extension* extension) { |
1868 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) | 1868 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) |
1869 return false; | 1869 return false; |
1870 | 1870 |
1871 return (Extension::IsExternalLocation(extension->location()) && | 1871 return (Manifest::IsExternalLocation(extension->location()) && |
1872 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id()) && | 1872 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id()) && |
1873 !(extension_prefs_->GetDisableReasons(extension->id()) & | 1873 !(extension_prefs_->GetDisableReasons(extension->id()) & |
1874 Extension::DISABLE_SIDELOAD_WIPEOUT)); | 1874 Extension::DISABLE_SIDELOAD_WIPEOUT)); |
1875 } | 1875 } |
1876 | 1876 |
1877 void ExtensionService::HandleExtensionAlertDetails() { | 1877 void ExtensionService::HandleExtensionAlertDetails() { |
1878 extension_error_ui_->ShowExtensions(); | 1878 extension_error_ui_->ShowExtensions(); |
1879 } | 1879 } |
1880 | 1880 |
1881 void ExtensionService::UpdateExternalExtensionAlert() { | 1881 void ExtensionService::UpdateExternalExtensionAlert() { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2044 content::Source<Profile>(profile_), | 2044 content::Source<Profile>(profile_), |
2045 content::NotificationService::NoDetails()); | 2045 content::NotificationService::NoDetails()); |
2046 } | 2046 } |
2047 | 2047 |
2048 void ExtensionService::AddExtension(const Extension* extension) { | 2048 void ExtensionService::AddExtension(const Extension* extension) { |
2049 // TODO(jstritar): We may be able to get rid of this branch by overriding the | 2049 // TODO(jstritar): We may be able to get rid of this branch by overriding the |
2050 // default extension state to DISABLED when the --disable-extensions flag | 2050 // default extension state to DISABLED when the --disable-extensions flag |
2051 // is set (http://crbug.com/29067). | 2051 // is set (http://crbug.com/29067). |
2052 if (!extensions_enabled() && | 2052 if (!extensions_enabled() && |
2053 !extension->is_theme() && | 2053 !extension->is_theme() && |
2054 extension->location() != Extension::COMPONENT && | 2054 extension->location() != Manifest::COMPONENT && |
2055 !Extension::IsExternalLocation(extension->location())) { | 2055 !Manifest::IsExternalLocation(extension->location())) { |
2056 return; | 2056 return; |
2057 } | 2057 } |
2058 | 2058 |
2059 SetBeingUpgraded(extension, false); | 2059 SetBeingUpgraded(extension, false); |
2060 | 2060 |
2061 // The extension is now loaded, remove its data from unloaded extension map. | 2061 // The extension is now loaded, remove its data from unloaded extension map. |
2062 unloaded_extension_paths_.erase(extension->id()); | 2062 unloaded_extension_paths_.erase(extension->id()); |
2063 | 2063 |
2064 // If a terminated extension is loaded, remove it from the terminated list. | 2064 // If a terminated extension is loaded, remove it from the terminated list. |
2065 UntrackTerminatedExtension(extension->id()); | 2065 UntrackTerminatedExtension(extension->id()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2223 } | 2223 } |
2224 | 2224 |
2225 // Silently grant all active permissions to default apps only on install. | 2225 // Silently grant all active permissions to default apps only on install. |
2226 // After install they should behave like other apps. | 2226 // After install they should behave like other apps. |
2227 if (is_default_app_install) | 2227 if (is_default_app_install) |
2228 GrantPermissions(extension, true); | 2228 GrantPermissions(extension, true); |
2229 | 2229 |
2230 if (is_extension_upgrade) { | 2230 if (is_extension_upgrade) { |
2231 // Other than for unpacked extensions, CrxInstaller should have guaranteed | 2231 // Other than for unpacked extensions, CrxInstaller should have guaranteed |
2232 // that we aren't downgrading. | 2232 // that we aren't downgrading. |
2233 if (extension->location() != Extension::LOAD) | 2233 if (extension->location() != Manifest::LOAD) |
2234 CHECK_GE(extension->version()->CompareTo(*(old->version())), 0); | 2234 CHECK_GE(extension->version()->CompareTo(*(old->version())), 0); |
2235 | 2235 |
2236 // Extensions get upgraded if the privileges are allowed to increase or | 2236 // Extensions get upgraded if the privileges are allowed to increase or |
2237 // the privileges haven't increased. | 2237 // the privileges haven't increased. |
2238 if (!is_privilege_increase) { | 2238 if (!is_privilege_increase) { |
2239 SetBeingUpgraded(old, true); | 2239 SetBeingUpgraded(old, true); |
2240 SetBeingUpgraded(extension, true); | 2240 SetBeingUpgraded(extension, true); |
2241 } | 2241 } |
2242 | 2242 |
2243 // If the extension was already disabled, suppress any alerts for becoming | 2243 // If the extension was already disabled, suppress any alerts for becoming |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2281 extension->id(), | 2281 extension->id(), |
2282 static_cast<Extension::DisableReason>(disable_reasons)); | 2282 static_cast<Extension::DisableReason>(disable_reasons)); |
2283 } | 2283 } |
2284 } | 2284 } |
2285 | 2285 |
2286 void ExtensionService::MaybeWipeout( | 2286 void ExtensionService::MaybeWipeout( |
2287 const extensions::Extension* extension) { | 2287 const extensions::Extension* extension) { |
2288 if (!wipeout_is_active_) | 2288 if (!wipeout_is_active_) |
2289 return; | 2289 return; |
2290 | 2290 |
2291 if (extension->GetType() != Extension::TYPE_EXTENSION) | 2291 if (extension->GetType() != Manifest::TYPE_EXTENSION) |
2292 return; | 2292 return; |
2293 | 2293 |
2294 Extension::Location location = extension->location(); | 2294 Manifest::Location location = extension->location(); |
2295 if (location != Extension::EXTERNAL_REGISTRY) | 2295 if (location != Manifest::EXTERNAL_REGISTRY) |
2296 return; | 2296 return; |
2297 | 2297 |
2298 if (extension_prefs_->IsExternalExtensionExcludedFromWipeout(extension->id())) | 2298 if (extension_prefs_->IsExternalExtensionExcludedFromWipeout(extension->id())) |
2299 return; | 2299 return; |
2300 | 2300 |
2301 int disable_reasons = extension_prefs_->GetDisableReasons(extension->id()); | 2301 int disable_reasons = extension_prefs_->GetDisableReasons(extension->id()); |
2302 if (disable_reasons == Extension::DISABLE_NONE) { | 2302 if (disable_reasons == Extension::DISABLE_NONE) { |
2303 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); | 2303 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); |
2304 extension_prefs_->AddDisableReason( | 2304 extension_prefs_->AddDisableReason( |
2305 extension->id(), | 2305 extension->id(), |
2306 static_cast<Extension::DisableReason>( | 2306 static_cast<Extension::DisableReason>( |
2307 Extension::DISABLE_SIDELOAD_WIPEOUT)); | 2307 Extension::DISABLE_SIDELOAD_WIPEOUT)); |
2308 UMA_HISTOGRAM_BOOLEAN("DisabledExtension.ExtensionWipedStatus", true); | 2308 UMA_HISTOGRAM_BOOLEAN("DisabledExtension.ExtensionWipedStatus", true); |
2309 wipeout_count_++; | 2309 wipeout_count_++; |
2310 } | 2310 } |
2311 } | 2311 } |
2312 | 2312 |
2313 void ExtensionService::UpdateActiveExtensionsInCrashReporter() { | 2313 void ExtensionService::UpdateActiveExtensionsInCrashReporter() { |
2314 std::set<std::string> extension_ids; | 2314 std::set<std::string> extension_ids; |
2315 for (ExtensionSet::const_iterator iter = extensions_.begin(); | 2315 for (ExtensionSet::const_iterator iter = extensions_.begin(); |
2316 iter != extensions_.end(); ++iter) { | 2316 iter != extensions_.end(); ++iter) { |
2317 const Extension* extension = *iter; | 2317 const Extension* extension = *iter; |
2318 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) | 2318 if (!extension->is_theme() && extension->location() != Manifest::COMPONENT) |
2319 extension_ids.insert(extension->id()); | 2319 extension_ids.insert(extension->id()); |
2320 } | 2320 } |
2321 | 2321 |
2322 child_process_logging::SetActiveExtensions(extension_ids); | 2322 child_process_logging::SetActiveExtensions(extension_ids); |
2323 } | 2323 } |
2324 | 2324 |
2325 void ExtensionService::OnExtensionInstalled( | 2325 void ExtensionService::OnExtensionInstalled( |
2326 const Extension* extension, | 2326 const Extension* extension, |
2327 const syncer::StringOrdinal& page_ordinal, | 2327 const syncer::StringOrdinal& page_ordinal, |
2328 bool has_requirement_errors, | 2328 bool has_requirement_errors, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 } else if (extension_prefs_->GetDisableReasons(id) == | 2379 } else if (extension_prefs_->GetDisableReasons(id) == |
2380 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) { | 2380 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) { |
2381 initial_enable = true; | 2381 initial_enable = true; |
2382 extension_prefs_->ClearDisableReasons(id); | 2382 extension_prefs_->ClearDisableReasons(id); |
2383 } | 2383 } |
2384 | 2384 |
2385 if (!GetInstalledExtension(extension->id())) { | 2385 if (!GetInstalledExtension(extension->id())) { |
2386 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", | 2386 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", |
2387 extension->GetType(), 100); | 2387 extension->GetType(), 100); |
2388 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallSource", | 2388 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallSource", |
2389 extension->location(), Extension::NUM_LOCATIONS); | 2389 extension->location(), Manifest::NUM_LOCATIONS); |
2390 RecordPermissionMessagesHistogram( | 2390 RecordPermissionMessagesHistogram( |
2391 extension, "Extensions.Permissions_Install"); | 2391 extension, "Extensions.Permissions_Install"); |
2392 } else { | 2392 } else { |
2393 UMA_HISTOGRAM_ENUMERATION("Extensions.UpdateType", | 2393 UMA_HISTOGRAM_ENUMERATION("Extensions.UpdateType", |
2394 extension->GetType(), 100); | 2394 extension->GetType(), 100); |
2395 UMA_HISTOGRAM_ENUMERATION("Extensions.UpdateSource", | 2395 UMA_HISTOGRAM_ENUMERATION("Extensions.UpdateSource", |
2396 extension->location(), Extension::NUM_LOCATIONS); | 2396 extension->location(), Manifest::NUM_LOCATIONS); |
2397 } | 2397 } |
2398 | 2398 |
2399 // Certain extension locations are specific enough that we can | 2399 // Certain extension locations are specific enough that we can |
2400 // auto-acknowledge any extension that came from one of them. | 2400 // auto-acknowledge any extension that came from one of them. |
2401 if (extension->location() == Extension::EXTERNAL_POLICY_DOWNLOAD) | 2401 if (extension->location() == Manifest::EXTERNAL_POLICY_DOWNLOAD) |
2402 AcknowledgeExternalExtension(extension->id()); | 2402 AcknowledgeExternalExtension(extension->id()); |
2403 const Extension::State initial_state = | 2403 const Extension::State initial_state = |
2404 initial_enable ? Extension::ENABLED : Extension::DISABLED; | 2404 initial_enable ? Extension::ENABLED : Extension::DISABLED; |
2405 if (ShouldDelayExtensionUpdate(id, wait_for_idle)) { | 2405 if (ShouldDelayExtensionUpdate(id, wait_for_idle)) { |
2406 extension_prefs_->SetDelayedInstallInfo(extension, initial_state, | 2406 extension_prefs_->SetDelayedInstallInfo(extension, initial_state, |
2407 page_ordinal); | 2407 page_ordinal); |
2408 | 2408 |
2409 // Transfer ownership of |extension|. | 2409 // Transfer ownership of |extension|. |
2410 delayed_updates_for_idle_.Insert(extension); | 2410 delayed_updates_for_idle_.Insert(extension); |
2411 | 2411 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2466 void ExtensionService::FinishInstallation(const Extension* extension) { | 2466 void ExtensionService::FinishInstallation(const Extension* extension) { |
2467 content::NotificationService::current()->Notify( | 2467 content::NotificationService::current()->Notify( |
2468 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 2468 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
2469 content::Source<Profile>(profile_), | 2469 content::Source<Profile>(profile_), |
2470 content::Details<const Extension>(extension)); | 2470 content::Details<const Extension>(extension)); |
2471 | 2471 |
2472 bool unacknowledged_external = IsUnacknowledgedExternalExtension(extension); | 2472 bool unacknowledged_external = IsUnacknowledgedExternalExtension(extension); |
2473 | 2473 |
2474 // Unpacked extensions default to allowing file access, but if that has been | 2474 // Unpacked extensions default to allowing file access, but if that has been |
2475 // overridden, don't reset the value. | 2475 // overridden, don't reset the value. |
2476 if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) && | 2476 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && |
2477 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { | 2477 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { |
2478 extension_prefs_->SetAllowFileAccess(extension->id(), true); | 2478 extension_prefs_->SetAllowFileAccess(extension->id(), true); |
2479 } | 2479 } |
2480 | 2480 |
2481 AddExtension(extension); | 2481 AddExtension(extension); |
2482 | 2482 |
2483 #if defined(ENABLE_THEMES) | 2483 #if defined(ENABLE_THEMES) |
2484 // We do this here since AddExtension() is always called on browser | 2484 // We do this here since AddExtension() is always called on browser |
2485 // startup, and we only really care about the last theme installed. | 2485 // startup, and we only really care about the last theme installed. |
2486 // If that ever changes and we have to move this code somewhere | 2486 // If that ever changes and we have to move this code somewhere |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2534 INCLUDE_TERMINATED | | 2534 INCLUDE_TERMINATED | |
2535 INCLUDE_BLACKLISTED; | 2535 INCLUDE_BLACKLISTED; |
2536 return GetExtensionById(id, include_mask); | 2536 return GetExtensionById(id, include_mask); |
2537 } | 2537 } |
2538 | 2538 |
2539 bool ExtensionService::ExtensionBindingsAllowed(const GURL& url) { | 2539 bool ExtensionService::ExtensionBindingsAllowed(const GURL& url) { |
2540 // Allow bindings for all packaged extensions and component hosted apps. | 2540 // Allow bindings for all packaged extensions and component hosted apps. |
2541 const Extension* extension = extensions_.GetExtensionOrAppByURL( | 2541 const Extension* extension = extensions_.GetExtensionOrAppByURL( |
2542 ExtensionURLInfo(url)); | 2542 ExtensionURLInfo(url)); |
2543 return extension && (!extension->is_hosted_app() || | 2543 return extension && (!extension->is_hosted_app() || |
2544 extension->location() == Extension::COMPONENT); | 2544 extension->location() == Manifest::COMPONENT); |
2545 } | 2545 } |
2546 | 2546 |
2547 bool ExtensionService::ShouldBlockUrlInBrowserTab(GURL* url) { | 2547 bool ExtensionService::ShouldBlockUrlInBrowserTab(GURL* url) { |
2548 const Extension* extension = extensions_.GetExtensionOrAppByURL( | 2548 const Extension* extension = extensions_.GetExtensionOrAppByURL( |
2549 ExtensionURLInfo(*url)); | 2549 ExtensionURLInfo(*url)); |
2550 if (extension && extension->is_platform_app()) { | 2550 if (extension && extension->is_platform_app()) { |
2551 *url = GURL(chrome::kExtensionInvalidRequestURL); | 2551 *url = GURL(chrome::kExtensionInvalidRequestURL); |
2552 return true; | 2552 return true; |
2553 } | 2553 } |
2554 | 2554 |
2555 return false; | 2555 return false; |
2556 } | 2556 } |
2557 | 2557 |
2558 bool ExtensionService::OnExternalExtensionFileFound( | 2558 bool ExtensionService::OnExternalExtensionFileFound( |
2559 const std::string& id, | 2559 const std::string& id, |
2560 const Version* version, | 2560 const Version* version, |
2561 const FilePath& path, | 2561 const FilePath& path, |
2562 Extension::Location location, | 2562 Manifest::Location location, |
2563 int creation_flags, | 2563 int creation_flags, |
2564 bool mark_acknowledged) { | 2564 bool mark_acknowledged) { |
2565 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2565 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2566 CHECK(Extension::IdIsValid(id)); | 2566 CHECK(Extension::IdIsValid(id)); |
2567 if (extension_prefs_->IsExternalExtensionUninstalled(id)) | 2567 if (extension_prefs_->IsExternalExtensionUninstalled(id)) |
2568 return false; | 2568 return false; |
2569 | 2569 |
2570 // Before even bothering to unpack, check and see if we already have this | 2570 // Before even bothering to unpack, check and see if we already have this |
2571 // version. This is important because these extensions are going to get | 2571 // version. This is important because these extensions are going to get |
2572 // installed on every startup. | 2572 // installed on every startup. |
2573 const Extension* existing = GetExtensionById(id, true); | 2573 const Extension* existing = GetExtensionById(id, true); |
2574 | 2574 |
2575 if (existing) { | 2575 if (existing) { |
2576 // The default apps will have the location set as INTERNAL. Since older | 2576 // The default apps will have the location set as INTERNAL. Since older |
2577 // default apps are installed as EXTERNAL, we override them. However, if the | 2577 // default apps are installed as EXTERNAL, we override them. However, if the |
2578 // app is already installed as internal, then do the version check. | 2578 // app is already installed as internal, then do the version check. |
2579 // TODO(grv) : Remove after Q1-2013. | 2579 // TODO(grv) : Remove after Q1-2013. |
2580 bool is_default_apps_migration = | 2580 bool is_default_apps_migration = |
2581 (location == Extension::INTERNAL && | 2581 (location == Manifest::INTERNAL && |
2582 Extension::IsExternalLocation(existing->location())); | 2582 Manifest::IsExternalLocation(existing->location())); |
2583 | 2583 |
2584 if (!is_default_apps_migration) { | 2584 if (!is_default_apps_migration) { |
2585 DCHECK(version); | 2585 DCHECK(version); |
2586 | 2586 |
2587 switch (existing->version()->CompareTo(*version)) { | 2587 switch (existing->version()->CompareTo(*version)) { |
2588 case -1: // existing version is older, we should upgrade | 2588 case -1: // existing version is older, we should upgrade |
2589 break; | 2589 break; |
2590 case 0: // existing version is same, do nothing | 2590 case 0: // existing version is same, do nothing |
2591 return false; | 2591 return false; |
2592 case 1: // existing version is newer, uh-oh | 2592 case 1: // existing version is newer, uh-oh |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2768 } | 2768 } |
2769 | 2769 |
2770 bool ExtensionService::HasApps() const { | 2770 bool ExtensionService::HasApps() const { |
2771 return !GetAppIds().empty(); | 2771 return !GetAppIds().empty(); |
2772 } | 2772 } |
2773 | 2773 |
2774 ExtensionIdSet ExtensionService::GetAppIds() const { | 2774 ExtensionIdSet ExtensionService::GetAppIds() const { |
2775 ExtensionIdSet result; | 2775 ExtensionIdSet result; |
2776 for (ExtensionSet::const_iterator it = extensions_.begin(); | 2776 for (ExtensionSet::const_iterator it = extensions_.begin(); |
2777 it != extensions_.end(); ++it) { | 2777 it != extensions_.end(); ++it) { |
2778 if ((*it)->is_app() && (*it)->location() != Extension::COMPONENT) | 2778 if ((*it)->is_app() && (*it)->location() != Manifest::COMPONENT) |
2779 result.insert((*it)->id()); | 2779 result.insert((*it)->id()); |
2780 } | 2780 } |
2781 | 2781 |
2782 return result; | 2782 return result; |
2783 } | 2783 } |
2784 | 2784 |
2785 bool ExtensionService::IsBackgroundPageReady(const Extension* extension) const { | 2785 bool ExtensionService::IsBackgroundPageReady(const Extension* extension) const { |
2786 if (!extension->has_persistent_background_page()) | 2786 if (!extension->has_persistent_background_page()) |
2787 return true; | 2787 return true; |
2788 ExtensionRuntimeDataMap::const_iterator it = | 2788 ExtensionRuntimeDataMap::const_iterator it = |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2982 if (system_->management_policy()->MustRemainEnabled(extension, NULL)) | 2982 if (system_->management_policy()->MustRemainEnabled(extension, NULL)) |
2983 return true; | 2983 return true; |
2984 | 2984 |
2985 if (extension_prefs_->IsExtensionDisabled(extension->id())) | 2985 if (extension_prefs_->IsExtensionDisabled(extension->id())) |
2986 return false; | 2986 return false; |
2987 | 2987 |
2988 if (FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) { | 2988 if (FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) { |
2989 // External extensions are initially disabled. We prompt the user before | 2989 // External extensions are initially disabled. We prompt the user before |
2990 // enabling them. Hosted apps are excepted because they are not dangerous | 2990 // enabling them. Hosted apps are excepted because they are not dangerous |
2991 // (they need to be launched by the user anyway). | 2991 // (they need to be launched by the user anyway). |
2992 if (extension->GetType() != Extension::TYPE_HOSTED_APP && | 2992 if (extension->GetType() != Manifest::TYPE_HOSTED_APP && |
2993 Extension::IsExternalLocation(extension->location()) && | 2993 Manifest::IsExternalLocation(extension->location()) && |
2994 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id())) { | 2994 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id())) { |
2995 return false; | 2995 return false; |
2996 } | 2996 } |
2997 } | 2997 } |
2998 | 2998 |
2999 return true; | 2999 return true; |
3000 } | 3000 } |
3001 | 3001 |
3002 bool ExtensionService::IsExtensionIdle(const std::string& extension_id) const { | 3002 bool ExtensionService::IsExtensionIdle(const std::string& extension_id) const { |
3003 ExtensionProcessManager* process_manager = system_->process_manager(); | 3003 ExtensionProcessManager* process_manager = system_->process_manager(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3115 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); | 3115 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); |
3116 DCHECK(extension); | 3116 DCHECK(extension); |
3117 if (!extension) | 3117 if (!extension) |
3118 continue; | 3118 continue; |
3119 blacklisted_extensions_.Insert(extension); | 3119 blacklisted_extensions_.Insert(extension); |
3120 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); | 3120 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); |
3121 } | 3121 } |
3122 | 3122 |
3123 IdentifyAlertableExtensions(); | 3123 IdentifyAlertableExtensions(); |
3124 } | 3124 } |
OLD | NEW |