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

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

Issue 1349613003: [Extensions] Un-refcount PermissionSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 APIPermission::kEnumBoundary, 994 APIPermission::kEnumBoundary,
995 APIPermission::kEnumBoundary + 1, 995 APIPermission::kEnumBoundary + 1,
996 base::HistogramBase::kUmaTargetedHistogramFlag); 996 base::HistogramBase::kUmaTargetedHistogramFlag);
997 997
998 base::HistogramBase* counter_has_any = base::BooleanHistogram::FactoryGet( 998 base::HistogramBase* counter_has_any = base::BooleanHistogram::FactoryGet(
999 base::StringPrintf("Extensions.HasPermissions_%s3", histogram), 999 base::StringPrintf("Extensions.HasPermissions_%s3", histogram),
1000 base::HistogramBase::kUmaTargetedHistogramFlag); 1000 base::HistogramBase::kUmaTargetedHistogramFlag);
1001 1001
1002 PermissionIDSet permissions = 1002 PermissionIDSet permissions =
1003 extensions::PermissionMessageProvider::Get()->GetAllPermissionIDs( 1003 extensions::PermissionMessageProvider::Get()->GetAllPermissionIDs(
1004 extension->permissions_data()->active_permissions().get(), 1004 extension->permissions_data()->active_permissions(),
1005 extension->GetType()); 1005 extension->GetType());
1006 counter_has_any->AddBoolean(!permissions.empty()); 1006 counter_has_any->AddBoolean(!permissions.empty());
1007 for (const PermissionID& id : permissions) 1007 for (const PermissionID& id : permissions)
1008 counter->Add(id.id()); 1008 counter->Add(id.id());
1009 } 1009 }
1010 1010
1011 void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { 1011 void ExtensionService::NotifyExtensionLoaded(const Extension* extension) {
1012 // The URLRequestContexts need to be first to know that the extension 1012 // The URLRequestContexts need to be first to know that the extension
1013 // was loaded, otherwise a race can arise where a renderer that is created 1013 // was loaded, otherwise a race can arise where a renderer that is created
1014 // for the extension may try to load an extension URL with an extension id 1014 // for the extension may try to load an extension URL with an extension id
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 if (auto_grant_permission) 1595 if (auto_grant_permission)
1596 GrantPermissions(extension); 1596 GrantPermissions(extension);
1597 1597
1598 bool is_privilege_increase = false; 1598 bool is_privilege_increase = false;
1599 // We only need to compare the granted permissions to the current permissions 1599 // We only need to compare the granted permissions to the current permissions
1600 // if the extension has not been auto-granted its permissions above and is 1600 // if the extension has not been auto-granted its permissions above and is
1601 // installed internally. 1601 // installed internally.
1602 if (extension->location() == Manifest::INTERNAL && !auto_grant_permission) { 1602 if (extension->location() == Manifest::INTERNAL && !auto_grant_permission) {
1603 // Add all the recognized permissions if the granted permissions list 1603 // Add all the recognized permissions if the granted permissions list
1604 // hasn't been initialized yet. 1604 // hasn't been initialized yet.
1605 scoped_refptr<const PermissionSet> granted_permissions = 1605 scoped_ptr<const PermissionSet> granted_permissions =
1606 extension_prefs_->GetGrantedPermissions(extension->id()); 1606 extension_prefs_->GetGrantedPermissions(extension->id());
1607 CHECK(granted_permissions.get()); 1607 CHECK(granted_permissions.get());
1608 1608
1609 // Here, we check if an extension's privileges have increased in a manner 1609 // Here, we check if an extension's privileges have increased in a manner
1610 // that requires the user's approval. This could occur because the browser 1610 // that requires the user's approval. This could occur because the browser
1611 // upgraded and recognized additional privileges, or an extension upgrades 1611 // upgraded and recognized additional privileges, or an extension upgrades
1612 // to a version that requires additional privileges. 1612 // to a version that requires additional privileges.
1613 is_privilege_increase = 1613 is_privilege_increase =
1614 extensions::PermissionMessageProvider::Get()->IsPrivilegeIncrease( 1614 extensions::PermissionMessageProvider::Get()->IsPrivilegeIncrease(
1615 granted_permissions.get(), 1615 granted_permissions.get(),
1616 extension->permissions_data()->active_permissions().get(), 1616 extension->permissions_data()->active_permissions(),
1617 extension->GetType()); 1617 extension->GetType());
1618 } 1618 }
1619 1619
1620 if (is_extension_installed) { 1620 if (is_extension_installed) {
1621 // If the extension was already disabled, suppress any alerts for becoming 1621 // If the extension was already disabled, suppress any alerts for becoming
1622 // disabled on permissions increase. 1622 // disabled on permissions increase.
1623 bool previously_disabled = 1623 bool previously_disabled =
1624 extension_prefs_->IsExtensionDisabled(extension->id()); 1624 extension_prefs_->IsExtensionDisabled(extension->id());
1625 // Legacy disabled extensions do not have a disable reason. Infer that it 1625 // Legacy disabled extensions do not have a disable reason. Infer that it
1626 // was likely disabled by the user. 1626 // was likely disabled by the user.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 1841
1842 // Revokes blocked permissions from active_permissions for all extensions. 1842 // Revokes blocked permissions from active_permissions for all extensions.
1843 extensions::ExtensionManagement* settings = 1843 extensions::ExtensionManagement* settings =
1844 extensions::ExtensionManagementFactory::GetForBrowserContext(profile()); 1844 extensions::ExtensionManagementFactory::GetForBrowserContext(profile());
1845 CHECK(settings); 1845 CHECK(settings);
1846 scoped_ptr<ExtensionSet> all_extensions( 1846 scoped_ptr<ExtensionSet> all_extensions(
1847 registry_->GenerateInstalledExtensionsSet()); 1847 registry_->GenerateInstalledExtensionsSet());
1848 for (const auto& extension : *all_extensions.get()) { 1848 for (const auto& extension : *all_extensions.get()) {
1849 if (!settings->IsPermissionSetAllowed( 1849 if (!settings->IsPermissionSetAllowed(
1850 extension.get(), 1850 extension.get(),
1851 extension->permissions_data()->active_permissions())) { 1851 *extension->permissions_data()->active_permissions())) {
1852 extensions::PermissionsUpdater(profile()).RemovePermissionsUnsafe( 1852 extensions::PermissionsUpdater(profile()).RemovePermissionsUnsafe(
1853 extension.get(), 1853 extension.get(),
1854 settings->GetBlockedPermissions(extension.get()).get()); 1854 settings->GetBlockedPermissions(extension.get()).get());
1855 } 1855 }
1856 } 1856 }
1857 1857
1858 CheckManagementPolicy(); 1858 CheckManagementPolicy();
1859 } 1859 }
1860 1860
1861 void ExtensionService::AddNewOrUpdatedExtension( 1861 void ExtensionService::AddNewOrUpdatedExtension(
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2561 } 2561 }
2562 2562
2563 void ExtensionService::OnProfileDestructionStarted() { 2563 void ExtensionService::OnProfileDestructionStarted() {
2564 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2564 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2565 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2565 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2566 it != ids_to_unload.end(); 2566 it != ids_to_unload.end();
2567 ++it) { 2567 ++it) {
2568 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2568 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2569 } 2569 }
2570 } 2570 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs_unittest.cc ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698