diff options
author | rdevlin.cronin <rdevlin.cronin@chromium.org> | 2015-07-24 16:15:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-24 23:16:41 +0000 |
commit | 28201fd8a43169682638388c6203a1d71ff4bb22 (patch) | |
tree | 389a646dcdca1e5b2f106fa47d498f6d8dee9e13 | |
parent | a16338aab059480a3f120644c42aef5c03629f46 (diff) | |
download | chromium_src-28201fd8a43169682638388c6203a1d71ff4bb22.zip chromium_src-28201fd8a43169682638388c6203a1d71ff4bb22.tar.gz chromium_src-28201fd8a43169682638388c6203a1d71ff4bb22.tar.bz2 |
[Extensions UI] Update mac code for "info" setting
Update BrowserActionsContainerView to be able to highlight the container in
either the warning (yellow) or info (blue) colors.
BUG=512905
Review URL: https://codereview.chromium.org/1258693002
Cr-Commit-Position: refs/heads/master@{#340370}
3 files changed, 25 insertions, 11 deletions
diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h b/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h index 17fa3af..d775b10 100644 --- a/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h +++ b/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h @@ -8,8 +8,13 @@ #import <Cocoa/Cocoa.h> #include "base/mac/scoped_nsobject.h" +#include "base/memory/scoped_ptr.h" #import "ui/base/cocoa/tracking_area.h" +namespace ui { +struct NinePartImageIds; +} + // Sent when a user-initiated drag to resize the container is initiated. extern NSString* const kBrowserActionGrippyDragStartedNotification; @@ -96,9 +101,8 @@ class BrowserActionsContainerViewSizeDelegate { // to large. BOOL grippyPinned_; - // Whether the toolbar is currently highlighting its actions (in which case it - // is drawn with an orange background). - BOOL isHighlighting_; + // The nine-grid of the highlight to paint, if any. + scoped_ptr<ui::NinePartImageIds> highlight_; // A tracking area to receive mouseEntered events, if tracking is enabled. ui::ScopedCrTrackingArea trackingArea_; @@ -117,7 +121,7 @@ class BrowserActionsContainerViewSizeDelegate { - (void)setIsOverflow:(BOOL)isOverflow; // Sets whether or not the container is highlighting. -- (void)setIsHighlighting:(BOOL)isHighlighting; +- (void)setHighlight:(scoped_ptr<ui::NinePartImageIds>)highlight; // Resizes the container to the given ideal width, optionally animating. - (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate; diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm b/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm index 1fb201a..d437200 100644 --- a/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm +++ b/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm @@ -83,10 +83,9 @@ const CGFloat kMinimumContainerWidth = 3.0; - (void)drawRect:(NSRect)rect { [super drawRect:rect]; - if (isHighlighting_) { - ui::NinePartImageIds imageIds = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT); + if (highlight_) { ui::DrawNinePartImage( - [self bounds], imageIds, NSCompositeSourceOver, 1.0, true); + [self bounds], *highlight_, NSCompositeSourceOver, 1.0, true); } } @@ -167,9 +166,9 @@ const CGFloat kMinimumContainerWidth = 3.0; [super keyDown:theEvent]; } -- (void)setIsHighlighting:(BOOL)isHighlighting { - if (isHighlighting != isHighlighting_) { - isHighlighting_ = isHighlighting; +- (void)setHighlight:(scoped_ptr<ui::NinePartImageIds>)highlight { + if (highlight || highlight_) { + highlight_ = highlight.Pass(); [self setNeedsDisplay:YES]; } } diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm index c6e5147..a413727 100644 --- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm +++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm @@ -26,6 +26,7 @@ #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h" #include "grit/theme_resources.h" #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h" +#include "ui/base/cocoa/appkit_utils.h" NSString* const kBrowserActionVisibilityChangedNotification = @"BrowserActionVisibilityChangedNotification"; @@ -559,7 +560,17 @@ void ToolbarActionsBarBridge::ShowExtensionMessageBubble( if (![self updateContainerVisibility]) return; // Container is hidden; no need to update. - [containerView_ setIsHighlighting:toolbarActionsBar_->is_highlighting()]; + scoped_ptr<ui::NinePartImageIds> highlight; + if (toolbarActionsBar_->is_highlighting()) { + if (toolbarActionsBar_->highlight_type() == + extensions::ExtensionToolbarModel::HIGHLIGHT_INFO) + highlight.reset( + new ui::NinePartImageIds(IMAGE_GRID(IDR_TOOLBAR_ACTION_HIGHLIGHT))); + else + highlight.reset( + new ui::NinePartImageIds(IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT))); + } + [containerView_ setHighlight:highlight.Pass()]; std::vector<ToolbarActionViewController*> toolbar_actions = toolbarActionsBar_->GetActions(); |