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

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 6 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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 return permission; 445 return permission;
446 } 446 }
447 447
448 // 448 //
449 // ExtensionPermissionSet 449 // ExtensionPermissionSet
450 // 450 //
451 451
452 ExtensionPermissionSet::ExtensionPermissionSet() {} 452 ExtensionPermissionSet::ExtensionPermissionSet() {}
453 453
454 ExtensionPermissionSet::ExtensionPermissionSet( 454 ExtensionPermissionSet::ExtensionPermissionSet(
455 const Extension* extension, 455 const extensions::Extension* extension,
456 const ExtensionAPIPermissionSet& apis, 456 const ExtensionAPIPermissionSet& apis,
457 const URLPatternSet& explicit_hosts, 457 const URLPatternSet& explicit_hosts,
458 const ExtensionOAuth2Scopes& scopes) 458 const ExtensionOAuth2Scopes& scopes)
459 : apis_(apis), 459 : apis_(apis),
460 scopes_(scopes) { 460 scopes_(scopes) {
461 DCHECK(extension); 461 DCHECK(extension);
462 AddPatternsAndRemovePaths(explicit_hosts, &explicit_hosts_); 462 AddPatternsAndRemovePaths(explicit_hosts, &explicit_hosts_);
463 InitImplicitExtensionPermissions(extension); 463 InitImplicitExtensionPermissions(extension);
464 InitEffectiveHosts(); 464 InitEffectiveHosts();
465 } 465 }
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 862
863 // Build up the final vector by concatenating hosts and RCDs. 863 // Build up the final vector by concatenating hosts and RCDs.
864 std::set<std::string> distinct_hosts; 864 std::set<std::string> distinct_hosts;
865 for (HostVector::iterator it = hosts_best_rcd.begin(); 865 for (HostVector::iterator it = hosts_best_rcd.begin();
866 it != hosts_best_rcd.end(); ++it) 866 it != hosts_best_rcd.end(); ++it)
867 distinct_hosts.insert(it->first + it->second); 867 distinct_hosts.insert(it->first + it->second);
868 return distinct_hosts; 868 return distinct_hosts;
869 } 869 }
870 870
871 void ExtensionPermissionSet::InitImplicitExtensionPermissions( 871 void ExtensionPermissionSet::InitImplicitExtensionPermissions(
872 const Extension* extension) { 872 const extensions::Extension* extension) {
873 // Add the implied permissions. 873 // Add the implied permissions.
874 if (!extension->plugins().empty()) 874 if (!extension->plugins().empty())
875 apis_.insert(ExtensionAPIPermission::kPlugin); 875 apis_.insert(ExtensionAPIPermission::kPlugin);
876 876
877 if (!extension->devtools_url().is_empty()) 877 if (!extension->devtools_url().is_empty())
878 apis_.insert(ExtensionAPIPermission::kDevtools); 878 apis_.insert(ExtensionAPIPermission::kDevtools);
879 879
880 // Add the scriptable hosts. 880 // Add the scriptable hosts.
881 for (UserScriptList::const_iterator content_script = 881 for (UserScriptList::const_iterator content_script =
882 extension->content_scripts().begin(); 882 extension->content_scripts().begin();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 ExtensionOAuth2Scopes current_scopes = scopes(); 964 ExtensionOAuth2Scopes current_scopes = scopes();
965 ExtensionOAuth2Scopes new_scopes = permissions->scopes(); 965 ExtensionOAuth2Scopes new_scopes = permissions->scopes();
966 ExtensionOAuth2Scopes delta_scopes; 966 ExtensionOAuth2Scopes delta_scopes;
967 std::set_difference(new_scopes.begin(), new_scopes.end(), 967 std::set_difference(new_scopes.begin(), new_scopes.end(),
968 current_scopes.begin(), current_scopes.end(), 968 current_scopes.begin(), current_scopes.end(),
969 std::inserter(delta_scopes, delta_scopes.begin())); 969 std::inserter(delta_scopes, delta_scopes.begin()));
970 970
971 // We have less privileges if there are additional scopes present. 971 // We have less privileges if there are additional scopes present.
972 return !delta_scopes.empty(); 972 return !delta_scopes.empty();
973 } 973 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_permission_set.h ('k') | chrome/common/extensions/extension_permission_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698