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/tabs/tab_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // A C++ delegate that handles enabling/disabling menu items and handling when | 35 // A C++ delegate that handles enabling/disabling menu items and handling when |
36 // a menu command is chosen. Also fixes up the menu item label for "pin/unpin | 36 // a menu command is chosen. Also fixes up the menu item label for "pin/unpin |
37 // tab". | 37 // tab". |
38 class MenuDelegate : public ui::SimpleMenuModel::Delegate { | 38 class MenuDelegate : public ui::SimpleMenuModel::Delegate { |
39 public: | 39 public: |
40 explicit MenuDelegate(id<TabControllerTarget> target, TabController* owner) | 40 explicit MenuDelegate(id<TabControllerTarget> target, TabController* owner) |
41 : target_(target), | 41 : target_(target), |
42 owner_(owner) {} | 42 owner_(owner) {} |
43 | 43 |
44 // Overridden from ui::SimpleMenuModel::Delegate | 44 // Overridden from ui::SimpleMenuModel::Delegate |
45 virtual bool IsCommandIdChecked(int command_id) const override { | 45 bool IsCommandIdChecked(int command_id) const override { return false; } |
46 return false; | 46 bool IsCommandIdEnabled(int command_id) const override { |
47 } | |
48 virtual bool IsCommandIdEnabled(int command_id) const override { | |
49 TabStripModel::ContextMenuCommand command = | 47 TabStripModel::ContextMenuCommand command = |
50 static_cast<TabStripModel::ContextMenuCommand>(command_id); | 48 static_cast<TabStripModel::ContextMenuCommand>(command_id); |
51 return [target_ isCommandEnabled:command forController:owner_]; | 49 return [target_ isCommandEnabled:command forController:owner_]; |
52 } | 50 } |
53 virtual bool GetAcceleratorForCommandId( | 51 bool GetAcceleratorForCommandId(int command_id, |
54 int command_id, | 52 ui::Accelerator* accelerator) override { |
55 ui::Accelerator* accelerator) override { return false; } | 53 return false; |
56 virtual void ExecuteCommand(int command_id, int event_flags) override { | 54 } |
| 55 void ExecuteCommand(int command_id, int event_flags) override { |
57 TabStripModel::ContextMenuCommand command = | 56 TabStripModel::ContextMenuCommand command = |
58 static_cast<TabStripModel::ContextMenuCommand>(command_id); | 57 static_cast<TabStripModel::ContextMenuCommand>(command_id); |
59 [target_ commandDispatch:command forController:owner_]; | 58 [target_ commandDispatch:command forController:owner_]; |
60 } | 59 } |
61 | 60 |
62 private: | 61 private: |
63 id<TabControllerTarget> target_; // weak | 62 id<TabControllerTarget> target_; // weak |
64 TabController* owner_; // weak, owns me | 63 TabController* owner_; // weak, owns me |
65 }; | 64 }; |
66 | 65 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 // TabStripDragController. | 426 // TabStripDragController. |
428 - (BOOL)tabCanBeDragged:(TabController*)controller { | 427 - (BOOL)tabCanBeDragged:(TabController*)controller { |
429 return [[target_ dragController] tabCanBeDragged:controller]; | 428 return [[target_ dragController] tabCanBeDragged:controller]; |
430 } | 429 } |
431 | 430 |
432 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab { | 431 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab { |
433 [[target_ dragController] maybeStartDrag:event forTab:tab]; | 432 [[target_ dragController] maybeStartDrag:event forTab:tab]; |
434 } | 433 } |
435 | 434 |
436 @end | 435 @end |
OLD | NEW |