| 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/browser/extensions/extension_action.h" | 5 #include "chrome/browser/extensions/extension_action.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/base64.h" | 10 #include "base/base64.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "extensions/browser/extension_icon_image.h" | 13 #include "extensions/browser/extension_icon_image.h" |
| 13 #include "extensions/browser/extension_icon_placeholder.h" | 14 #include "extensions/browser/extension_icon_placeholder.h" |
| 14 #include "extensions/common/constants.h" | 15 #include "extensions/common/constants.h" |
| 15 #include "extensions/common/extension_icon_set.h" | 16 #include "extensions/common/extension_icon_set.h" |
| 16 #include "extensions/common/feature_switch.h" | 17 #include "extensions/common/feature_switch.h" |
| 17 #include "extensions/common/manifest_handlers/icons_handler.h" | 18 #include "extensions/common/manifest_handlers/icons_handler.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 bool ExtensionAction::HasIsVisible(int tab_id) const { | 283 bool ExtensionAction::HasIsVisible(int tab_id) const { |
| 283 return HasValue(is_visible_, tab_id); | 284 return HasValue(is_visible_, tab_id); |
| 284 } | 285 } |
| 285 | 286 |
| 286 bool ExtensionAction::HasIcon(int tab_id) const { | 287 bool ExtensionAction::HasIcon(int tab_id) const { |
| 287 return HasValue(icon_, tab_id); | 288 return HasValue(icon_, tab_id); |
| 288 } | 289 } |
| 289 | 290 |
| 290 void ExtensionAction::SetDefaultIconForTest( | 291 void ExtensionAction::SetDefaultIconForTest( |
| 291 scoped_ptr<ExtensionIconSet> default_icon) { | 292 scoped_ptr<ExtensionIconSet> default_icon) { |
| 292 default_icon_ = default_icon.Pass(); | 293 default_icon_ = std::move(default_icon); |
| 293 } | 294 } |
| 294 | 295 |
| 295 void ExtensionAction::Populate(const extensions::Extension& extension, | 296 void ExtensionAction::Populate(const extensions::Extension& extension, |
| 296 const extensions::ActionInfo& manifest_data) { | 297 const extensions::ActionInfo& manifest_data) { |
| 297 // If the manifest doesn't specify a title, set it to |extension|'s name. | 298 // If the manifest doesn't specify a title, set it to |extension|'s name. |
| 298 const std::string& title = | 299 const std::string& title = |
| 299 !manifest_data.default_title.empty() ? manifest_data.default_title : | 300 !manifest_data.default_title.empty() ? manifest_data.default_title : |
| 300 extension.name(); | 301 extension.name(); |
| 301 SetTitle(kDefaultTabId, title); | 302 SetTitle(kDefaultTabId, title); |
| 302 SetPopupUrl(kDefaultTabId, manifest_data.default_popup_url); | 303 SetPopupUrl(kDefaultTabId, manifest_data.default_popup_url); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 323 // If there is a default icon, the icon width will be set depending on our | 324 // If there is a default icon, the icon width will be set depending on our |
| 324 // action type. | 325 // action type. |
| 325 if (default_icon_) | 326 if (default_icon_) |
| 326 return ActionIconSize(); | 327 return ActionIconSize(); |
| 327 | 328 |
| 328 // If no icon has been set and there is no default icon, we need favicon | 329 // If no icon has been set and there is no default icon, we need favicon |
| 329 // width. | 330 // width. |
| 330 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 331 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 331 IDR_EXTENSIONS_FAVICON).Width(); | 332 IDR_EXTENSIONS_FAVICON).Width(); |
| 332 } | 333 } |
| OLD | NEW |