| 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() || !iter->GetAsString(&path) || | 71 if (iter == icons->end() || |
| 72 !(*iter)->GetAsString(&path) || |
| 72 !manifest_handler_helpers::NormalizeAndValidatePath(&path)) { | 73 !manifest_handler_helpers::NormalizeAndValidatePath(&path)) { |
| 73 *error = base::ASCIIToUTF16(errors::kInvalidPageActionIconPath); | 74 *error = base::ASCIIToUTF16(errors::kInvalidPageActionIconPath); |
| 74 return std::unique_ptr<ActionInfo>(); | 75 return std::unique_ptr<ActionInfo>(); |
| 75 } | 76 } |
| 76 // Extension icons were 19 DIP when kPageActionIcons was supported. | 77 // Extension icons were 19 DIP when kPageActionIcons was supported. |
| 77 result->default_icon.Add(19, path); | 78 result->default_icon.Add(19, path); |
| 78 } | 79 } |
| 79 | 80 |
| 80 std::string id; | 81 std::string id; |
| 81 if (dict->HasKey(keys::kPageActionId)) { | 82 if (dict->HasKey(keys::kPageActionId)) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 217 |
| 217 // static | 218 // static |
| 218 bool ActionInfo::IsVerboseInstallMessage(const Extension* extension) { | 219 bool ActionInfo::IsVerboseInstallMessage(const Extension* extension) { |
| 219 const ActionInfo* page_action_info = GetPageActionInfo(extension); | 220 const ActionInfo* page_action_info = GetPageActionInfo(extension); |
| 220 return page_action_info && | 221 return page_action_info && |
| 221 (CommandsInfo::GetPageActionCommand(extension) || | 222 (CommandsInfo::GetPageActionCommand(extension) || |
| 222 !page_action_info->default_icon.empty()); | 223 !page_action_info->default_icon.empty()); |
| 223 } | 224 } |
| 224 | 225 |
| 225 } // namespace extensions | 226 } // namespace extensions |
| OLD | NEW |