| 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 virtual bool IsCommandIdChecked(int command_id) const override { |
| 46 return false; | 46 return false; |
| 47 } | 47 } |
| 48 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { | 48 virtual bool IsCommandIdEnabled(int command_id) const override { |
| 49 TabStripModel::ContextMenuCommand command = | 49 TabStripModel::ContextMenuCommand command = |
| 50 static_cast<TabStripModel::ContextMenuCommand>(command_id); | 50 static_cast<TabStripModel::ContextMenuCommand>(command_id); |
| 51 return [target_ isCommandEnabled:command forController:owner_]; | 51 return [target_ isCommandEnabled:command forController:owner_]; |
| 52 } | 52 } |
| 53 virtual bool GetAcceleratorForCommandId( | 53 virtual bool GetAcceleratorForCommandId( |
| 54 int command_id, | 54 int command_id, |
| 55 ui::Accelerator* accelerator) OVERRIDE { return false; } | 55 ui::Accelerator* accelerator) override { return false; } |
| 56 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE { | 56 virtual void ExecuteCommand(int command_id, int event_flags) override { |
| 57 TabStripModel::ContextMenuCommand command = | 57 TabStripModel::ContextMenuCommand command = |
| 58 static_cast<TabStripModel::ContextMenuCommand>(command_id); | 58 static_cast<TabStripModel::ContextMenuCommand>(command_id); |
| 59 [target_ commandDispatch:command forController:owner_]; | 59 [target_ commandDispatch:command forController:owner_]; |
| 60 } | 60 } |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 id<TabControllerTarget> target_; // weak | 63 id<TabControllerTarget> target_; // weak |
| 64 TabController* owner_; // weak, owns me | 64 TabController* owner_; // weak, owns me |
| 65 }; | 65 }; |
| 66 | 66 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 // TabStripDragController. | 427 // TabStripDragController. |
| 428 - (BOOL)tabCanBeDragged:(TabController*)controller { | 428 - (BOOL)tabCanBeDragged:(TabController*)controller { |
| 429 return [[target_ dragController] tabCanBeDragged:controller]; | 429 return [[target_ dragController] tabCanBeDragged:controller]; |
| 430 } | 430 } |
| 431 | 431 |
| 432 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab { | 432 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab { |
| 433 [[target_ dragController] maybeStartDrag:event forTab:tab]; | 433 [[target_ dragController] maybeStartDrag:event forTab:tab]; |
| 434 } | 434 } |
| 435 | 435 |
| 436 @end | 436 @end |
| OLD | NEW |