| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 icons_value, | 98 icons_value, |
| 99 icon_sizes, | 99 icon_sizes, |
| 100 extension_misc::kNumExtensionActionIconSizes, | 100 extension_misc::kNumExtensionActionIconSizes, |
| 101 &result->default_icon, | 101 &result->default_icon, |
| 102 error)) { | 102 error)) { |
| 103 return scoped_ptr<ActionInfo>(); | 103 return scoped_ptr<ActionInfo>(); |
| 104 } | 104 } |
| 105 } else if (dict->GetString(keys::kPageActionDefaultIcon, &default_icon) && | 105 } else if (dict->GetString(keys::kPageActionDefaultIcon, &default_icon) && |
| 106 manifest_handler_helpers::NormalizeAndValidatePath( | 106 manifest_handler_helpers::NormalizeAndValidatePath( |
| 107 &default_icon)) { | 107 &default_icon)) { |
| 108 result->default_icon.Add(extension_misc::EXTENSION_ICON_ACTION, | 108 // Choose the most optimistic (highest) icon density - e.g. 38 not 19 - |
| 109 // regardless of the actual icon resolution, whatever that happens to be. |
| 110 // Code elsewhere knows how to scale 38 down to 19. |
| 111 result->default_icon.Add(extension_misc::EXTENSION_ICON_ACTION * |
| 112 extension_misc::kNumExtensionActionIconSizes, |
| 109 default_icon); | 113 default_icon); |
| 110 } else { | 114 } else { |
| 111 *error = base::ASCIIToUTF16(errors::kInvalidPageActionIconPath); | 115 *error = base::ASCIIToUTF16(errors::kInvalidPageActionIconPath); |
| 112 return scoped_ptr<ActionInfo>(); | 116 return scoped_ptr<ActionInfo>(); |
| 113 } | 117 } |
| 114 } | 118 } |
| 115 | 119 |
| 116 // Read the page action title from |default_title| if present, |name| if not | 120 // Read the page action title from |default_title| if present, |name| if not |
| 117 // (both optional). | 121 // (both optional). |
| 118 if (dict->HasKey(keys::kPageActionDefaultTitle)) { | 122 if (dict->HasKey(keys::kPageActionDefaultTitle)) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 220 |
| 217 // static | 221 // static |
| 218 bool ActionInfo::IsVerboseInstallMessage(const Extension* extension) { | 222 bool ActionInfo::IsVerboseInstallMessage(const Extension* extension) { |
| 219 const ActionInfo* page_action_info = GetPageActionInfo(extension); | 223 const ActionInfo* page_action_info = GetPageActionInfo(extension); |
| 220 return page_action_info && | 224 return page_action_info && |
| 221 (CommandsInfo::GetPageActionCommand(extension) || | 225 (CommandsInfo::GetPageActionCommand(extension) || |
| 222 !page_action_info->default_icon.empty()); | 226 !page_action_info->default_icon.empty()); |
| 223 } | 227 } |
| 224 | 228 |
| 225 } // namespace extensions | 229 } // namespace extensions |
| OLD | NEW |