OLD | NEW |
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/browser/extensions/api/permissions/permissions_api_helpers.h" | 5 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/common/extensions/api/permissions.h" | 8 #include "chrome/common/extensions/api/permissions.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 #include "chrome/common/extensions/extension_error_utils.h" | 10 #include "chrome/common/extensions/extension_error_utils.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 "Invalid value for origin pattern *: *"; | 28 "Invalid value for origin pattern *: *"; |
29 const char kUnknownPermissionError[] = | 29 const char kUnknownPermissionError[] = |
30 "'*' is not a recognized permission."; | 30 "'*' is not a recognized permission."; |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 scoped_ptr<Permissions> PackPermissionSet(const PermissionSet* set) { | 34 scoped_ptr<Permissions> PackPermissionSet(const PermissionSet* set) { |
35 Permissions* permissions(new Permissions()); | 35 Permissions* permissions(new Permissions()); |
36 | 36 |
37 permissions->permissions.reset(new std::vector<std::string>()); | 37 permissions->permissions.reset(new std::vector<std::string>()); |
38 PermissionsInfo* info = PermissionsInfo::GetInstance(); | |
39 for (APIPermissionSet::const_iterator i = set->apis().begin(); | 38 for (APIPermissionSet::const_iterator i = set->apis().begin(); |
40 i != set->apis().end(); ++i) { | 39 i != set->apis().end(); ++i) { |
41 permissions->permissions->push_back(info->GetByID(*i)->name()); | 40 permissions->permissions->push_back(i->name()); |
42 } | 41 } |
43 | 42 |
44 permissions->origins.reset(new std::vector<std::string>()); | 43 permissions->origins.reset(new std::vector<std::string>()); |
45 URLPatternSet hosts = set->explicit_hosts(); | 44 URLPatternSet hosts = set->explicit_hosts(); |
46 for (URLPatternSet::const_iterator i = hosts.begin(); i != hosts.end(); ++i) | 45 for (URLPatternSet::const_iterator i = hosts.begin(); i != hosts.end(); ++i) |
47 permissions->origins->push_back(i->GetAsString()); | 46 permissions->origins->push_back(i->GetAsString()); |
48 | 47 |
49 return scoped_ptr<Permissions>(permissions); | 48 return scoped_ptr<Permissions>(permissions); |
50 } | 49 } |
51 | 50 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 origins.AddPattern(origin); | 82 origins.AddPattern(origin); |
84 } | 83 } |
85 } | 84 } |
86 | 85 |
87 return scoped_refptr<PermissionSet>( | 86 return scoped_refptr<PermissionSet>( |
88 new PermissionSet(apis, origins, URLPatternSet())); | 87 new PermissionSet(apis, origins, URLPatternSet())); |
89 } | 88 } |
90 | 89 |
91 } // namespace permissions_api | 90 } // namespace permissions_api |
92 } // namespace extensions | 91 } // namespace extensions |
OLD | NEW |