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

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

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 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/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"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 permissions->permissions.reset(new std::vector<std::string>()); 45 permissions->permissions.reset(new std::vector<std::string>());
46 for (APIPermissionSet::const_iterator i = set->apis().begin(); 46 for (APIPermissionSet::const_iterator i = set->apis().begin();
47 i != set->apis().end(); ++i) { 47 i != set->apis().end(); ++i) {
48 scoped_ptr<base::Value> value(i->ToValue()); 48 scoped_ptr<base::Value> value(i->ToValue());
49 if (!value) { 49 if (!value) {
50 permissions->permissions->push_back(i->name()); 50 permissions->permissions->push_back(i->name());
51 } else { 51 } else {
52 std::string name(i->name()); 52 std::string name(i->name());
53 std::string json; 53 std::string json;
54 base::JSONWriter::Write(value.get(), &json); 54 base::JSONWriter::Write(*value, &json);
55 permissions->permissions->push_back(name + kDelimiter + json); 55 permissions->permissions->push_back(name + kDelimiter + json);
56 } 56 }
57 } 57 }
58 58
59 // TODO(rpaquay): We currently don't expose manifest permissions 59 // TODO(rpaquay): We currently don't expose manifest permissions
60 // to apps/extensions via the permissions API. 60 // to apps/extensions via the permissions API.
61 61
62 permissions->origins.reset(new std::vector<std::string>()); 62 permissions->origins.reset(new std::vector<std::string>());
63 URLPatternSet hosts = set->explicit_hosts(); 63 URLPatternSet hosts = set->explicit_hosts();
64 for (URLPatternSet::const_iterator i = hosts.begin(); i != hosts.end(); ++i) 64 for (URLPatternSet::const_iterator i = hosts.begin(); i != hosts.end(); ++i)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 origins.AddPattern(origin); 148 origins.AddPattern(origin);
149 } 149 }
150 } 150 }
151 151
152 return scoped_refptr<PermissionSet>( 152 return scoped_refptr<PermissionSet>(
153 new PermissionSet(apis, manifest_permissions, origins, URLPatternSet())); 153 new PermissionSet(apis, manifest_permissions, origins, URLPatternSet()));
154 } 154 }
155 155
156 } // namespace permissions_api_helpers 156 } // namespace permissions_api_helpers
157 } // namespace extensions 157 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698