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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm

Issue 1770573002: Update extension buttons to Material Design (Mac). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md_toolbar
Patch Set: Code clean-up. Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 13 matching lines...) Expand all
24 #import "chrome/browser/ui/cocoa/menu_button.h" 24 #import "chrome/browser/ui/cocoa/menu_button.h"
25 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 25 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
26 #include "chrome/browser/ui/extensions/extension_toolbar_icon_surfacing_bubble_d elegate.h" 26 #include "chrome/browser/ui/extensions/extension_toolbar_icon_surfacing_bubble_d elegate.h"
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model.h"
28 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 28 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
29 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" 29 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
30 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h" 30 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h"
31 #include "grit/theme_resources.h" 31 #include "grit/theme_resources.h"
32 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " 32 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h "
33 #include "ui/base/cocoa/appkit_utils.h" 33 #include "ui/base/cocoa/appkit_utils.h"
34 #include "ui/base/material_design/material_design_controller.h"
34 35
35 NSString* const kBrowserActionVisibilityChangedNotification = 36 NSString* const kBrowserActionVisibilityChangedNotification =
36 @"BrowserActionVisibilityChangedNotification"; 37 @"BrowserActionVisibilityChangedNotification";
37 38
38 namespace { 39 namespace {
39 40
40 const CGFloat kAnimationDuration = 0.2; 41 const CGFloat kAnimationDuration = 0.2;
41 42
42 const CGFloat kChevronWidth = 18; 43 const CGFloat kChevronWidth = 18;
43 44
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // Called when the window for the active bubble is closing, and sets the active 175 // Called when the window for the active bubble is closing, and sets the active
175 // bubble to nil. 176 // bubble to nil.
176 - (void)bubbleWindowClosing:(NSNotification*)notification; 177 - (void)bubbleWindowClosing:(NSNotification*)notification;
177 178
178 // Sets the current focused view. Should only be used for the overflow 179 // Sets the current focused view. Should only be used for the overflow
179 // container. 180 // container.
180 - (void)setFocusedViewIndex:(NSInteger)index; 181 - (void)setFocusedViewIndex:(NSInteger)index;
181 182
182 @end 183 @end
183 184
185 // A subclass of MenuButton that draws the chevron button in MD style.
186 @interface ChevronMenuButton : MenuButton
187 @end
188
189 @implementation ChevronMenuButton
190
191 - (gfx::VectorIconId)vectorIconId {
192 return gfx::VectorIconId::OVERFLOW_CHEVRON;
193 }
194
195 @end
196
184 namespace { 197 namespace {
185 198
186 // A bridge between the ToolbarActionsBar and the BrowserActionsController. 199 // A bridge between the ToolbarActionsBar and the BrowserActionsController.
187 class ToolbarActionsBarBridge : public ToolbarActionsBarDelegate { 200 class ToolbarActionsBarBridge : public ToolbarActionsBarDelegate {
188 public: 201 public:
189 explicit ToolbarActionsBarBridge(BrowserActionsController* controller); 202 explicit ToolbarActionsBarBridge(BrowserActionsController* controller);
190 ~ToolbarActionsBarBridge() override; 203 ~ToolbarActionsBarBridge() override;
191 204
192 BrowserActionsController* controller_for_test() { return controller_; } 205 BrowserActionsController* controller_for_test() { return controller_; }
193 206
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 [chevronMenuButton_ setFrame:buttonFrame]; 964 [chevronMenuButton_ setFrame:buttonFrame];
952 } 965 }
953 966
954 - (void)setChevronHidden:(BOOL)hidden 967 - (void)setChevronHidden:(BOOL)hidden
955 inFrame:(NSRect)frame { 968 inFrame:(NSRect)frame {
956 if (!toolbarActionsBar_->platform_settings().chevron_enabled || 969 if (!toolbarActionsBar_->platform_settings().chevron_enabled ||
957 hidden == [self chevronIsHidden]) 970 hidden == [self chevronIsHidden])
958 return; 971 return;
959 972
960 if (!chevronMenuButton_.get()) { 973 if (!chevronMenuButton_.get()) {
961 chevronMenuButton_.reset([[MenuButton alloc] init]); 974 bool isModeMaterial = ui::MaterialDesignController::IsModeMaterial();
975 if (isModeMaterial) {
976 chevronMenuButton_.reset([[ChevronMenuButton alloc] init]);
977 } else {
978 chevronMenuButton_.reset([[MenuButton alloc] init]);
979 }
962 [chevronMenuButton_ setOpenMenuOnClick:YES]; 980 [chevronMenuButton_ setOpenMenuOnClick:YES];
963 [chevronMenuButton_ setBordered:NO]; 981 [chevronMenuButton_ setBordered:NO];
964 [chevronMenuButton_ setShowsBorderOnlyWhileMouseInside:YES]; 982 [chevronMenuButton_ setShowsBorderOnlyWhileMouseInside:YES];
965 983
966 [[chevronMenuButton_ cell] setImageID:IDR_BROWSER_ACTIONS_OVERFLOW 984 if (!isModeMaterial) {
967 forButtonState:image_button_cell::kDefaultState]; 985 [[chevronMenuButton_ cell] setImageID:IDR_BROWSER_ACTIONS_OVERFLOW
968 [[chevronMenuButton_ cell] setImageID:IDR_BROWSER_ACTIONS_OVERFLOW_H 986 forButtonState:image_button_cell::kDefaultState];
969 forButtonState:image_button_cell::kHoverState]; 987 [[chevronMenuButton_ cell] setImageID:IDR_BROWSER_ACTIONS_OVERFLOW_H
970 [[chevronMenuButton_ cell] setImageID:IDR_BROWSER_ACTIONS_OVERFLOW_P 988 forButtonState:image_button_cell::kHoverState];
971 forButtonState:image_button_cell::kPressedState]; 989 [[chevronMenuButton_ cell] setImageID:IDR_BROWSER_ACTIONS_OVERFLOW_P
972 990 forButtonState:image_button_cell::kPressedState];
991 }
973 overflowMenu_.reset([[NSMenu alloc] initWithTitle:@""]); 992 overflowMenu_.reset([[NSMenu alloc] initWithTitle:@""]);
974 [overflowMenu_ setAutoenablesItems:NO]; 993 [overflowMenu_ setAutoenablesItems:NO];
975 [overflowMenu_ setDelegate:self]; 994 [overflowMenu_ setDelegate:self];
976 [chevronMenuButton_ setAttachedMenu:overflowMenu_]; 995 [chevronMenuButton_ setAttachedMenu:overflowMenu_];
977 996
978 [containerView_ addSubview:chevronMenuButton_]; 997 [containerView_ addSubview:chevronMenuButton_];
979 } 998 }
980 999
981 [self updateChevronPositionInFrame:frame]; 1000 [self updateChevronPositionInFrame:frame];
982 1001
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 } 1071 }
1053 1072
1054 #pragma mark - 1073 #pragma mark -
1055 #pragma mark Testing Methods 1074 #pragma mark Testing Methods
1056 1075
1057 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { 1076 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index {
1058 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil; 1077 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil;
1059 } 1078 }
1060 1079
1061 @end 1080 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/browser_action_button.mm ('k') | chrome/browser/ui/cocoa/toolbar/app_toolbar_button.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698