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

Side by Side Diff: extensions/browser/api/declarative/declarative_api.cc

Issue 2841623003: Remove base::Value::Get{Buffer,Size} (Closed)
Patch Set: std::vector::assign instead of std::vector::operator= Created 3 years, 8 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 "extensions/browser/api/declarative/declarative_api.h" 5 #include "extensions/browser/api/declarative/declarative_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 24 matching lines...) Expand all
35 35
36 namespace { 36 namespace {
37 37
38 const char kDeclarativeEventPrefix[] = "declarative"; 38 const char kDeclarativeEventPrefix[] = "declarative";
39 39
40 void ConvertBinaryDictionaryValuesToBase64(base::DictionaryValue* dict); 40 void ConvertBinaryDictionaryValuesToBase64(base::DictionaryValue* dict);
41 41
42 // Encodes |binary| as base64 and returns a new StringValue populated with the 42 // Encodes |binary| as base64 and returns a new StringValue populated with the
43 // encoded string. 43 // encoded string.
44 std::unique_ptr<base::Value> ConvertBinaryToBase64(base::Value* binary) { 44 std::unique_ptr<base::Value> ConvertBinaryToBase64(base::Value* binary) {
45 std::string binary_data = std::string(binary->GetBuffer(), binary->GetSize()); 45 std::string binary_data(binary->GetBlob().data(), binary->GetBlob().size());
46 std::string data64; 46 std::string data64;
47 base::Base64Encode(binary_data, &data64); 47 base::Base64Encode(binary_data, &data64);
48 return std::unique_ptr<base::Value>(new base::Value(data64)); 48 return std::unique_ptr<base::Value>(new base::Value(data64));
49 } 49 }
50 50
51 // Parses through |args| replacing any BinaryValues with base64 encoded 51 // Parses through |args| replacing any BinaryValues with base64 encoded
52 // StringValues. Recurses over any nested ListValues, and calls 52 // StringValues. Recurses over any nested ListValues, and calls
53 // ConvertBinaryDictionaryValuesToBase64 for any nested DictionaryValues. 53 // ConvertBinaryDictionaryValuesToBase64 for any nested DictionaryValues.
54 void ConvertBinaryListElementsToBase64(base::ListValue* args) { 54 void ConvertBinaryListElementsToBase64(base::ListValue* args) {
55 size_t index = 0; 55 size_t index = 0;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 std::unique_ptr<base::ListValue> rules_value(new base::ListValue()); 219 std::unique_ptr<base::ListValue> rules_value(new base::ListValue());
220 for (const auto& rule : rules) 220 for (const auto& rule : rules)
221 rules_value->Append(rule->ToValue()); 221 rules_value->Append(rule->ToValue());
222 SetResult(std::move(rules_value)); 222 SetResult(std::move(rules_value));
223 223
224 return true; 224 return true;
225 } 225 }
226 226
227 } // namespace extensions 227 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_message_util.cc ('k') | extensions/browser/api/socket/socket_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698