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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 // Parses through |dict| replacing any BinaryValues with base64 encoded | 124 // Parses through |dict| replacing any BinaryValues with base64 encoded |
125 // StringValues. Recurses over any nested DictionaryValues, and calls | 125 // StringValues. Recurses over any nested DictionaryValues, and calls |
126 // ConvertBinaryListElementsToBase64 for any nested ListValues. | 126 // ConvertBinaryListElementsToBase64 for any nested ListValues. |
127 void ConvertBinaryDictionaryValuesToBase64(base::DictionaryValue* dict) { | 127 void ConvertBinaryDictionaryValuesToBase64(base::DictionaryValue* dict) { |
128 for (base::DictionaryValue::Iterator iter(*dict); !iter.IsAtEnd(); | 128 for (base::DictionaryValue::Iterator iter(*dict); !iter.IsAtEnd(); |
129 iter.Advance()) { | 129 iter.Advance()) { |
130 if (iter.value().IsType(base::Value::Type::BINARY)) { | 130 if (iter.value().IsType(base::Value::Type::BINARY)) { |
131 base::Value* binary = NULL; | 131 base::Value* binary = NULL; |
132 if (dict->GetBinary(iter.key(), &binary)) | 132 if (dict->GetBinary(iter.key(), &binary)) |
133 dict->Set(iter.key(), ConvertBinaryToBase64(binary).release()); | 133 dict->Set(iter.key(), ConvertBinaryToBase64(binary)); |
134 } else if (iter.value().IsType(base::Value::Type::LIST)) { | 134 } else if (iter.value().IsType(base::Value::Type::LIST)) { |
135 const base::ListValue* list; | 135 const base::ListValue* list; |
136 iter.value().GetAsList(&list); | 136 iter.value().GetAsList(&list); |
137 ConvertBinaryListElementsToBase64(const_cast<base::ListValue*>(list)); | 137 ConvertBinaryListElementsToBase64(const_cast<base::ListValue*>(list)); |
138 } else if (iter.value().IsType(base::Value::Type::DICTIONARY)) { | 138 } else if (iter.value().IsType(base::Value::Type::DICTIONARY)) { |
139 const base::DictionaryValue* dict; | 139 const base::DictionaryValue* dict; |
140 iter.value().GetAsDictionary(&dict); | 140 iter.value().GetAsDictionary(&dict); |
141 ConvertBinaryDictionaryValuesToBase64( | 141 ConvertBinaryDictionaryValuesToBase64( |
142 const_cast<base::DictionaryValue*>(dict)); | 142 const_cast<base::DictionaryValue*>(dict)); |
143 } | 143 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 type = kDeclarativeWebRequestWebviewGetRules; | 330 type = kDeclarativeWebRequestWebviewGetRules; |
331 break; | 331 break; |
332 case DeclarativeAPIType::kUnknown: | 332 case DeclarativeAPIType::kUnknown: |
333 NOTREACHED(); | 333 NOTREACHED(); |
334 return; | 334 return; |
335 } | 335 } |
336 RecordUMAHelper(type); | 336 RecordUMAHelper(type); |
337 } | 337 } |
338 | 338 |
339 } // namespace extensions | 339 } // namespace extensions |
OLD | NEW |