summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrdevlin.cronin <rdevlin.cronin@chromium.org>2015-08-03 14:05:44 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-03 21:06:31 +0000
commit79559e3ce3f91939d6227f63cce13845a3e9b069 (patch)
treeb9ba29722dc1b4a2fa8558d4f6f207973f855971
parentac061e0d8e5c845c78bea4fa6ac5e9bf63d516e0 (diff)
downloadchromium_src-79559e3ce3f91939d6227f63cce13845a3e9b069.zip
chromium_src-79559e3ce3f91939d6227f63cce13845a3e9b069.tar.gz
chromium_src-79559e3ce3f91939d6227f63cce13845a3e9b069.tar.bz2
[Extensions UI] Adjust extension toolbar redesign surfacing bubble width
Per UI recommendations, adjust the extension toolbar redesign surfacing bubble's width and spacing to be a little more roomy. Also point the bubble at the full container, instead of the first action. BUG=512905 Review URL: https://codereview.chromium.org/1264813003 Cr-Commit-Position: refs/heads/master@{#341607}
-rw-r--r--chrome/app/resources/locale_settings.grd5
-rw-r--r--chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm28
-rw-r--r--chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.mm7
-rw-r--r--chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bubble_views.cc14
-rw-r--r--chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bubble_views.h2
-rw-r--r--chrome/browser/ui/views/toolbar/browser_actions_container.cc2
6 files changed, 31 insertions, 27 deletions
diff --git a/chrome/app/resources/locale_settings.grd b/chrome/app/resources/locale_settings.grd
index b9043db..efe330f 100644
--- a/chrome/app/resources/locale_settings.grd
+++ b/chrome/app/resources/locale_settings.grd
@@ -264,6 +264,11 @@
55
</message>
+ <!-- The width of the Extension Toolbar Redesign bubble in characters (See above). -->
+ <message name="IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS" use_name_for_id="true">
+ 55
+ </message>
+
<if expr="is_win or is_linux or chromeos">
<!-- The width of the ash/ChromeOS system tray menu in pixels. -->
<message name="IDS_SYSTEM_TRAY_MENU_BUBBLE_WIDTH_PIXELS" use_name_for_id="true">
diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
index fb45434..13c840e 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
@@ -165,7 +165,7 @@ const CGFloat kBrowserActionBubbleYOffset = 3.0;
// menu if no |anchorAction| is null.
- (ToolbarActionsBarBubbleMac*)createMessageBubble:
(scoped_ptr<ToolbarActionsBarBubbleDelegate>)delegate
- anchorAction:(ToolbarActionViewController*)anchorAction;
+ anchorToSelf:(BOOL)anchorToSelf;
// Called when the window for the active bubble is closing, and sets the active
// bubble to nil.
@@ -293,7 +293,7 @@ void ToolbarActionsBarBridge::ShowExtensionMessageBubble(
ExtensionMessageBubbleBridge* weak_bridge = bridge.get();
ToolbarActionsBarBubbleMac* bubble =
[controller_ createMessageBubble:bridge.Pass()
- anchorAction:anchor_action];
+ anchorToSelf:anchor_action != nil];
weak_bridge->SetBubble(bubble);
weak_bridge->controller()->Show(weak_bridge);
}
@@ -804,13 +804,11 @@ void ToolbarActionsBarBridge::ShowExtensionMessageBubble(
if (!activeBubble_ && // only show one bubble at a time
ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile(
browser_->profile())) {
- ToolbarActionViewController* anchorAction = [buttons_ count] > 0 ?
- [[self buttonAtIndex:0] viewController] : nullptr;
scoped_ptr<ToolbarActionsBarBubbleDelegate> delegate(
new ExtensionToolbarIconSurfacingBubbleDelegate(browser_->profile()));
ToolbarActionsBarBubbleMac* bubble =
[self createMessageBubble:delegate.Pass()
- anchorAction:anchorAction];
+ anchorToSelf:YES];
[bubble showWindow:nil];
}
[containerView_ setTrackingEnabled:NO];
@@ -898,9 +896,9 @@ void ToolbarActionsBarBridge::ShowExtensionMessageBubble(
- (NSPoint)popupPointForView:(NSView*)view
withBounds:(NSRect)bounds {
// Anchor point just above the center of the bottom.
- DCHECK([view isFlipped]);
- NSPoint anchor = NSMakePoint(NSMidX(bounds),
- NSMaxY(bounds) - kBrowserActionBubbleYOffset);
+ int y = [view isFlipped] ? NSMaxY(bounds) - kBrowserActionBubbleYOffset :
+ kBrowserActionBubbleYOffset;
+ NSPoint anchor = NSMakePoint(NSMidX(bounds), y);
// Convert the point to the container view's frame, and adjust for animation.
NSPoint anchorInContainer =
[containerView_ convertPoint:anchor fromView:view];
@@ -1032,16 +1030,12 @@ void ToolbarActionsBarBridge::ShowExtensionMessageBubble(
- (ToolbarActionsBarBubbleMac*)createMessageBubble:
(scoped_ptr<ToolbarActionsBarBubbleDelegate>)delegate
- anchorAction:(ToolbarActionViewController*)anchorAction {
+ anchorToSelf:(BOOL)anchorToSelf {
DCHECK_GE([buttons_ count], 0u);
- NSPoint anchor;
- if (anchorAction) {
- anchor = [self popupPointForId:anchorAction->GetId()];
- } else {
- NSView* wrenchButton = [[self toolbarController] wrenchButton];
- anchor = [self popupPointForView:wrenchButton
- withBounds:[wrenchButton bounds]];
- }
+ NSView* anchorView =
+ anchorToSelf ? containerView_ : [[self toolbarController] wrenchButton];
+ NSPoint anchor = [self popupPointForView:anchorView
+ withBounds:[anchorView bounds]];
anchor = [[containerView_ window] convertBaseToScreen:anchor];
activeBubble_ = [[ToolbarActionsBarBubbleMac alloc]
diff --git a/chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.mm b/chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.mm
index 06a1019..5e01460 100644
--- a/chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.mm
+++ b/chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.mm
@@ -19,6 +19,7 @@
namespace {
BOOL g_animations_enabled = false;
+CGFloat kMinWidth = 320.0;
}
@interface ToolbarActionsBarBubbleMac ()
@@ -220,9 +221,9 @@ BOOL g_animations_enabled = false;
if (learnMoreButton_)
buttonStripWidth += learnMoreSize.width + kButtonPadding;
- CGFloat headingWidth = headingSize.width + 50.0;
-
- CGFloat windowWidth = std::max(buttonStripWidth, headingWidth);
+ CGFloat headingWidth = headingSize.width;
+ CGFloat windowWidth =
+ std::max(std::max(kMinWidth, buttonStripWidth), headingWidth);
NSTextField* content =
[self addTextFieldWithString:delegate_->GetBodyText()
diff --git a/chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bubble_views.cc b/chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bubble_views.cc
index 6837ab4..c0ddf62 100644
--- a/chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bubble_views.cc
+++ b/chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bubble_views.cc
@@ -5,10 +5,12 @@
#include "chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bubble_views.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h"
+#include "chrome/grit/locale_settings.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/grid_layout.h"
+#include "ui/views/layout/layout_constants.h"
ExtensionToolbarIconSurfacingBubble::ExtensionToolbarIconSurfacingBubble(
views::View* anchor_view,
@@ -28,17 +30,16 @@ void ExtensionToolbarIconSurfacingBubble::Show() {
void ExtensionToolbarIconSurfacingBubble::Init() {
views::GridLayout* layout = new views::GridLayout(this);
+ layout->SetInsets(views::kPanelVertMargin, views::kPanelHorizMargin,
+ views::kPanelVertMargin, views::kPanelHorizMargin);
SetLayoutManager(layout);
- // Initialize a basic column set of |<padding> <content> <padding>|.
views::ColumnSet* columns = layout->AddColumnSet(0);
- columns->AddPaddingColumn(0, 10);
columns->AddColumn(views::GridLayout::LEADING,
views::GridLayout::LEADING,
1,
views::GridLayout::USE_PREF,
0,
0);
- columns->AddPaddingColumn(0, 10);
// Add a header.
layout->StartRow(0, 0);
@@ -48,8 +49,9 @@ void ExtensionToolbarIconSurfacingBubble::Init() {
ui::ResourceBundle::MediumFont));
heading_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
layout->AddView(heading_label);
- layout->AddPaddingRow(0, 10);
- int width = heading_label->GetPreferredSize().width();
+ layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing);
+ int width = views::Widget::GetLocalizedContentsWidth(
+ IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS);
// Add the content string.
layout->StartRow(0, 0);
@@ -58,7 +60,7 @@ void ExtensionToolbarIconSurfacingBubble::Init() {
content_label->SizeToFit(width);
content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
layout->AddView(content_label);
- layout->AddPaddingRow(0, 10);
+ layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing);
// Add a "got it" button.
layout->StartRow(0, 0);
diff --git a/chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bubble_views.h b/chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bubble_views.h
index ca23dd9..1dbb663 100644
--- a/chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bubble_views.h
+++ b/chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bubble_views.h
@@ -25,9 +25,11 @@ class ExtensionToolbarIconSurfacingBubble : public views::BubbleDelegateView,
void Show();
private:
+ // views::BubbleDelegateView:
void Init() override;
void OnWidgetDestroying(views::Widget* widget) override;
+ // views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
scoped_ptr<ToolbarActionsBarBubbleDelegate> delegate_;
diff --git a/chrome/browser/ui/views/toolbar/browser_actions_container.cc b/chrome/browser/ui/views/toolbar/browser_actions_container.cc
index fe36268..6213483 100644
--- a/chrome/browser/ui/views/toolbar/browser_actions_container.cc
+++ b/chrome/browser/ui/views/toolbar/browser_actions_container.cc
@@ -209,7 +209,7 @@ void BrowserActionsContainer::OnMouseEnteredToolbarActionView() {
browser_->profile())) {
ExtensionToolbarIconSurfacingBubble* bubble =
new ExtensionToolbarIconSurfacingBubble(
- toolbar_action_views_[0],
+ this,
make_scoped_ptr(new ExtensionToolbarIconSurfacingBubbleDelegate(
browser_->profile())));
views::BubbleDelegateView::CreateBubble(bubble);