OLD | NEW |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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)); |
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 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |