| 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 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 void ExtensionService::GrantPermissions(const Extension* extension) { | 1001 void ExtensionService::GrantPermissions(const Extension* extension) { |
| 1002 CHECK(extension); | 1002 CHECK(extension); |
| 1003 extensions::PermissionsUpdater perms_updater(profile()); | 1003 extensions::PermissionsUpdater perms_updater(profile()); |
| 1004 perms_updater.GrantActivePermissions(extension); | 1004 perms_updater.GrantActivePermissions(extension); |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 // static | 1007 // static |
| 1008 void ExtensionService::RecordPermissionMessagesHistogram( | 1008 void ExtensionService::RecordPermissionMessagesHistogram( |
| 1009 const Extension* e, const char* histogram) { | 1009 const Extension* extension, const char* histogram) { |
| 1010 // Since this is called from multiple sources, and since the histogram macros | 1010 // Since this is called from multiple sources, and since the histogram macros |
| 1011 // use statics, we need to manually lookup the histogram ourselves. | 1011 // use statics, we need to manually lookup the histogram ourselves. |
| 1012 base::HistogramBase* counter = base::LinearHistogram::FactoryGet( | 1012 base::HistogramBase* counter = base::LinearHistogram::FactoryGet( |
| 1013 histogram, | 1013 histogram, |
| 1014 1, | 1014 1, |
| 1015 PermissionMessage::kEnumBoundary, | 1015 PermissionMessage::kEnumBoundary, |
| 1016 PermissionMessage::kEnumBoundary + 1, | 1016 PermissionMessage::kEnumBoundary + 1, |
| 1017 base::HistogramBase::kUmaTargetedHistogramFlag); | 1017 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 1018 | 1018 |
| 1019 PermissionMessages permissions = e->GetPermissionMessages(); | 1019 PermissionMessages permissions = |
| 1020 extensions::PermissionsData::GetPermissionMessages(extension); |
| 1020 if (permissions.empty()) { | 1021 if (permissions.empty()) { |
| 1021 counter->Add(PermissionMessage::kNone); | 1022 counter->Add(PermissionMessage::kNone); |
| 1022 } else { | 1023 } else { |
| 1023 for (PermissionMessages::iterator it = permissions.begin(); | 1024 for (PermissionMessages::iterator it = permissions.begin(); |
| 1024 it != permissions.end(); ++it) | 1025 it != permissions.end(); ++it) |
| 1025 counter->Add(it->id()); | 1026 counter->Add(it->id()); |
| 1026 } | 1027 } |
| 1027 } | 1028 } |
| 1028 | 1029 |
| 1029 void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { | 1030 void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 // relevant objects via EXTENSION_LOADED? | 1071 // relevant objects via EXTENSION_LOADED? |
| 1071 | 1072 |
| 1072 profile_->GetExtensionSpecialStoragePolicy()-> | 1073 profile_->GetExtensionSpecialStoragePolicy()-> |
| 1073 GrantRightsForExtension(extension); | 1074 GrantRightsForExtension(extension); |
| 1074 | 1075 |
| 1075 UpdateActiveExtensionsInCrashReporter(); | 1076 UpdateActiveExtensionsInCrashReporter(); |
| 1076 | 1077 |
| 1077 // If the extension has permission to load chrome://favicon/ resources we need | 1078 // If the extension has permission to load chrome://favicon/ resources we need |
| 1078 // to make sure that the FaviconSource is registered with the | 1079 // to make sure that the FaviconSource is registered with the |
| 1079 // ChromeURLDataManager. | 1080 // ChromeURLDataManager. |
| 1080 if (extension->HasHostPermission(GURL(chrome::kChromeUIFaviconURL))) { | 1081 if (extensions::PermissionsData::HasHostPermission( |
| 1082 extension, GURL(chrome::kChromeUIFaviconURL))) { |
| 1081 FaviconSource* favicon_source = new FaviconSource(profile_, | 1083 FaviconSource* favicon_source = new FaviconSource(profile_, |
| 1082 FaviconSource::FAVICON); | 1084 FaviconSource::FAVICON); |
| 1083 content::URLDataSource::Add(profile_, favicon_source); | 1085 content::URLDataSource::Add(profile_, favicon_source); |
| 1084 } | 1086 } |
| 1085 | 1087 |
| 1086 #if !defined(OS_ANDROID) | 1088 #if !defined(OS_ANDROID) |
| 1087 // Same for chrome://theme/ resources. | 1089 // Same for chrome://theme/ resources. |
| 1088 if (extension->HasHostPermission(GURL(chrome::kChromeUIThemeURL))) { | 1090 if (extensions::PermissionsData::HasHostPermission( |
| 1091 extension, GURL(chrome::kChromeUIThemeURL))) { |
| 1089 ThemeSource* theme_source = new ThemeSource(profile_); | 1092 ThemeSource* theme_source = new ThemeSource(profile_); |
| 1090 content::URLDataSource::Add(profile_, theme_source); | 1093 content::URLDataSource::Add(profile_, theme_source); |
| 1091 } | 1094 } |
| 1092 #endif | 1095 #endif |
| 1093 | 1096 |
| 1094 // Same for chrome://thumb/ resources. | 1097 // Same for chrome://thumb/ resources. |
| 1095 if (extension->HasHostPermission(GURL(chrome::kChromeUIThumbnailURL))) { | 1098 if (extensions::PermissionsData::HasHostPermission( |
| 1099 extension, GURL(chrome::kChromeUIThumbnailURL))) { |
| 1096 ThumbnailSource* thumbnail_source = new ThumbnailSource(profile_); | 1100 ThumbnailSource* thumbnail_source = new ThumbnailSource(profile_); |
| 1097 content::URLDataSource::Add(profile_, thumbnail_source); | 1101 content::URLDataSource::Add(profile_, thumbnail_source); |
| 1098 } | 1102 } |
| 1099 | 1103 |
| 1100 #if defined(ENABLE_PLUGINS) | 1104 #if defined(ENABLE_PLUGINS) |
| 1101 // TODO(mpcomplete): This ends up affecting all profiles. See crbug.com/80757. | 1105 // TODO(mpcomplete): This ends up affecting all profiles. See crbug.com/80757. |
| 1102 bool plugins_changed = false; | 1106 bool plugins_changed = false; |
| 1103 if (extensions::PluginInfo::HasPlugins(extension)) { | 1107 if (extensions::PluginInfo::HasPlugins(extension)) { |
| 1104 const extensions::PluginInfo::PluginVector* plugins = | 1108 const extensions::PluginInfo::PluginVector* plugins = |
| 1105 extensions::PluginInfo::GetPlugins(extension); | 1109 extensions::PluginInfo::GetPlugins(extension); |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2200 bool is_default_app_install = | 2204 bool is_default_app_install = |
| 2201 (!is_extension_upgrade && extension->was_installed_by_default()); | 2205 (!is_extension_upgrade && extension->was_installed_by_default()); |
| 2202 // Silently grant all active permissions to default apps only on install. | 2206 // Silently grant all active permissions to default apps only on install. |
| 2203 // After install they should behave like other apps. | 2207 // After install they should behave like other apps. |
| 2204 if (is_default_app_install) | 2208 if (is_default_app_install) |
| 2205 GrantPermissions(extension); | 2209 GrantPermissions(extension); |
| 2206 | 2210 |
| 2207 bool is_privilege_increase = false; | 2211 bool is_privilege_increase = false; |
| 2208 // We only need to compare the granted permissions to the current permissions | 2212 // We only need to compare the granted permissions to the current permissions |
| 2209 // if the extension is not allowed to silently increase its permissions. | 2213 // if the extension is not allowed to silently increase its permissions. |
| 2210 if (!(extension->CanSilentlyIncreasePermissions() || | 2214 if (!extensions::PermissionsData::CanSilentlyIncreasePermissions(extension) && |
| 2211 is_default_app_install)) { | 2215 !is_default_app_install) { |
| 2212 // Add all the recognized permissions if the granted permissions list | 2216 // Add all the recognized permissions if the granted permissions list |
| 2213 // hasn't been initialized yet. | 2217 // hasn't been initialized yet. |
| 2214 scoped_refptr<PermissionSet> granted_permissions = | 2218 scoped_refptr<PermissionSet> granted_permissions = |
| 2215 extension_prefs_->GetGrantedPermissions(extension->id()); | 2219 extension_prefs_->GetGrantedPermissions(extension->id()); |
| 2216 CHECK(granted_permissions.get()); | 2220 CHECK(granted_permissions.get()); |
| 2217 | 2221 |
| 2218 // Here, we check if an extension's privileges have increased in a manner | 2222 // Here, we check if an extension's privileges have increased in a manner |
| 2219 // that requires the user's approval. This could occur because the browser | 2223 // that requires the user's approval. This could occur because the browser |
| 2220 // upgraded and recognized additional privileges, or an extension upgrades | 2224 // upgraded and recognized additional privileges, or an extension upgrades |
| 2221 // to a version that requires additional privileges. | 2225 // to a version that requires additional privileges. |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3111 } | 3115 } |
| 3112 | 3116 |
| 3113 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 3117 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
| 3114 update_observers_.AddObserver(observer); | 3118 update_observers_.AddObserver(observer); |
| 3115 } | 3119 } |
| 3116 | 3120 |
| 3117 void ExtensionService::RemoveUpdateObserver( | 3121 void ExtensionService::RemoveUpdateObserver( |
| 3118 extensions::UpdateObserver* observer) { | 3122 extensions::UpdateObserver* observer) { |
| 3119 update_observers_.RemoveObserver(observer); | 3123 update_observers_.RemoveObserver(observer); |
| 3120 } | 3124 } |
| OLD | NEW |