| 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 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 Profile* ExtensionService::profile() { | 1255 Profile* ExtensionService::profile() { |
| 1256 return profile_; | 1256 return profile_; |
| 1257 } | 1257 } |
| 1258 | 1258 |
| 1259 content::BrowserContext* ExtensionService::GetBrowserContext() const { | 1259 content::BrowserContext* ExtensionService::GetBrowserContext() const { |
| 1260 // Implemented in the .cc file to avoid adding a profile.h dependency to | 1260 // Implemented in the .cc file to avoid adding a profile.h dependency to |
| 1261 // extension_service.h. | 1261 // extension_service.h. |
| 1262 return profile_; | 1262 return profile_; |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 extensions::ExtensionPrefs* ExtensionService::extension_prefs() { | |
| 1266 return extension_prefs_; | |
| 1267 } | |
| 1268 | |
| 1269 const extensions::ExtensionPrefs* ExtensionService::extension_prefs() const { | |
| 1270 return extension_prefs_; | |
| 1271 } | |
| 1272 | |
| 1273 extensions::SettingsFrontend* ExtensionService::settings_frontend() { | 1265 extensions::SettingsFrontend* ExtensionService::settings_frontend() { |
| 1274 return settings_frontend_.get(); | 1266 return settings_frontend_.get(); |
| 1275 } | 1267 } |
| 1276 | 1268 |
| 1277 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() { | 1269 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() { |
| 1278 return extension_prefs()->content_settings_store(); | 1270 return extension_prefs_->content_settings_store(); |
| 1279 } | 1271 } |
| 1280 | 1272 |
| 1281 bool ExtensionService::is_ready() { | 1273 bool ExtensionService::is_ready() { |
| 1282 return ready_->is_signaled(); | 1274 return ready_->is_signaled(); |
| 1283 } | 1275 } |
| 1284 | 1276 |
| 1285 base::SequencedTaskRunner* ExtensionService::GetFileTaskRunner() { | 1277 base::SequencedTaskRunner* ExtensionService::GetFileTaskRunner() { |
| 1286 if (file_task_runner_.get()) | 1278 if (file_task_runner_.get()) |
| 1287 return file_task_runner_.get(); | 1279 return file_task_runner_.get(); |
| 1288 | 1280 |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1875 } | 1867 } |
| 1876 | 1868 |
| 1877 AddExtension(extension); | 1869 AddExtension(extension); |
| 1878 } | 1870 } |
| 1879 | 1871 |
| 1880 void ExtensionService::UpdateActivePermissions(const Extension* extension) { | 1872 void ExtensionService::UpdateActivePermissions(const Extension* extension) { |
| 1881 // If the extension has used the optional permissions API, it will have a | 1873 // If the extension has used the optional permissions API, it will have a |
| 1882 // custom set of active permissions defined in the extension prefs. Here, | 1874 // custom set of active permissions defined in the extension prefs. Here, |
| 1883 // we update the extension's active permissions based on the prefs. | 1875 // we update the extension's active permissions based on the prefs. |
| 1884 scoped_refptr<PermissionSet> active_permissions = | 1876 scoped_refptr<PermissionSet> active_permissions = |
| 1885 extension_prefs()->GetActivePermissions(extension->id()); | 1877 extension_prefs_->GetActivePermissions(extension->id()); |
| 1886 | 1878 |
| 1887 if (active_permissions.get()) { | 1879 if (active_permissions.get()) { |
| 1888 // We restrict the active permissions to be within the bounds defined in the | 1880 // We restrict the active permissions to be within the bounds defined in the |
| 1889 // extension's manifest. | 1881 // extension's manifest. |
| 1890 // a) active permissions must be a subset of optional + default permissions | 1882 // a) active permissions must be a subset of optional + default permissions |
| 1891 // b) active permissions must contains all default permissions | 1883 // b) active permissions must contains all default permissions |
| 1892 scoped_refptr<PermissionSet> total_permissions = | 1884 scoped_refptr<PermissionSet> total_permissions = |
| 1893 PermissionSet::CreateUnion( | 1885 PermissionSet::CreateUnion( |
| 1894 extensions::PermissionsData::GetRequiredPermissions(extension), | 1886 extensions::PermissionsData::GetRequiredPermissions(extension), |
| 1895 extensions::PermissionsData::GetOptionalPermissions(extension)); | 1887 extensions::PermissionsData::GetOptionalPermissions(extension)); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 initial_enable = true; | 2167 initial_enable = true; |
| 2176 extension_prefs_->ClearDisableReasons(id); | 2168 extension_prefs_->ClearDisableReasons(id); |
| 2177 } | 2169 } |
| 2178 | 2170 |
| 2179 if (blacklist_state == extensions::BLACKLISTED_MALWARE) { | 2171 if (blacklist_state == extensions::BLACKLISTED_MALWARE) { |
| 2180 // Installation of a blacklisted extension can happen from sync, policy, | 2172 // Installation of a blacklisted extension can happen from sync, policy, |
| 2181 // etc, where to maintain consistency we need to install it, just never | 2173 // etc, where to maintain consistency we need to install it, just never |
| 2182 // load it (see AddExtension). Usually it should be the job of callers to | 2174 // load it (see AddExtension). Usually it should be the job of callers to |
| 2183 // incercept blacklisted extension earlier (e.g. CrxInstaller, before even | 2175 // incercept blacklisted extension earlier (e.g. CrxInstaller, before even |
| 2184 // showing the install dialogue). | 2176 // showing the install dialogue). |
| 2185 extension_prefs()->AcknowledgeBlacklistedExtension(id); | 2177 extension_prefs_->AcknowledgeBlacklistedExtension(id); |
| 2186 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.SilentInstall", | 2178 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.SilentInstall", |
| 2187 extension->location(), | 2179 extension->location(), |
| 2188 Manifest::NUM_LOCATIONS); | 2180 Manifest::NUM_LOCATIONS); |
| 2189 } | 2181 } |
| 2190 | 2182 |
| 2191 if (!GetInstalledExtension(extension->id())) { | 2183 if (!GetInstalledExtension(extension->id())) { |
| 2192 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", | 2184 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", |
| 2193 extension->GetType(), 100); | 2185 extension->GetType(), 100); |
| 2194 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallSource", | 2186 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallSource", |
| 2195 extension->location(), Manifest::NUM_LOCATIONS); | 2187 extension->location(), Manifest::NUM_LOCATIONS); |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2904 void ExtensionService::UnloadAllExtensionsInternal() { | 2896 void ExtensionService::UnloadAllExtensionsInternal() { |
| 2905 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2897 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
| 2906 | 2898 |
| 2907 registry_->ClearAll(); | 2899 registry_->ClearAll(); |
| 2908 system_->runtime_data()->ClearAll(); | 2900 system_->runtime_data()->ClearAll(); |
| 2909 | 2901 |
| 2910 // TODO(erikkay) should there be a notification for this? We can't use | 2902 // TODO(erikkay) should there be a notification for this? We can't use |
| 2911 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2903 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
| 2912 // or uninstalled. | 2904 // or uninstalled. |
| 2913 } | 2905 } |
| OLD | NEW |