| OLD | NEW |
| 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" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 class ToolbarActionViewDelegateBridge : public ToolbarActionViewDelegate { | 53 class ToolbarActionViewDelegateBridge : public ToolbarActionViewDelegate { |
| 54 public: | 54 public: |
| 55 ToolbarActionViewDelegateBridge(BrowserActionButton* owner, | 55 ToolbarActionViewDelegateBridge(BrowserActionButton* owner, |
| 56 BrowserActionsController* controller, | 56 BrowserActionsController* controller, |
| 57 ToolbarActionViewController* viewController); | 57 ToolbarActionViewController* viewController); |
| 58 ~ToolbarActionViewDelegateBridge() override; | 58 ~ToolbarActionViewDelegateBridge() override; |
| 59 | 59 |
| 60 // Shows the context menu for the owning action. | 60 // Shows the context menu for the owning action. |
| 61 void ShowContextMenu(); | 61 void ShowContextMenu(); |
| 62 | 62 |
| 63 void HidePopup(); |
| 64 |
| 63 bool user_shown_popup_visible() const { return user_shown_popup_visible_; } | 65 bool user_shown_popup_visible() const { return user_shown_popup_visible_; } |
| 64 | 66 |
| 65 private: | 67 private: |
| 66 // ToolbarActionViewDelegate: | 68 // ToolbarActionViewDelegate: |
| 67 content::WebContents* GetCurrentWebContents() const override; | 69 content::WebContents* GetCurrentWebContents() const override; |
| 68 void UpdateState() override; | 70 void UpdateState() override; |
| 69 bool IsMenuRunning() const override; | 71 bool IsMenuRunning() const override; |
| 70 void OnPopupShown(bool by_user) override; | 72 void OnPopupShown(bool by_user) override; |
| 71 void OnPopupClosed() override; | 73 void OnPopupClosed() override; |
| 72 | 74 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 if ([appMenuController isMenuOpen]) | 132 if ([appMenuController isMenuOpen]) |
| 131 [appMenuController cancel]; | 133 [appMenuController cancel]; |
| 132 | 134 |
| 133 [controller_ toolbarActionsBar]->PopOutAction( | 135 [controller_ toolbarActionsBar]->PopOutAction( |
| 134 viewController_, | 136 viewController_, |
| 135 false, | 137 false, |
| 136 base::Bind(&ToolbarActionViewDelegateBridge::DoShowContextMenu, | 138 base::Bind(&ToolbarActionViewDelegateBridge::DoShowContextMenu, |
| 137 weakFactory_.GetWeakPtr())); | 139 weakFactory_.GetWeakPtr())); |
| 138 } | 140 } |
| 139 | 141 |
| 142 void ToolbarActionViewDelegateBridge::HidePopup() { |
| 143 viewController_->HidePopup(); |
| 144 } |
| 145 |
| 140 content::WebContents* ToolbarActionViewDelegateBridge::GetCurrentWebContents() | 146 content::WebContents* ToolbarActionViewDelegateBridge::GetCurrentWebContents() |
| 141 const { | 147 const { |
| 142 return [controller_ currentWebContents]; | 148 return [controller_ currentWebContents]; |
| 143 } | 149 } |
| 144 | 150 |
| 145 void ToolbarActionViewDelegateBridge::UpdateState() { | 151 void ToolbarActionViewDelegateBridge::UpdateState() { |
| 146 [owner_ updateState]; | 152 [owner_ updateState]; |
| 147 } | 153 } |
| 148 | 154 |
| 149 bool ToolbarActionViewDelegateBridge::IsMenuRunning() const { | 155 bool ToolbarActionViewDelegateBridge::IsMenuRunning() const { |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 hints:nil]; | 478 hints:nil]; |
| 473 | 479 |
| 474 [image unlockFocus]; | 480 [image unlockFocus]; |
| 475 return image; | 481 return image; |
| 476 } | 482 } |
| 477 | 483 |
| 478 - (void)showContextMenu { | 484 - (void)showContextMenu { |
| 479 viewControllerDelegate_->ShowContextMenu(); | 485 viewControllerDelegate_->ShowContextMenu(); |
| 480 } | 486 } |
| 481 | 487 |
| 488 - (void)hidePopup { |
| 489 viewControllerDelegate_->HidePopup(); |
| 490 } |
| 491 |
| 482 - (NSMenu*)menu { | 492 - (NSMenu*)menu { |
| 483 // Hack: Since Cocoa doesn't support menus-running-in-menus (see also comment | 493 // Hack: Since Cocoa doesn't support menus-running-in-menus (see also comment |
| 484 // in -rightMouseDown:), it doesn't launch the menu for an overflowed action | 494 // in -rightMouseDown:), it doesn't launch the menu for an overflowed action |
| 485 // on a Control-click. Even more unfortunate, it doesn't even pass us the | 495 // on a Control-click. Even more unfortunate, it doesn't even pass us the |
| 486 // mouseDown event for control clicks. However, it does call -menuForEvent:, | 496 // mouseDown event for control clicks. However, it does call -menuForEvent:, |
| 487 // which in turn calls -menu:, so we can tap in here and show the menu | 497 // which in turn calls -menu:, so we can tap in here and show the menu |
| 488 // programmatically for the Control-click case. | 498 // programmatically for the Control-click case. |
| 489 if ([browserActionsController_ isOverflow] && | 499 if ([browserActionsController_ isOverflow] && |
| 490 ([NSEvent modifierFlags] & NSControlKeyMask)) { | 500 ([NSEvent modifierFlags] & NSControlKeyMask)) { |
| 491 [browserActionsController_ mainButtonForId:viewController_->GetId()]-> | 501 [browserActionsController_ mainButtonForId:viewController_->GetId()]-> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 - (const ui::ThemeProvider*)themeProviderForWindow:(NSWindow*)window { | 579 - (const ui::ThemeProvider*)themeProviderForWindow:(NSWindow*)window { |
| 570 const ui::ThemeProvider* themeProvider = [window themeProvider]; | 580 const ui::ThemeProvider* themeProvider = [window themeProvider]; |
| 571 if (!themeProvider) | 581 if (!themeProvider) |
| 572 themeProvider = | 582 themeProvider = |
| 573 [[browserActionsController_ browser]->window()->GetNativeWindow() | 583 [[browserActionsController_ browser]->window()->GetNativeWindow() |
| 574 themeProvider]; | 584 themeProvider]; |
| 575 return themeProvider; | 585 return themeProvider; |
| 576 } | 586 } |
| 577 | 587 |
| 578 @end | 588 @end |
| OLD | NEW |