Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Unified Diff: chrome/browser/extensions/extension_action.cc

Issue 1131443006: [Extensions UI] Add a placeholder icon for extensions in the toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finnur's Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_action.h ('k') | extensions/browser/extension_icon_placeholder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_action.cc
diff --git a/chrome/browser/extensions/extension_action.cc b/chrome/browser/extensions/extension_action.cc
index d543784223f2a87101faea41075a88428498fa23..f1c1c54bbcb5380a5e48e57643560b441d47c4c5 100644
--- a/chrome/browser/extensions/extension_action.cc
+++ b/chrome/browser/extensions/extension_action.cc
@@ -11,8 +11,10 @@
#include "chrome/common/badge_util.h"
#include "chrome/common/icon_with_badge_image_source.h"
#include "extensions/browser/extension_icon_image.h"
+#include "extensions/browser/extension_icon_placeholder.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_icon_set.h"
+#include "extensions/common/feature_switch.h"
#include "extensions/common/manifest_handlers/icons_handler.h"
#include "grit/theme_resources.h"
#include "grit/ui_resources.h"
@@ -103,7 +105,9 @@ const int ExtensionAction::kPageActionIconMaxSize =
ExtensionAction::ExtensionAction(const extensions::Extension& extension,
extensions::ActionInfo::Type action_type,
const extensions::ActionInfo& manifest_data)
- : extension_id_(extension.id()), action_type_(action_type) {
+ : extension_id_(extension.id()),
+ extension_name_(extension.name()),
+ action_type_(action_type) {
// Page/script actions are hidden/disabled by default, and browser actions are
// visible/enabled by default.
SetIsVisible(kDefaultTabId,
@@ -282,7 +286,18 @@ extensions::IconImage* ExtensionAction::LoadDefaultIconImage(
gfx::Image ExtensionAction::GetDefaultIconImage() const {
// If we have a default icon, it should be loaded before trying to use it.
DCHECK(!default_icon_image_ == !default_icon_);
- return default_icon_image_ ? default_icon_image_->image() : GetDefaultIcon();
+ if (default_icon_image_)
+ return default_icon_image_->image();
+
+ // If the extension action redesign is enabled, we use a special placeholder
+ // icon (with the first letter of the extension name) rather than the default
+ // (puzzle piece).
+ if (extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) {
+ return extensions::ExtensionIconPlaceholder::CreateImage(
+ extension_misc::EXTENSION_ICON_ACTION, extension_name_);
+ }
+
+ return GetDefaultIcon();
}
bool ExtensionAction::HasPopupUrl(int tab_id) const {
« no previous file with comments | « chrome/browser/extensions/extension_action.h ('k') | extensions/browser/extension_icon_placeholder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698