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