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

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

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 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
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 23 matching lines...) Expand all
34 namespace extensions { 34 namespace extensions {
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::StringValue> ConvertBinaryToBase64( 44 std::unique_ptr<base::Value> ConvertBinaryToBase64(base::BinaryValue* binary) {
45 base::BinaryValue* binary) {
46 std::string binary_data = std::string(binary->GetBuffer(), binary->GetSize()); 45 std::string binary_data = std::string(binary->GetBuffer(), binary->GetSize());
47 std::string data64; 46 std::string data64;
48 base::Base64Encode(binary_data, &data64); 47 base::Base64Encode(binary_data, &data64);
49 return std::unique_ptr<base::StringValue>(new base::StringValue(data64)); 48 return std::unique_ptr<base::Value>(new base::Value(data64));
50 } 49 }
51 50
52 // Parses through |args| replacing any BinaryValues with base64 encoded 51 // Parses through |args| replacing any BinaryValues with base64 encoded
53 // StringValues. Recurses over any nested ListValues, and calls 52 // StringValues. Recurses over any nested ListValues, and calls
54 // ConvertBinaryDictionaryValuesToBase64 for any nested DictionaryValues. 53 // ConvertBinaryDictionaryValuesToBase64 for any nested DictionaryValues.
55 void ConvertBinaryListElementsToBase64(base::ListValue* args) { 54 void ConvertBinaryListElementsToBase64(base::ListValue* args) {
56 size_t index = 0; 55 size_t index = 0;
57 for (base::ListValue::iterator iter = args->begin(); iter != args->end(); 56 for (base::ListValue::iterator iter = args->begin(); iter != args->end();
58 ++iter, ++index) { 57 ++iter, ++index) {
59 if ((*iter)->IsType(base::Value::Type::BINARY)) { 58 if ((*iter)->IsType(base::Value::Type::BINARY)) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 218
220 std::unique_ptr<base::ListValue> rules_value(new base::ListValue()); 219 std::unique_ptr<base::ListValue> rules_value(new base::ListValue());
221 for (const auto& rule : rules) 220 for (const auto& rule : rules)
222 rules_value->Append(rule->ToValue()); 221 rules_value->Append(rule->ToValue());
223 SetResult(std::move(rules_value)); 222 SetResult(std::move(rules_value));
224 223
225 return true; 224 return true;
226 } 225 }
227 226
228 } // namespace extensions 227 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698