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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/common/extensions/api/commands/commands_handler.h" | 9 #include "chrome/common/extensions/api/commands/commands_handler.h" |
10 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 // Read the page action |default_icon| (optional). | 87 // Read the page action |default_icon| (optional). |
88 // The |default_icon| value can be either dictionary {icon size -> icon path} | 88 // The |default_icon| value can be either dictionary {icon size -> icon path} |
89 // or non empty string value. | 89 // or non empty string value. |
90 if (dict->HasKey(keys::kPageActionDefaultIcon)) { | 90 if (dict->HasKey(keys::kPageActionDefaultIcon)) { |
91 const base::DictionaryValue* icons_value = NULL; | 91 const base::DictionaryValue* icons_value = NULL; |
92 std::string default_icon; | 92 std::string default_icon; |
93 if (dict->GetDictionary(keys::kPageActionDefaultIcon, &icons_value)) { | 93 if (dict->GetDictionary(keys::kPageActionDefaultIcon, &icons_value)) { |
| 94 int icon_sizes[extension_misc::kNumExtensionActionIconSizes]; |
| 95 for (size_t i = 0u; i < extension_misc::kNumExtensionActionIconSizes; ++i) |
| 96 icon_sizes[i] = extension_misc::kExtensionActionIconSizes[i].size; |
94 if (!manifest_handler_helpers::LoadIconsFromDictionary( | 97 if (!manifest_handler_helpers::LoadIconsFromDictionary( |
95 icons_value, | 98 icons_value, |
96 extension_misc::kExtensionActionIconSizes, | 99 icon_sizes, |
97 extension_misc::kNumExtensionActionIconSizes, | 100 extension_misc::kNumExtensionActionIconSizes, |
98 &result->default_icon, | 101 &result->default_icon, |
99 error)) { | 102 error)) { |
100 return scoped_ptr<ActionInfo>(); | 103 return scoped_ptr<ActionInfo>(); |
101 } | 104 } |
102 } else if (dict->GetString(keys::kPageActionDefaultIcon, &default_icon) && | 105 } else if (dict->GetString(keys::kPageActionDefaultIcon, &default_icon) && |
103 manifest_handler_helpers::NormalizeAndValidatePath( | 106 manifest_handler_helpers::NormalizeAndValidatePath( |
104 &default_icon)) { | 107 &default_icon)) { |
105 result->default_icon.Add(extension_misc::EXTENSION_ICON_ACTION, | 108 result->default_icon.Add(extension_misc::EXTENSION_ICON_ACTION, |
106 default_icon); | 109 default_icon); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 216 |
214 // static | 217 // static |
215 bool ActionInfo::IsVerboseInstallMessage(const Extension* extension) { | 218 bool ActionInfo::IsVerboseInstallMessage(const Extension* extension) { |
216 const ActionInfo* page_action_info = GetPageActionInfo(extension); | 219 const ActionInfo* page_action_info = GetPageActionInfo(extension); |
217 return page_action_info && | 220 return page_action_info && |
218 (CommandsInfo::GetPageActionCommand(extension) || | 221 (CommandsInfo::GetPageActionCommand(extension) || |
219 !page_action_info->default_icon.empty()); | 222 !page_action_info->default_icon.empty()); |
220 } | 223 } |
221 | 224 |
222 } // namespace extensions | 225 } // namespace extensions |
OLD | NEW |