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

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

Issue 911203002: [Extensions Toolbar Mac] Remove ToolbarActionViewDelegateCocoa (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/extension_action_platform_delegate_cocoa.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_action_button.h" 5 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 16 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
17 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" 17 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
18 #import "chrome/browser/ui/cocoa/themed_window.h" 18 #import "chrome/browser/ui/cocoa/themed_window.h"
19 #import "chrome/browser/ui/cocoa/toolbar/toolbar_action_view_delegate_cocoa.h"
20 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 19 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
21 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" 20 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h"
22 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 21 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
22 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h"
23 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
24 #include "skia/ext/skia_utils_mac.h" 24 #include "skia/ext/skia_utils_mac.h"
25 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " 25 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h "
26 #import "ui/base/cocoa/menu_controller.h" 26 #import "ui/base/cocoa/menu_controller.h"
27 #include "ui/gfx/canvas_skia_paint.h" 27 #include "ui/gfx/canvas_skia_paint.h"
28 #include "ui/gfx/geometry/rect.h" 28 #include "ui/gfx/geometry/rect.h"
29 #include "ui/gfx/image/image.h" 29 #include "ui/gfx/image/image.h"
30 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 30 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
31 31
32 NSString* const kBrowserActionButtonDraggingNotification = 32 NSString* const kBrowserActionButtonDraggingNotification =
33 @"BrowserActionButtonDraggingNotification"; 33 @"BrowserActionButtonDraggingNotification";
34 NSString* const kBrowserActionButtonDragEndNotification = 34 NSString* const kBrowserActionButtonDragEndNotification =
35 @"BrowserActionButtonDragEndNotification"; 35 @"BrowserActionButtonDragEndNotification";
36 36
37 static const CGFloat kBrowserActionBadgeOriginYOffset = 5; 37 static const CGFloat kBrowserActionBadgeOriginYOffset = 5;
38 static const CGFloat kAnimationDuration = 0.2; 38 static const CGFloat kAnimationDuration = 0.2;
39 static const CGFloat kMinimumDragDistance = 5; 39 static const CGFloat kMinimumDragDistance = 5;
40 40
41 @interface BrowserActionButton () 41 @interface BrowserActionButton ()
42 - (void)endDrag; 42 - (void)endDrag;
43 - (void)updateHighlightedState; 43 - (void)updateHighlightedState;
44 @end 44 @end
45 45
46 // A class to bridge the ToolbarActionViewController and the 46 // A class to bridge the ToolbarActionViewController and the
47 // BrowserActionButton. 47 // BrowserActionButton.
48 class ToolbarActionViewDelegateBridge : public ToolbarActionViewDelegateCocoa { 48 class ToolbarActionViewDelegateBridge : public ToolbarActionViewDelegate {
49 public: 49 public:
50 ToolbarActionViewDelegateBridge(BrowserActionButton* owner, 50 ToolbarActionViewDelegateBridge(BrowserActionButton* owner,
51 BrowserActionsController* controller, 51 BrowserActionsController* controller,
52 ToolbarActionViewController* viewController); 52 ToolbarActionViewController* viewController);
53 ~ToolbarActionViewDelegateBridge() override; 53 ~ToolbarActionViewDelegateBridge() override;
54 54
55 // Shows the context menu for the owning action. 55 // Shows the context menu for the owning action.
56 void ShowContextMenu(); 56 void ShowContextMenu();
57 57
58 bool user_shown_popup_visible() const { return user_shown_popup_visible_; } 58 bool user_shown_popup_visible() const { return user_shown_popup_visible_; }
59 59
60 private: 60 private:
61 // ToolbarActionViewDelegateCocoa: 61 // ToolbarActionViewDelegate:
62 ToolbarActionViewController* GetPreferredPopupViewController() override; 62 ToolbarActionViewController* GetPreferredPopupViewController() override;
63 content::WebContents* GetCurrentWebContents() const override; 63 content::WebContents* GetCurrentWebContents() const override;
64 void UpdateState() override; 64 void UpdateState() override;
65 void OnPopupShown(bool by_user) override; 65 void OnPopupShown(bool by_user) override;
66 void OnPopupClosed() override; 66 void OnPopupClosed() override;
67 NSPoint GetPopupPoint() override;
68 67
69 // A helper method to implement showing the context menu. 68 // A helper method to implement showing the context menu.
70 void DoShowContextMenu(); 69 void DoShowContextMenu();
71 70
72 // The owning button. Weak. 71 // The owning button. Weak.
73 BrowserActionButton* owner_; 72 BrowserActionButton* owner_;
74 73
75 // The BrowserActionsController that owns the button. Weak. 74 // The BrowserActionsController that owns the button. Weak.
76 BrowserActionsController* controller_; 75 BrowserActionsController* controller_;
77 76
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 if (by_user) 142 if (by_user)
144 user_shown_popup_visible_ = true; 143 user_shown_popup_visible_ = true;
145 [owner_ updateHighlightedState]; 144 [owner_ updateHighlightedState];
146 } 145 }
147 146
148 void ToolbarActionViewDelegateBridge::OnPopupClosed() { 147 void ToolbarActionViewDelegateBridge::OnPopupClosed() {
149 user_shown_popup_visible_ = false; 148 user_shown_popup_visible_ = false;
150 [owner_ updateHighlightedState]; 149 [owner_ updateHighlightedState];
151 } 150 }
152 151
153 NSPoint ToolbarActionViewDelegateBridge::GetPopupPoint() {
154 return [controller_ popupPointForId:[owner_ viewController]->GetId()];
155 }
156
157 void ToolbarActionViewDelegateBridge::DoShowContextMenu() { 152 void ToolbarActionViewDelegateBridge::DoShowContextMenu() {
158 NSButton* wrenchButton = 153 NSButton* wrenchButton =
159 [[[BrowserWindowController browserWindowControllerForWindow: 154 [[[BrowserWindowController browserWindowControllerForWindow:
160 [controller_ browser]->window()->GetNativeWindow()] 155 [controller_ browser]->window()->GetNativeWindow()]
161 toolbarController] wrenchButton]; 156 toolbarController] wrenchButton];
162 // The point the menu shows matches that of the normal wrench menu - that is, 157 // The point the menu shows matches that of the normal wrench menu - that is,
163 // the right-left most corner of the menu is left-aligned with the wrench 158 // the right-left most corner of the menu is left-aligned with the wrench
164 // button, and the menu is displayed "a little bit" lower. It would be nice to 159 // button, and the menu is displayed "a little bit" lower. It would be nice to
165 // be able to avoid the magic '5' here, but since it's built into Cocoa, it's 160 // be able to avoid the magic '5' here, but since it's built into Cocoa, it's
166 // not too hopeful. 161 // not too hopeful.
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 - (ui::ThemeProvider*)themeProviderForWindow:(NSWindow*)window { 522 - (ui::ThemeProvider*)themeProviderForWindow:(NSWindow*)window {
528 ui::ThemeProvider* themeProvider = [window themeProvider]; 523 ui::ThemeProvider* themeProvider = [window themeProvider];
529 if (!themeProvider) 524 if (!themeProvider)
530 themeProvider = 525 themeProvider =
531 [[browserActionsController_ browser]->window()->GetNativeWindow() 526 [[browserActionsController_ browser]->window()->GetNativeWindow()
532 themeProvider]; 527 themeProvider];
533 return themeProvider; 528 return themeProvider;
534 } 529 }
535 530
536 @end 531 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/extension_action_platform_delegate_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698