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

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

Issue 2816513002: Revert of Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
56 for (base::ListValue::iterator iter = args->begin(); iter != args->end(); 56 for (base::ListValue::iterator iter = args->begin(); iter != args->end();
57 ++iter, ++index) { 57 ++iter, ++index) {
58 if (iter->IsType(base::Value::Type::BINARY)) { 58 if ((*iter)->IsType(base::Value::Type::BINARY)) {
59 base::Value* binary = NULL; 59 base::Value* binary = NULL;
60 if (args->GetBinary(index, &binary)) 60 if (args->GetBinary(index, &binary))
61 args->Set(index, ConvertBinaryToBase64(binary).release()); 61 args->Set(index, ConvertBinaryToBase64(binary).release());
62 } else if (iter->IsType(base::Value::Type::LIST)) { 62 } else if ((*iter)->IsType(base::Value::Type::LIST)) {
63 base::ListValue* list; 63 base::ListValue* list;
64 iter->GetAsList(&list); 64 (*iter)->GetAsList(&list);
65 ConvertBinaryListElementsToBase64(list); 65 ConvertBinaryListElementsToBase64(list);
66 } else if (iter->IsType(base::Value::Type::DICTIONARY)) { 66 } else if ((*iter)->IsType(base::Value::Type::DICTIONARY)) {
67 base::DictionaryValue* dict; 67 base::DictionaryValue* dict;
68 iter->GetAsDictionary(&dict); 68 (*iter)->GetAsDictionary(&dict);
69 ConvertBinaryDictionaryValuesToBase64(dict); 69 ConvertBinaryDictionaryValuesToBase64(dict);
70 } 70 }
71 } 71 }
72 } 72 }
73 73
74 // Parses through |dict| replacing any BinaryValues with base64 encoded 74 // Parses through |dict| replacing any BinaryValues with base64 encoded
75 // StringValues. Recurses over any nested DictionaryValues, and calls 75 // StringValues. Recurses over any nested DictionaryValues, and calls
76 // ConvertBinaryListElementsToBase64 for any nested ListValues. 76 // ConvertBinaryListElementsToBase64 for any nested ListValues.
77 void ConvertBinaryDictionaryValuesToBase64(base::DictionaryValue* dict) { 77 void ConvertBinaryDictionaryValuesToBase64(base::DictionaryValue* dict) {
78 for (base::DictionaryValue::Iterator iter(*dict); !iter.IsAtEnd(); 78 for (base::DictionaryValue::Iterator iter(*dict); !iter.IsAtEnd();
(...skipping 139 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 | « dbus/values_util.cc ('k') | extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698