| 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 if (!manifest_handler_helpers::LoadAllIconsFromDictionary( | 94 if (!manifest_handler_helpers::LoadIconsFromDictionary( |
| 95 icons_value, &result->default_icon, error)) { | 95 icons_value, &result->default_icon, error)) { |
| 96 return scoped_ptr<ActionInfo>(); | 96 return scoped_ptr<ActionInfo>(); |
| 97 } | 97 } |
| 98 } else if (dict->GetString(keys::kPageActionDefaultIcon, &default_icon) && | 98 } else if (dict->GetString(keys::kPageActionDefaultIcon, &default_icon) && |
| 99 manifest_handler_helpers::NormalizeAndValidatePath( | 99 manifest_handler_helpers::NormalizeAndValidatePath( |
| 100 &default_icon)) { | 100 &default_icon)) { |
| 101 // Choose the most optimistic (highest) icon density regardless of the | 101 // Choose the most optimistic (highest) icon density regardless of the |
| 102 // actual icon resolution, whatever that happens to be. Code elsewhere | 102 // actual icon resolution, whatever that happens to be. Code elsewhere |
| 103 // knows how to scale down to 19. | 103 // knows how to scale down to 19. |
| 104 result->default_icon.Add(extension_misc::EXTENSION_ICON_GIGANTOR, | 104 result->default_icon.Add(extension_misc::EXTENSION_ICON_GIGANTOR, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 // static | 213 // static |
| 214 bool ActionInfo::IsVerboseInstallMessage(const Extension* extension) { | 214 bool ActionInfo::IsVerboseInstallMessage(const Extension* extension) { |
| 215 const ActionInfo* page_action_info = GetPageActionInfo(extension); | 215 const ActionInfo* page_action_info = GetPageActionInfo(extension); |
| 216 return page_action_info && | 216 return page_action_info && |
| 217 (CommandsInfo::GetPageActionCommand(extension) || | 217 (CommandsInfo::GetPageActionCommand(extension) || |
| 218 !page_action_info->default_icon.empty()); | 218 !page_action_info->default_icon.empty()); |
| 219 } | 219 } |
| 220 | 220 |
| 221 } // namespace extensions | 221 } // namespace extensions |
| OLD | NEW |