OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/common/extensions/manifest_handlers/theme_handler.h" | 5 #include "chrome/common/extensions/manifest_handlers/theme_handler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 base::string16* error, | 25 base::string16* error, |
26 ThemeInfo* theme_info) { | 26 ThemeInfo* theme_info) { |
27 const base::DictionaryValue* images_value = NULL; | 27 const base::DictionaryValue* images_value = NULL; |
28 if (theme_value->GetDictionary(keys::kThemeImages, &images_value)) { | 28 if (theme_value->GetDictionary(keys::kThemeImages, &images_value)) { |
29 // Validate that the images are all strings. | 29 // Validate that the images are all strings. |
30 for (base::DictionaryValue::Iterator iter(*images_value); !iter.IsAtEnd(); | 30 for (base::DictionaryValue::Iterator iter(*images_value); !iter.IsAtEnd(); |
31 iter.Advance()) { | 31 iter.Advance()) { |
32 // The value may be a dictionary of scales and files paths. | 32 // The value may be a dictionary of scales and files paths. |
33 // Or the value may be a file path, in which case a scale | 33 // Or the value may be a file path, in which case a scale |
34 // of 100% is assumed. | 34 // of 100% is assumed. |
35 if (iter.value().IsType(base::Value::TYPE_DICTIONARY)) { | 35 if (iter.value().IsType(base::Value::Type::DICTIONARY)) { |
36 const base::DictionaryValue* inner_value = NULL; | 36 const base::DictionaryValue* inner_value = NULL; |
37 if (iter.value().GetAsDictionary(&inner_value)) { | 37 if (iter.value().GetAsDictionary(&inner_value)) { |
38 for (base::DictionaryValue::Iterator inner_iter(*inner_value); | 38 for (base::DictionaryValue::Iterator inner_iter(*inner_value); |
39 !inner_iter.IsAtEnd(); inner_iter.Advance()) { | 39 !inner_iter.IsAtEnd(); inner_iter.Advance()) { |
40 if (!inner_iter.value().IsType(base::Value::TYPE_STRING)) { | 40 if (!inner_iter.value().IsType(base::Value::Type::STRING)) { |
41 *error = base::ASCIIToUTF16(errors::kInvalidThemeImages); | 41 *error = base::ASCIIToUTF16(errors::kInvalidThemeImages); |
42 return false; | 42 return false; |
43 } | 43 } |
44 } | 44 } |
45 } else { | 45 } else { |
46 *error = base::ASCIIToUTF16(errors::kInvalidThemeImages); | 46 *error = base::ASCIIToUTF16(errors::kInvalidThemeImages); |
47 return false; | 47 return false; |
48 } | 48 } |
49 } else if (!iter.value().IsType(base::Value::TYPE_STRING)) { | 49 } else if (!iter.value().IsType(base::Value::Type::STRING)) { |
50 *error = base::ASCIIToUTF16(errors::kInvalidThemeImages); | 50 *error = base::ASCIIToUTF16(errors::kInvalidThemeImages); |
51 return false; | 51 return false; |
52 } | 52 } |
53 } | 53 } |
54 theme_info->theme_images_.reset(images_value->DeepCopy()); | 54 theme_info->theme_images_.reset(images_value->DeepCopy()); |
55 } | 55 } |
56 return true; | 56 return true; |
57 } | 57 } |
58 | 58 |
59 bool LoadColors(const base::DictionaryValue* theme_value, | 59 bool LoadColors(const base::DictionaryValue* theme_value, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 } | 215 } |
216 return true; | 216 return true; |
217 } | 217 } |
218 | 218 |
219 const std::vector<std::string> ThemeHandler::Keys() const { | 219 const std::vector<std::string> ThemeHandler::Keys() const { |
220 return SingleKey(keys::kTheme); | 220 return SingleKey(keys::kTheme); |
221 } | 221 } |
222 | 222 |
223 } // namespace extensions | 223 } // namespace extensions |
OLD | NEW |