| 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 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 249 } |
| 250 return default_icon_image_.get(); | 250 return default_icon_image_.get(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 gfx::Image ExtensionAction::GetDefaultIconImage() const { | 253 gfx::Image ExtensionAction::GetDefaultIconImage() const { |
| 254 // If we have a default icon, it should be loaded before trying to use it. | 254 // If we have a default icon, it should be loaded before trying to use it. |
| 255 DCHECK(!default_icon_image_ == !default_icon_); | 255 DCHECK(!default_icon_image_ == !default_icon_); |
| 256 if (default_icon_image_) | 256 if (default_icon_image_) |
| 257 return default_icon_image_->image(); | 257 return default_icon_image_->image(); |
| 258 | 258 |
| 259 if (placeholder_icon_image_.IsEmpty()) { | 259 // If the extension action redesign is enabled, we use a special placeholder |
| 260 // If the extension action redesign is enabled, we use a special placeholder | 260 // icon (with the first letter of the extension name) rather than the default |
| 261 // icon (with the first letter of the extension name) rather than the | 261 // (puzzle piece). |
| 262 // default (puzzle piece). | 262 if (extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) { |
| 263 if (extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) { | 263 return extensions::ExtensionIconPlaceholder::CreateImage( |
| 264 placeholder_icon_image_ = | 264 extension_misc::EXTENSION_ICON_ACTION, extension_name_); |
| 265 extensions::ExtensionIconPlaceholder::CreateImage( | |
| 266 extension_misc::EXTENSION_ICON_ACTION, extension_name_); | |
| 267 } else { | |
| 268 placeholder_icon_image_ = GetDefaultIcon(); | |
| 269 } | |
| 270 } | 265 } |
| 271 | 266 |
| 272 return placeholder_icon_image_; | 267 return GetDefaultIcon(); |
| 273 } | 268 } |
| 274 | 269 |
| 275 bool ExtensionAction::HasPopupUrl(int tab_id) const { | 270 bool ExtensionAction::HasPopupUrl(int tab_id) const { |
| 276 return HasValue(popup_url_, tab_id); | 271 return HasValue(popup_url_, tab_id); |
| 277 } | 272 } |
| 278 | 273 |
| 279 bool ExtensionAction::HasTitle(int tab_id) const { | 274 bool ExtensionAction::HasTitle(int tab_id) const { |
| 280 return HasValue(title_, tab_id); | 275 return HasValue(title_, tab_id); |
| 281 } | 276 } |
| 282 | 277 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 // If there is a default icon, the icon width will be set depending on our | 349 // If there is a default icon, the icon width will be set depending on our |
| 355 // action type. | 350 // action type. |
| 356 if (default_icon_) | 351 if (default_icon_) |
| 357 return GetIconSizeForType(action_type()); | 352 return GetIconSizeForType(action_type()); |
| 358 | 353 |
| 359 // If no icon has been set and there is no default icon, we need favicon | 354 // If no icon has been set and there is no default icon, we need favicon |
| 360 // width. | 355 // width. |
| 361 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 356 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 362 IDR_EXTENSIONS_FAVICON).Width(); | 357 IDR_EXTENSIONS_FAVICON).Width(); |
| 363 } | 358 } |
| OLD | NEW |