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

Side by Side Diff: chrome/common/extensions/extension_permission_set.cc

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 2 Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/extensions/extension_permission_set.h" 5 #include "chrome/common/extensions/extension_permission_set.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 return permission; 443 return permission;
444 } 444 }
445 445
446 // 446 //
447 // ExtensionPermissionSet 447 // ExtensionPermissionSet
448 // 448 //
449 449
450 ExtensionPermissionSet::ExtensionPermissionSet() {} 450 ExtensionPermissionSet::ExtensionPermissionSet() {}
451 451
452 ExtensionPermissionSet::ExtensionPermissionSet( 452 ExtensionPermissionSet::ExtensionPermissionSet(
453 const Extension* extension, 453 const extensions::Extension* extension,
454 const ExtensionAPIPermissionSet& apis, 454 const ExtensionAPIPermissionSet& apis,
455 const URLPatternSet& explicit_hosts, 455 const URLPatternSet& explicit_hosts,
456 const ExtensionOAuth2Scopes& scopes) 456 const ExtensionOAuth2Scopes& scopes)
457 : apis_(apis), 457 : apis_(apis),
458 scopes_(scopes) { 458 scopes_(scopes) {
459 DCHECK(extension); 459 DCHECK(extension);
460 AddPatternsAndRemovePaths(explicit_hosts, &explicit_hosts_); 460 AddPatternsAndRemovePaths(explicit_hosts, &explicit_hosts_);
461 InitImplicitExtensionPermissions(extension); 461 InitImplicitExtensionPermissions(extension);
462 InitEffectiveHosts(); 462 InitEffectiveHosts();
463 } 463 }
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 860
861 // Build up the final vector by concatenating hosts and RCDs. 861 // Build up the final vector by concatenating hosts and RCDs.
862 std::set<std::string> distinct_hosts; 862 std::set<std::string> distinct_hosts;
863 for (HostVector::iterator it = hosts_best_rcd.begin(); 863 for (HostVector::iterator it = hosts_best_rcd.begin();
864 it != hosts_best_rcd.end(); ++it) 864 it != hosts_best_rcd.end(); ++it)
865 distinct_hosts.insert(it->first + it->second); 865 distinct_hosts.insert(it->first + it->second);
866 return distinct_hosts; 866 return distinct_hosts;
867 } 867 }
868 868
869 void ExtensionPermissionSet::InitImplicitExtensionPermissions( 869 void ExtensionPermissionSet::InitImplicitExtensionPermissions(
870 const Extension* extension) { 870 const extensions::Extension* extension) {
871 // Add the implied permissions. 871 // Add the implied permissions.
872 if (!extension->plugins().empty()) 872 if (!extension->plugins().empty())
873 apis_.insert(ExtensionAPIPermission::kPlugin); 873 apis_.insert(ExtensionAPIPermission::kPlugin);
874 874
875 if (!extension->devtools_url().is_empty()) 875 if (!extension->devtools_url().is_empty())
876 apis_.insert(ExtensionAPIPermission::kDevtools); 876 apis_.insert(ExtensionAPIPermission::kDevtools);
877 877
878 // Add the scriptable hosts. 878 // Add the scriptable hosts.
879 for (UserScriptList::const_iterator content_script = 879 for (UserScriptList::const_iterator content_script =
880 extension->content_scripts().begin(); 880 extension->content_scripts().begin();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 ExtensionOAuth2Scopes current_scopes = scopes(); 962 ExtensionOAuth2Scopes current_scopes = scopes();
963 ExtensionOAuth2Scopes new_scopes = permissions->scopes(); 963 ExtensionOAuth2Scopes new_scopes = permissions->scopes();
964 ExtensionOAuth2Scopes delta_scopes; 964 ExtensionOAuth2Scopes delta_scopes;
965 std::set_difference(new_scopes.begin(), new_scopes.end(), 965 std::set_difference(new_scopes.begin(), new_scopes.end(),
966 current_scopes.begin(), current_scopes.end(), 966 current_scopes.begin(), current_scopes.end(),
967 std::inserter(delta_scopes, delta_scopes.begin())); 967 std::inserter(delta_scopes, delta_scopes.begin()));
968 968
969 // We have less privileges if there are additional scopes present. 969 // We have less privileges if there are additional scopes present.
970 return !delta_scopes.empty(); 970 return !delta_scopes.empty();
971 } 971 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698