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

Side by Side Diff: chrome/browser/extensions/api/permissions/permissions_api_helpers.cc

Issue 1349613003: [Extensions] Un-refcount PermissionSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 2 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/browser/extensions/api/permissions/permissions_api_helpers.h" 5 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/common/extensions/api/permissions.h" 10 #include "chrome/common/extensions/api/permissions.h"
11 #include "extensions/common/error_utils.h" 11 #include "extensions/common/error_utils.h"
12 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
13 #include "extensions/common/permissions/permission_set.h" 13 #include "extensions/common/permissions/permission_set.h"
14 #include "extensions/common/permissions/permissions_info.h" 14 #include "extensions/common/permissions/permissions_info.h"
15 #include "extensions/common/permissions/usb_device_permission.h" 15 #include "extensions/common/permissions/usb_device_permission.h"
16 #include "extensions/common/url_pattern_set.h" 16 #include "extensions/common/url_pattern_set.h"
17 17
18 using extensions::APIPermission;
19 using extensions::PermissionSet;
20 using extensions::PermissionsInfo;
21
22 namespace extensions { 18 namespace extensions {
23 19
24 using api::permissions::Permissions; 20 using api::permissions::Permissions;
25 21
26 namespace permissions_api_helpers { 22 namespace permissions_api_helpers {
27 23
28 namespace { 24 namespace {
29 25
30 const char kDelimiter[] = "|"; 26 const char kDelimiter[] = "|";
31 const char kInvalidParameter[] = 27 const char kInvalidParameter[] =
(...skipping 28 matching lines...) Expand all
60 // to apps/extensions via the permissions API. 56 // to apps/extensions via the permissions API.
61 57
62 permissions->origins.reset(new std::vector<std::string>()); 58 permissions->origins.reset(new std::vector<std::string>());
63 URLPatternSet hosts = set->explicit_hosts(); 59 URLPatternSet hosts = set->explicit_hosts();
64 for (URLPatternSet::const_iterator i = hosts.begin(); i != hosts.end(); ++i) 60 for (URLPatternSet::const_iterator i = hosts.begin(); i != hosts.end(); ++i)
65 permissions->origins->push_back(i->GetAsString()); 61 permissions->origins->push_back(i->GetAsString());
66 62
67 return scoped_ptr<Permissions>(permissions); 63 return scoped_ptr<Permissions>(permissions);
68 } 64 }
69 65
70 scoped_refptr<const PermissionSet> UnpackPermissionSet( 66 scoped_ptr<const PermissionSet> UnpackPermissionSet(
71 const Permissions& permissions, 67 const Permissions& permissions,
72 bool allow_file_access, 68 bool allow_file_access,
73 std::string* error) { 69 std::string* error) {
74 DCHECK(error); 70 DCHECK(error);
75 APIPermissionSet apis; 71 APIPermissionSet apis;
76 std::vector<std::string>* permissions_list = permissions.permissions.get(); 72 std::vector<std::string>* permissions_list = permissions.permissions.get();
77 if (permissions_list) { 73 if (permissions_list) {
78 PermissionsInfo* info = PermissionsInfo::GetInstance(); 74 PermissionsInfo* info = PermissionsInfo::GetInstance();
79 for (std::vector<std::string>::iterator it = permissions_list->begin(); 75 for (std::vector<std::string>::iterator it = permissions_list->begin();
80 it != permissions_list->end(); ++it) { 76 it != permissions_list->end(); ++it) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 *error = ErrorUtils::FormatErrorMessage( 138 *error = ErrorUtils::FormatErrorMessage(
143 kInvalidOrigin, 139 kInvalidOrigin,
144 *it, 140 *it,
145 URLPattern::GetParseResultString(parse_result)); 141 URLPattern::GetParseResultString(parse_result));
146 return NULL; 142 return NULL;
147 } 143 }
148 origins.AddPattern(origin); 144 origins.AddPattern(origin);
149 } 145 }
150 } 146 }
151 147
152 return make_scoped_refptr( 148 return make_scoped_ptr(
153 new PermissionSet(apis, manifest_permissions, origins, URLPatternSet())); 149 new PermissionSet(apis, manifest_permissions, origins, URLPatternSet()));
154 } 150 }
155 151
156 } // namespace permissions_api_helpers 152 } // namespace permissions_api_helpers
157 } // namespace extensions 153 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698