summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrdevlin.cronin <rdevlin.cronin@chromium.org>2015-07-27 10:57:26 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-27 17:57:50 +0000
commit13086c76841fd36191e942004465a008fb2c82b2 (patch)
tree9f86e8a175d59e8fffd51837c0cc207ab9bc7239
parent0a4acdc9aceeac0a0dd019a660e33317846e3416 (diff)
downloadchromium_src-13086c76841fd36191e942004465a008fb2c82b2.zip
chromium_src-13086c76841fd36191e942004465a008fb2c82b2.tar.gz
chromium_src-13086c76841fd36191e942004465a008fb2c82b2.tar.bz2
[Extensions UI] Change the wrench menu color when overflowed action wants to act
Change the wrench menu color to be blue when an overflowed action wants to run, unless there is a present error. This is in line with the new UI for an extension desire to act, outlined in the bug. BUG=417441 Review URL: https://codereview.chromium.org/1254583004 Cr-Commit-Position: refs/heads/master@{#340498}
-rw-r--r--chrome/app/theme/default_100_percent/common/browser_tools_bar_info.pngbin0 -> 225 bytes
-rw-r--r--chrome/app/theme/default_200_percent/common/browser_tools_bar_info.pngbin0 -> 395 bytes
-rw-r--r--chrome/app/theme/theme_resources.grd1
-rw-r--r--chrome/browser/ui/cocoa/extensions/browser_action_test_util_mac.mm10
-rw-r--r--chrome/browser/ui/cocoa/toolbar/toolbar_controller.h3
-rw-r--r--chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm12
-rw-r--r--chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.h11
-rw-r--r--chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.mm13
-rw-r--r--chrome/browser/ui/toolbar/wrench_icon_painter.cc2
-rw-r--r--chrome/browser/ui/toolbar/wrench_icon_painter.h1
-rw-r--r--chrome/browser/ui/toolbar/wrench_menu_badge_controller.cc16
-rw-r--r--chrome/browser/ui/toolbar/wrench_menu_badge_controller.h8
-rw-r--r--chrome/browser/ui/views/toolbar/browser_action_test_util_views.cc2
-rw-r--r--chrome/browser/ui/views/toolbar/browser_actions_container.cc3
-rw-r--r--chrome/browser/ui/views/toolbar/toolbar_view.h3
-rw-r--r--chrome/browser/ui/views/toolbar/wrench_toolbar_button.cc7
-rw-r--r--chrome/browser/ui/views/toolbar/wrench_toolbar_button.h11
17 files changed, 48 insertions, 55 deletions
diff --git a/chrome/app/theme/default_100_percent/common/browser_tools_bar_info.png b/chrome/app/theme/default_100_percent/common/browser_tools_bar_info.png
new file mode 100644
index 0000000..7a153d6
--- /dev/null
+++ b/chrome/app/theme/default_100_percent/common/browser_tools_bar_info.png
Binary files differ
diff --git a/chrome/app/theme/default_200_percent/common/browser_tools_bar_info.png b/chrome/app/theme/default_200_percent/common/browser_tools_bar_info.png
new file mode 100644
index 0000000..9cc3e93
--- /dev/null
+++ b/chrome/app/theme/default_200_percent/common/browser_tools_bar_info.png
Binary files differ
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 835205d..070407a 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -977,6 +977,7 @@
<structure type="chrome_scaled_image" name="IDR_TOOLBAR_BEZEL_HOVER" file="common/browser_toolbar_bezel_hover.png" />
<structure type="chrome_scaled_image" name="IDR_TOOLBAR_BEZEL_PRESSED" file="common/browser_toolbar_bezel_pressed.png" />
<structure type="chrome_scaled_image" name="IDR_TOOLS_BAR" file="common/browser_tools_bar.png" />
+ <structure type="chrome_scaled_image" name="IDR_TOOLS_BAR_INFO" file="common/browser_tools_bar_info.png" />
<structure type="chrome_scaled_image" name="IDR_TOOLS_BAR_LOW" file="common/browser_tools_bar_low.png" />
<structure type="chrome_scaled_image" name="IDR_TOOLS_BAR_MEDIUM" file="common/browser_tools_bar_medium.png" />
<structure type="chrome_scaled_image" name="IDR_TOOLS_BAR_HIGH" file="common/browser_tools_bar_high.png" />
diff --git a/chrome/browser/ui/cocoa/extensions/browser_action_test_util_mac.mm b/chrome/browser/ui/cocoa/extensions/browser_action_test_util_mac.mm
index 76b3049..908c67d 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_action_test_util_mac.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_action_test_util_mac.mm
@@ -19,7 +19,6 @@
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
#import "chrome/browser/ui/cocoa/themed_window.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
-#import "chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.h"
#include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
#include "chrome/common/chrome_constants.h"
@@ -184,12 +183,9 @@ bool BrowserActionTestUtil::ActionButtonWantsToRun(size_t index) {
}
bool BrowserActionTestUtil::OverflowedActionButtonWantsToRun() {
- NSView* wrench = [[[BrowserWindowController browserWindowControllerForWindow:
- browser_->window()->GetNativeWindow()] toolbarController] wrenchButton];
- NSButton* wrenchButton = base::mac::ObjCCastStrict<NSButton>(wrench);
- WrenchToolbarButtonCell* cell =
- base::mac::ObjCCastStrict<WrenchToolbarButtonCell>([wrenchButton cell]);
- return [cell overflowedToolbarActionWantsToRun];
+ return [[[BrowserWindowController browserWindowControllerForWindow:
+ browser_->window()->GetNativeWindow()] toolbarController]
+ overflowedToolbarActionWantsToRun];
}
ToolbarActionsBar* BrowserActionTestUtil::GetToolbarActionsBar() {
diff --git a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.h b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.h
index b6f5814..76e357f 100644
--- a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.h
+++ b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.h
@@ -138,6 +138,9 @@ class NotificationBridge;
// Only used if the extension toolbar redesign is on.
- (void)setOverflowedToolbarActionWantsToRun:(BOOL)overflowedActionWantsToRun;
+// Returns whether or not an overflowed toolbar action wants to run.
+- (BOOL)overflowedToolbarActionWantsToRun;
+
// Happens when the zoom for the active tab changes, the active tab switches, or
// a new tab or browser window is created. |canShowBubble| indicates if it is
// appropriate to show a zoom bubble for the change.
diff --git a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
index ed8ab39..2566d31 100644
--- a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
+++ b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
@@ -190,6 +190,8 @@ class NotificationBridge : public WrenchMenuBadgeController::Delegate {
[controller_ prefChanged:pref_name];
}
+ WrenchMenuBadgeController* badge_controller() { return &badge_controller_; }
+
private:
ToolbarController* controller_; // weak, owns us
@@ -539,9 +541,13 @@ class NotificationBridge : public WrenchMenuBadgeController::Delegate {
}
- (void)setOverflowedToolbarActionWantsToRun:(BOOL)overflowedActionWantsToRun {
- WrenchToolbarButtonCell* cell =
- base::mac::ObjCCastStrict<WrenchToolbarButtonCell>([wrenchButton_ cell]);
- [cell setOverflowedToolbarActionWantsToRun:overflowedActionWantsToRun];
+ notificationBridge_->badge_controller()->SetOverflowedToolbarActionWantsToRun(
+ overflowedActionWantsToRun);
+}
+
+- (BOOL)overflowedToolbarActionWantsToRun {
+ return notificationBridge_->badge_controller()->
+ overflowed_toolbar_action_wants_to_run();
}
- (void)zoomChangedForActiveTab:(BOOL)canShowBubble {
diff --git a/chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.h b/chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.h
index 2c1e8a2..26f3615 100644
--- a/chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.h
+++ b/chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.h
@@ -17,11 +17,6 @@ class WrenchIconPainterDelegateMac;
// and paint severity levels.
@interface WrenchToolbarButtonCell : ClickHoldButtonCell {
@private
- // True if an overflowed toolbar action wants to act, and the button should
- // draw itself in a "popped" state. Only used with the extension toolbar
- // redesign.
- BOOL overflowedToolbarActionWantsToRun_;
-
scoped_ptr<WrenchIconPainter> wrenchIconPainter_;
scoped_ptr<WrenchIconPainterDelegateMac> delegate_;
}
@@ -29,12 +24,6 @@ class WrenchIconPainterDelegateMac;
- (void)setSeverity:(WrenchIconPainter::Severity)severity
shouldAnimate:(BOOL)shouldAnimate;
-- (void)setOverflowedToolbarActionWantsToRun:(BOOL)overflowedActionWantsToRun;
-
-@end
-
-@interface WrenchToolbarButtonCell(TestingAPI)
-- (BOOL) overflowedToolbarActionWantsToRun;
@end
#endif // CHROME_BROWSER_UI_COCOA_TOOLBAR_WRENCH_TOOLBAR_BUTTON_CELL_H_
diff --git a/chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.mm b/chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.mm
index 2f2e214..9e932b4 100644
--- a/chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.mm
+++ b/chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.mm
@@ -66,13 +66,7 @@ class WrenchIconPainterDelegateMac : public WrenchIconPainter::Delegate {
wrenchIconPainter_->SetSeverity(severity, shouldAnimate);
}
-- (void)setOverflowedToolbarActionWantsToRun:(BOOL)overflowedActionWantsToRun {
- overflowedToolbarActionWantsToRun_ = overflowedActionWantsToRun;
- [[self controlView] setNeedsDisplay:YES];
-}
-
- (void)commonInit {
- overflowedToolbarActionWantsToRun_ = NO;
delegate_.reset(new WrenchIconPainterDelegateMac(self));
wrenchIconPainter_.reset(new WrenchIconPainter(delegate_.get()));
}
@@ -85,11 +79,4 @@ class WrenchIconPainterDelegateMac : public WrenchIconPainter::Delegate {
return WrenchIconPainter::BEZEL_NONE;
}
-#pragma mark -
-#pragma mark Testing Methods
-
-- (BOOL)overflowedToolbarActionWantsToRun {
- return overflowedToolbarActionWantsToRun_;
-}
-
@end
diff --git a/chrome/browser/ui/toolbar/wrench_icon_painter.cc b/chrome/browser/ui/toolbar/wrench_icon_painter.cc
index d654160..81aabc1 100644
--- a/chrome/browser/ui/toolbar/wrench_icon_painter.cc
+++ b/chrome/browser/ui/toolbar/wrench_icon_painter.cc
@@ -146,6 +146,8 @@ int WrenchIconPainter::GetCurrentSeverityImageID() const {
switch (severity_) {
case SEVERITY_NONE:
return 0;
+ case SEVERITY_INFO:
+ return IDR_TOOLS_BAR_INFO;
case SEVERITY_LOW:
return IDR_TOOLS_BAR_LOW;
case SEVERITY_MEDIUM:
diff --git a/chrome/browser/ui/toolbar/wrench_icon_painter.h b/chrome/browser/ui/toolbar/wrench_icon_painter.h
index c50d7b2..cf4f7f1 100644
--- a/chrome/browser/ui/toolbar/wrench_icon_painter.h
+++ b/chrome/browser/ui/toolbar/wrench_icon_painter.h
@@ -32,6 +32,7 @@ class WrenchIconPainter : gfx::AnimationDelegate {
enum Severity {
SEVERITY_NONE,
+ SEVERITY_INFO,
SEVERITY_LOW,
SEVERITY_MEDIUM,
SEVERITY_HIGH,
diff --git a/chrome/browser/ui/toolbar/wrench_menu_badge_controller.cc b/chrome/browser/ui/toolbar/wrench_menu_badge_controller.cc
index 2cd840c..d3838b1 100644
--- a/chrome/browser/ui/toolbar/wrench_menu_badge_controller.cc
+++ b/chrome/browser/ui/toolbar/wrench_menu_badge_controller.cc
@@ -77,7 +77,9 @@ bool ShouldShowIncompatibilityWarning() {
WrenchMenuBadgeController::WrenchMenuBadgeController(Profile* profile,
Delegate* delegate)
- : profile_(profile), delegate_(delegate) {
+ : profile_(profile),
+ delegate_(delegate),
+ overflowed_toolbar_action_wants_to_run_(false) {
DCHECK(profile_);
DCHECK(delegate_);
@@ -124,10 +126,22 @@ void WrenchMenuBadgeController::UpdateDelegate() {
return;
}
+ if (overflowed_toolbar_action_wants_to_run_) {
+ delegate_->UpdateBadgeSeverity(BADGE_TYPE_NONE,
+ WrenchIconPainter::SEVERITY_INFO, true);
+ return;
+ }
+
delegate_->UpdateBadgeSeverity(BADGE_TYPE_NONE,
WrenchIconPainter::SEVERITY_NONE, true);
}
+void WrenchMenuBadgeController::SetOverflowedToolbarActionWantsToRun(
+ bool wants_to_run) {
+ overflowed_toolbar_action_wants_to_run_ = wants_to_run;
+ UpdateDelegate();
+}
+
void WrenchMenuBadgeController::Observe(
int type,
const content::NotificationSource& source,
diff --git a/chrome/browser/ui/toolbar/wrench_menu_badge_controller.h b/chrome/browser/ui/toolbar/wrench_menu_badge_controller.h
index abdfd40..c75b371 100644
--- a/chrome/browser/ui/toolbar/wrench_menu_badge_controller.h
+++ b/chrome/browser/ui/toolbar/wrench_menu_badge_controller.h
@@ -50,6 +50,13 @@ class WrenchMenuBadgeController : public content::NotificationObserver {
// delegate.
void UpdateDelegate();
+ // Sets |overflowed_toolbar_action_wants_to_run_| and updates the delegate.
+ void SetOverflowedToolbarActionWantsToRun(bool wants_to_run);
+
+ bool overflowed_toolbar_action_wants_to_run() const {
+ return overflowed_toolbar_action_wants_to_run_;
+ }
+
private:
// content::NotificationObserver:
void Observe(int type,
@@ -59,6 +66,7 @@ class WrenchMenuBadgeController : public content::NotificationObserver {
Profile* profile_;
Delegate* delegate_;
content::NotificationRegistrar registrar_;
+ bool overflowed_toolbar_action_wants_to_run_;
DISALLOW_COPY_AND_ASSIGN(WrenchMenuBadgeController);
};
diff --git a/chrome/browser/ui/views/toolbar/browser_action_test_util_views.cc b/chrome/browser/ui/views/toolbar/browser_action_test_util_views.cc
index 48edbf0..da6d869 100644
--- a/chrome/browser/ui/views/toolbar/browser_action_test_util_views.cc
+++ b/chrome/browser/ui/views/toolbar/browser_action_test_util_views.cc
@@ -176,7 +176,7 @@ bool BrowserActionTestUtil::ActionButtonWantsToRun(size_t index) {
bool BrowserActionTestUtil::OverflowedActionButtonWantsToRun() {
return BrowserView::GetBrowserViewForBrowser(browser_)->toolbar()->
- app_menu()->overflowed_toolbar_action_wants_to_run_for_testing();
+ wrench_menu_badge_controller()->overflowed_toolbar_action_wants_to_run();
}
ToolbarActionsBar* BrowserActionTestUtil::GetToolbarActionsBar() {
diff --git a/chrome/browser/ui/views/toolbar/browser_actions_container.cc b/chrome/browser/ui/views/toolbar/browser_actions_container.cc
index 9cd228d..09d3dc6 100644
--- a/chrome/browser/ui/views/toolbar/browser_actions_container.cc
+++ b/chrome/browser/ui/views/toolbar/browser_actions_container.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
+#include "chrome/browser/ui/toolbar/wrench_menu_badge_controller.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
#include "chrome/browser/ui/views/extensions/extension_message_bubble_view.h"
@@ -325,7 +326,7 @@ void BrowserActionsContainer::OnOverflowedActionWantsToRunChanged(
bool overflowed_action_wants_to_run) {
DCHECK(!in_overflow_mode());
BrowserView::GetBrowserViewForBrowser(browser_)->toolbar()->
- app_menu()->SetOverflowedToolbarActionWantsToRun(
+ wrench_menu_badge_controller()->SetOverflowedToolbarActionWantsToRun(
overflowed_action_wants_to_run);
}
diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.h b/chrome/browser/ui/views/toolbar/toolbar_view.h
index 76c8942..32eebde 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_view.h
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.h
@@ -107,6 +107,9 @@ class ToolbarView : public views::AccessiblePaneView,
LocationBarView* location_bar() const { return location_bar_; }
WrenchToolbarButton* app_menu() const { return app_menu_; }
HomeButton* home_button() const { return home_; }
+ WrenchMenuBadgeController* wrench_menu_badge_controller() {
+ return &badge_controller_;
+ }
// AccessiblePaneView:
bool SetPaneFocus(View* initial_focus) override;
diff --git a/chrome/browser/ui/views/toolbar/wrench_toolbar_button.cc b/chrome/browser/ui/views/toolbar/wrench_toolbar_button.cc
index ce7325d..1aeca46 100644
--- a/chrome/browser/ui/views/toolbar/wrench_toolbar_button.cc
+++ b/chrome/browser/ui/views/toolbar/wrench_toolbar_button.cc
@@ -28,7 +28,6 @@ WrenchToolbarButton::WrenchToolbarButton(ToolbarView* toolbar_view)
toolbar_view_(toolbar_view),
allow_extension_dragging_(
extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()),
- overflowed_toolbar_action_wants_to_run_for_testing_(false),
weak_factory_(this) {
}
@@ -41,12 +40,6 @@ void WrenchToolbarButton::SetSeverity(WrenchIconPainter::Severity severity,
SchedulePaint();
}
-void WrenchToolbarButton::SetOverflowedToolbarActionWantsToRun(
- bool wants_to_run) {
- overflowed_toolbar_action_wants_to_run_for_testing_ = wants_to_run;
- SchedulePaint();
-}
-
gfx::Size WrenchToolbarButton::GetPreferredSize() const {
return ResourceBundle::GetSharedInstance().
GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size();
diff --git a/chrome/browser/ui/views/toolbar/wrench_toolbar_button.h b/chrome/browser/ui/views/toolbar/wrench_toolbar_button.h
index 3e99ecd..cab4651 100644
--- a/chrome/browser/ui/views/toolbar/wrench_toolbar_button.h
+++ b/chrome/browser/ui/views/toolbar/wrench_toolbar_button.h
@@ -32,13 +32,6 @@ class WrenchToolbarButton : public views::MenuButton,
// WrenchIconPainter::Delegate:
void ScheduleWrenchIconPaint() override;
- // Sets |overflowed_toolbar_action_wants_to_run_| and schedules a paint.
- void SetOverflowedToolbarActionWantsToRun(bool wants_to_run);
-
- bool overflowed_toolbar_action_wants_to_run_for_testing() const {
- return overflowed_toolbar_action_wants_to_run_for_testing_;
- }
-
// Opens the wrench menu immediately during a drag-and-drop operation.
// Used only in testing.
static bool g_open_wrench_immediately_for_testing;
@@ -69,10 +62,6 @@ class WrenchToolbarButton : public views::MenuButton,
// (in order to open the overflow in the app/wrench menu).
bool allow_extension_dragging_;
- // A flag for whether or not any overflowed toolbar actions want to run.
- // Only needed for testing.
- bool overflowed_toolbar_action_wants_to_run_for_testing_;
-
// Used to spawn weak pointers for delayed tasks to open the overflow menu.
base::WeakPtrFactory<WrenchToolbarButton> weak_factory_;