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

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

Issue 9460002: Convert app_bindings.js to the schema_generated_bindings.js infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix koz bool thing Created 8 years, 9 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 | Annotate | Revision Log
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 24 matching lines...) Expand all
35 if (a == "net") 35 if (a == "net")
36 return b != "com"; 36 return b != "com";
37 if (a == "org") 37 if (a == "org")
38 return b != "com" && b != "net"; 38 return b != "com" && b != "net";
39 return false; 39 return false;
40 } 40 }
41 41
42 // Names of API modules that can be used without listing it in the 42 // Names of API modules that can be used without listing it in the
43 // permissions section of the manifest. 43 // permissions section of the manifest.
44 const char* kNonPermissionModuleNames[] = { 44 const char* kNonPermissionModuleNames[] = {
45 "app",
45 "browserAction", 46 "browserAction",
46 "devtools", 47 "devtools",
47 "extension", 48 "extension",
48 "i18n", 49 "i18n",
49 "omnibox", 50 "omnibox",
50 "pageAction", 51 "pageAction",
51 "pageActions", 52 "pageActions",
52 "permissions", 53 "permissions",
53 "test", 54 "test",
54 "types" 55 "types"
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 std::set<std::string> apis_str; 607 std::set<std::string> apis_str;
607 for (ExtensionAPIPermissionSet::const_iterator i = apis_.begin(); 608 for (ExtensionAPIPermissionSet::const_iterator i = apis_.begin();
608 i != apis_.end(); ++i) { 609 i != apis_.end(); ++i) {
609 ExtensionAPIPermission* permission = info->GetByID(*i); 610 ExtensionAPIPermission* permission = info->GetByID(*i);
610 if (permission) 611 if (permission)
611 apis_str.insert(permission->name()); 612 apis_str.insert(permission->name());
612 } 613 }
613 return apis_str; 614 return apis_str;
614 } 615 }
615 616
617 std::set<std::string> ExtensionPermissionSet::
618 GetAPIsWithAnyAccessAsStrings() const {
619 std::set<std::string> result = GetAPIsAsStrings();
620 for (size_t i = 0; i < kNumNonPermissionModuleNames; ++i)
621 result.insert(kNonPermissionModuleNames[i]);
622 for (size_t i = 0; i < kNumNonPermissionFunctionNames; ++i)
623 result.insert(GetPermissionName(kNonPermissionFunctionNames[i]));
624 return result;
625 }
626
616 bool ExtensionPermissionSet::HasAnyAccessToAPI( 627 bool ExtensionPermissionSet::HasAnyAccessToAPI(
617 const std::string& api_name) const { 628 const std::string& api_name) const {
618 if (HasAccessToFunction(api_name)) 629 if (HasAccessToFunction(api_name))
619 return true; 630 return true;
620 631
621 for (size_t i = 0; i < kNumNonPermissionFunctionNames; ++i) { 632 for (size_t i = 0; i < kNumNonPermissionFunctionNames; ++i) {
622 if (api_name == GetPermissionName(kNonPermissionFunctionNames[i])) 633 if (api_name == GetPermissionName(kNonPermissionFunctionNames[i]))
623 return true; 634 return true;
624 } 635 }
625 636
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 std::set<std::string> new_hosts_set(GetDistinctHosts(new_list, false, false)); 933 std::set<std::string> new_hosts_set(GetDistinctHosts(new_list, false, false));
923 std::set<std::string> old_hosts_set(GetDistinctHosts(old_list, false, false)); 934 std::set<std::string> old_hosts_set(GetDistinctHosts(old_list, false, false));
924 std::set<std::string> new_hosts_only; 935 std::set<std::string> new_hosts_only;
925 936
926 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), 937 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(),
927 old_hosts_set.begin(), old_hosts_set.end(), 938 old_hosts_set.begin(), old_hosts_set.end(),
928 std::inserter(new_hosts_only, new_hosts_only.begin())); 939 std::inserter(new_hosts_only, new_hosts_only.begin()));
929 940
930 return !new_hosts_only.empty(); 941 return !new_hosts_only.empty();
931 } 942 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698