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 "chrome/common/extensions/api/extension_action/action_info.h" | 5 #include "chrome/common/extensions/api/extension_action/action_info.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 std::unique_ptr<ActionInfo> result(new ActionInfo()); | 61 std::unique_ptr<ActionInfo> result(new ActionInfo()); |
62 | 62 |
63 if (extension->manifest_version() == 1) { | 63 if (extension->manifest_version() == 1) { |
64 // kPageActionIcons is obsolete, and used by very few extensions. Continue | 64 // kPageActionIcons is obsolete, and used by very few extensions. Continue |
65 // loading it, but only take the first icon as the default_icon path. | 65 // loading it, but only take the first icon as the default_icon path. |
66 const base::ListValue* icons = NULL; | 66 const base::ListValue* icons = NULL; |
67 if (dict->HasKey(keys::kPageActionIcons) && | 67 if (dict->HasKey(keys::kPageActionIcons) && |
68 dict->GetList(keys::kPageActionIcons, &icons)) { | 68 dict->GetList(keys::kPageActionIcons, &icons)) { |
69 base::ListValue::const_iterator iter = icons->begin(); | 69 base::ListValue::const_iterator iter = icons->begin(); |
70 std::string path; | 70 std::string path; |
71 if (iter == icons->end() || | 71 if (iter == icons->end() || !iter->GetAsString(&path) || |
72 !(*iter)->GetAsString(&path) || | |
73 !manifest_handler_helpers::NormalizeAndValidatePath(&path)) { | 72 !manifest_handler_helpers::NormalizeAndValidatePath(&path)) { |
74 *error = base::ASCIIToUTF16(errors::kInvalidPageActionIconPath); | 73 *error = base::ASCIIToUTF16(errors::kInvalidPageActionIconPath); |
75 return std::unique_ptr<ActionInfo>(); | 74 return std::unique_ptr<ActionInfo>(); |
76 } | 75 } |
77 // Extension icons were 19 DIP when kPageActionIcons was supported. | 76 // Extension icons were 19 DIP when kPageActionIcons was supported. |
78 result->default_icon.Add(19, path); | 77 result->default_icon.Add(19, path); |
79 } | 78 } |
80 | 79 |
81 std::string id; | 80 std::string id; |
82 if (dict->HasKey(keys::kPageActionId)) { | 81 if (dict->HasKey(keys::kPageActionId)) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 216 |
218 // static | 217 // static |
219 bool ActionInfo::IsVerboseInstallMessage(const Extension* extension) { | 218 bool ActionInfo::IsVerboseInstallMessage(const Extension* extension) { |
220 const ActionInfo* page_action_info = GetPageActionInfo(extension); | 219 const ActionInfo* page_action_info = GetPageActionInfo(extension); |
221 return page_action_info && | 220 return page_action_info && |
222 (CommandsInfo::GetPageActionCommand(extension) || | 221 (CommandsInfo::GetPageActionCommand(extension) || |
223 !page_action_info->default_icon.empty()); | 222 !page_action_info->default_icon.empty()); |
224 } | 223 } |
225 | 224 |
226 } // namespace extensions | 225 } // namespace extensions |
OLD | NEW |