| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 Profile* ExtensionService::profile() { | 1233 Profile* ExtensionService::profile() { |
| 1234 return profile_; | 1234 return profile_; |
| 1235 } | 1235 } |
| 1236 | 1236 |
| 1237 content::BrowserContext* ExtensionService::GetBrowserContext() const { | 1237 content::BrowserContext* ExtensionService::GetBrowserContext() const { |
| 1238 // Implemented in the .cc file to avoid adding a profile.h dependency to | 1238 // Implemented in the .cc file to avoid adding a profile.h dependency to |
| 1239 // extension_service.h. | 1239 // extension_service.h. |
| 1240 return profile_; | 1240 return profile_; |
| 1241 } | 1241 } |
| 1242 | 1242 |
| 1243 extensions::ExtensionPrefs* ExtensionService::extension_prefs() { | |
| 1244 return extension_prefs_; | |
| 1245 } | |
| 1246 | |
| 1247 const extensions::ExtensionPrefs* ExtensionService::extension_prefs() const { | |
| 1248 return extension_prefs_; | |
| 1249 } | |
| 1250 | |
| 1251 extensions::SettingsFrontend* ExtensionService::settings_frontend() { | 1243 extensions::SettingsFrontend* ExtensionService::settings_frontend() { |
| 1252 return settings_frontend_.get(); | 1244 return settings_frontend_.get(); |
| 1253 } | 1245 } |
| 1254 | 1246 |
| 1255 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() { | 1247 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() { |
| 1256 return extension_prefs()->content_settings_store(); | 1248 return extension_prefs_->content_settings_store(); |
| 1257 } | 1249 } |
| 1258 | 1250 |
| 1259 bool ExtensionService::is_ready() { | 1251 bool ExtensionService::is_ready() { |
| 1260 return ready_->is_signaled(); | 1252 return ready_->is_signaled(); |
| 1261 } | 1253 } |
| 1262 | 1254 |
| 1263 base::SequencedTaskRunner* ExtensionService::GetFileTaskRunner() { | 1255 base::SequencedTaskRunner* ExtensionService::GetFileTaskRunner() { |
| 1264 if (file_task_runner_.get()) | 1256 if (file_task_runner_.get()) |
| 1265 return file_task_runner_.get(); | 1257 return file_task_runner_.get(); |
| 1266 | 1258 |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 } | 1845 } |
| 1854 | 1846 |
| 1855 AddExtension(extension); | 1847 AddExtension(extension); |
| 1856 } | 1848 } |
| 1857 | 1849 |
| 1858 void ExtensionService::UpdateActivePermissions(const Extension* extension) { | 1850 void ExtensionService::UpdateActivePermissions(const Extension* extension) { |
| 1859 // If the extension has used the optional permissions API, it will have a | 1851 // If the extension has used the optional permissions API, it will have a |
| 1860 // custom set of active permissions defined in the extension prefs. Here, | 1852 // custom set of active permissions defined in the extension prefs. Here, |
| 1861 // we update the extension's active permissions based on the prefs. | 1853 // we update the extension's active permissions based on the prefs. |
| 1862 scoped_refptr<PermissionSet> active_permissions = | 1854 scoped_refptr<PermissionSet> active_permissions = |
| 1863 extension_prefs()->GetActivePermissions(extension->id()); | 1855 extension_prefs_->GetActivePermissions(extension->id()); |
| 1864 | 1856 |
| 1865 if (active_permissions.get()) { | 1857 if (active_permissions.get()) { |
| 1866 // We restrict the active permissions to be within the bounds defined in the | 1858 // We restrict the active permissions to be within the bounds defined in the |
| 1867 // extension's manifest. | 1859 // extension's manifest. |
| 1868 // a) active permissions must be a subset of optional + default permissions | 1860 // a) active permissions must be a subset of optional + default permissions |
| 1869 // b) active permissions must contains all default permissions | 1861 // b) active permissions must contains all default permissions |
| 1870 scoped_refptr<PermissionSet> total_permissions = | 1862 scoped_refptr<PermissionSet> total_permissions = |
| 1871 PermissionSet::CreateUnion( | 1863 PermissionSet::CreateUnion( |
| 1872 extensions::PermissionsData::GetRequiredPermissions(extension), | 1864 extensions::PermissionsData::GetRequiredPermissions(extension), |
| 1873 extensions::PermissionsData::GetOptionalPermissions(extension)); | 1865 extensions::PermissionsData::GetOptionalPermissions(extension)); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2153 initial_enable = true; | 2145 initial_enable = true; |
| 2154 extension_prefs_->ClearDisableReasons(id); | 2146 extension_prefs_->ClearDisableReasons(id); |
| 2155 } | 2147 } |
| 2156 | 2148 |
| 2157 if (blacklist_state == extensions::BLACKLISTED_MALWARE) { | 2149 if (blacklist_state == extensions::BLACKLISTED_MALWARE) { |
| 2158 // Installation of a blacklisted extension can happen from sync, policy, | 2150 // Installation of a blacklisted extension can happen from sync, policy, |
| 2159 // etc, where to maintain consistency we need to install it, just never | 2151 // etc, where to maintain consistency we need to install it, just never |
| 2160 // load it (see AddExtension). Usually it should be the job of callers to | 2152 // load it (see AddExtension). Usually it should be the job of callers to |
| 2161 // incercept blacklisted extension earlier (e.g. CrxInstaller, before even | 2153 // incercept blacklisted extension earlier (e.g. CrxInstaller, before even |
| 2162 // showing the install dialogue). | 2154 // showing the install dialogue). |
| 2163 extension_prefs()->AcknowledgeBlacklistedExtension(id); | 2155 extension_prefs_->AcknowledgeBlacklistedExtension(id); |
| 2164 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.SilentInstall", | 2156 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.SilentInstall", |
| 2165 extension->location(), | 2157 extension->location(), |
| 2166 Manifest::NUM_LOCATIONS); | 2158 Manifest::NUM_LOCATIONS); |
| 2167 } | 2159 } |
| 2168 | 2160 |
| 2169 if (!GetInstalledExtension(extension->id())) { | 2161 if (!GetInstalledExtension(extension->id())) { |
| 2170 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", | 2162 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", |
| 2171 extension->GetType(), 100); | 2163 extension->GetType(), 100); |
| 2172 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallSource", | 2164 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallSource", |
| 2173 extension->location(), Manifest::NUM_LOCATIONS); | 2165 extension->location(), Manifest::NUM_LOCATIONS); |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2875 void ExtensionService::UnloadAllExtensionsInternal() { | 2867 void ExtensionService::UnloadAllExtensionsInternal() { |
| 2876 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2868 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
| 2877 | 2869 |
| 2878 registry_->ClearAll(); | 2870 registry_->ClearAll(); |
| 2879 system_->runtime_data()->ClearAll(); | 2871 system_->runtime_data()->ClearAll(); |
| 2880 | 2872 |
| 2881 // TODO(erikkay) should there be a notification for this? We can't use | 2873 // TODO(erikkay) should there be a notification for this? We can't use |
| 2882 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2874 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
| 2883 // or uninstalled. | 2875 // or uninstalled. |
| 2884 } | 2876 } |
| OLD | NEW |