OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/common/manifest_handler_helpers.h" | 5 #include "extensions/common/manifest_handler_helpers.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "extensions/common/constants.h" | |
13 #include "extensions/common/error_utils.h" | 14 #include "extensions/common/error_utils.h" |
14 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
15 #include "extensions/common/extension_icon_set.h" | 16 #include "extensions/common/extension_icon_set.h" |
16 #include "extensions/common/manifest_constants.h" | 17 #include "extensions/common/manifest_constants.h" |
17 | 18 |
18 namespace extensions { | 19 namespace extensions { |
19 | 20 |
20 namespace errors = manifest_errors; | 21 namespace errors = manifest_errors; |
21 | 22 |
22 namespace manifest_handler_helpers { | 23 namespace manifest_handler_helpers { |
(...skipping 11 matching lines...) Expand all Loading... | |
34 | 35 |
35 bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value, | 36 bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value, |
36 ExtensionIconSet* icons, | 37 ExtensionIconSet* icons, |
37 base::string16* error) { | 38 base::string16* error) { |
38 DCHECK(icons); | 39 DCHECK(icons); |
39 DCHECK(error); | 40 DCHECK(error); |
40 for (base::DictionaryValue::Iterator iterator(*icons_value); | 41 for (base::DictionaryValue::Iterator iterator(*icons_value); |
41 !iterator.IsAtEnd(); iterator.Advance()) { | 42 !iterator.IsAtEnd(); iterator.Advance()) { |
42 int size = 0; | 43 int size = 0; |
43 std::string icon_path; | 44 std::string icon_path; |
44 if (!base::StringToInt(iterator.key(), &size) || | 45 if (!base::StringToInt(iterator.key(), &size) || size <= 0 || |
46 size > extension_misc::EXTENSION_ICON_GIGANTOR * 4 || | |
45 !iterator.value().GetAsString(&icon_path) || | 47 !iterator.value().GetAsString(&icon_path) || |
46 !NormalizeAndValidatePath(&icon_path)) { | 48 !NormalizeAndValidatePath(&icon_path)) { |
47 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidIconPath, | 49 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidIconPath, |
Devlin
2016/01/22 23:41:56
We should add a separate error for these (invalid
Evan Stade
2016/01/23 02:28:37
Done.
| |
48 iterator.key()); | 50 iterator.key()); |
49 return false; | 51 return false; |
50 } | 52 } |
51 | 53 |
52 icons->Add(size, icon_path); | 54 icons->Add(size, icon_path); |
53 } | 55 } |
54 return true; | 56 return true; |
55 } | 57 } |
56 | 58 |
57 } // namespace manifest_handler_helpers | 59 } // namespace manifest_handler_helpers |
58 | 60 |
59 } // namespace extensions | 61 } // namespace extensions |
OLD | NEW |