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

Unified Diff: chrome/browser/ui/cocoa/extensions/browser_action_button.mm

Issue 10963016: Fix disabled browser action appearance on Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a Created 8 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/extensions/browser_action_button.mm
diff --git a/chrome/browser/ui/cocoa/extensions/browser_action_button.mm b/chrome/browser/ui/cocoa/extensions/browser_action_button.mm
index 93fa87978383e3616d80a6c7d7c75118e876a9a2..92e1c4faeffbf6f632f970bb610d2962d4478f75 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_action_button.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_action_button.mm
@@ -24,6 +24,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas_skia_paint.h"
#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
#include "ui/gfx/size.h"
@@ -135,6 +136,8 @@ class ExtensionActionIconFactoryBridge
forButtonState:image_button_cell::kHoverState];
[cell setImageID:IDR_BROWSER_ACTION_P
forButtonState:image_button_cell::kPressedState];
+ [cell setImageID:IDR_BROWSER_ACTION
+ forButtonState:image_button_cell::kDisabledState];
[self setTitle:@""];
[self setButtonType:NSMomentaryChangeButton];
@@ -247,16 +250,19 @@ class ExtensionActionIconFactoryBridge
[self setToolTip:base::SysUTF8ToNSString(tooltip)];
}
- gfx::Image image = iconFactoryBridge_->GetIcon(tabId_);
-
- if (!image.IsEmpty())
- [self setImage:image.ToNSImage()];
-
- [[self cell] setTabId:tabId_];
+ gfx::ImageSkia image = iconFactoryBridge_->GetIcon(tabId_).AsImageSkia();
bool enabled = extension_->browser_action()->GetIsVisible(tabId_);
+ if (!image.isNull()) {
+ if (!enabled)
+ image = gfx::ImageSkiaOperations::CreateTransparentImage(image, 0.4);
+ [self setImage:gfx::Image(image).ToNSImage()];
Nico 2012/09/21 02:02:02 It looks like we're round-tripping to skia and bac
Yoyo Zhou 2012/09/21 18:04:59 Ah, I didn't realize this was something to avoid.
+ }
+
[self setEnabled:enabled ? YES : NO];
Nico 2012/09/21 02:02:02 just "enabled" is enough. Drop the ?YES:NO.
Yoyo Zhou 2012/09/21 18:04:59 Done.
+ [[self cell] setTabId:tabId_];
+
[self setNeedsDisplay:YES];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698