Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: chrome/browser/extensions/extension_service.cc

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

Powered by Google App Engine
This is Rietveld 408576698