| 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 <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // A C++ delegate that handles enabling/disabling menu items and handling when | 34 // A C++ delegate that handles enabling/disabling menu items and handling when |
| 35 // a menu command is chosen. Also fixes up the menu item label for "pin/unpin | 35 // a menu command is chosen. Also fixes up the menu item label for "pin/unpin |
| 36 // tab". | 36 // tab". |
| 37 class MenuDelegate : public ui::SimpleMenuModel::Delegate { | 37 class MenuDelegate : public ui::SimpleMenuModel::Delegate { |
| 38 public: | 38 public: |
| 39 explicit MenuDelegate(id<TabControllerTarget> target, TabController* owner) | 39 explicit MenuDelegate(id<TabControllerTarget> target, TabController* owner) |
| 40 : target_(target), | 40 : target_(target), |
| 41 owner_(owner) {} | 41 owner_(owner) {} |
| 42 | 42 |
| 43 // Overridden from ui::SimpleMenuModel::Delegate | 43 // Overridden from ui::SimpleMenuModel::Delegate |
| 44 virtual bool IsCommandIdChecked(int command_id) const { return false; } | 44 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE { |
| 45 virtual bool IsCommandIdEnabled(int command_id) const { | 45 return false; |
| 46 } |
| 47 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { |
| 46 TabStripModel::ContextMenuCommand command = | 48 TabStripModel::ContextMenuCommand command = |
| 47 static_cast<TabStripModel::ContextMenuCommand>(command_id); | 49 static_cast<TabStripModel::ContextMenuCommand>(command_id); |
| 48 return [target_ isCommandEnabled:command forController:owner_]; | 50 return [target_ isCommandEnabled:command forController:owner_]; |
| 49 } | 51 } |
| 50 virtual bool GetAcceleratorForCommandId( | 52 virtual bool GetAcceleratorForCommandId( |
| 51 int command_id, | 53 int command_id, |
| 52 ui::Accelerator* accelerator) { return false; } | 54 ui::Accelerator* accelerator) OVERRIDE { return false; } |
| 53 virtual void ExecuteCommand(int command_id) { | 55 virtual void ExecuteCommand(int command_id) OVERRIDE { |
| 54 TabStripModel::ContextMenuCommand command = | 56 TabStripModel::ContextMenuCommand command = |
| 55 static_cast<TabStripModel::ContextMenuCommand>(command_id); | 57 static_cast<TabStripModel::ContextMenuCommand>(command_id); |
| 56 [target_ commandDispatch:command forController:owner_]; | 58 [target_ commandDispatch:command forController:owner_]; |
| 57 } | 59 } |
| 58 | 60 |
| 59 private: | 61 private: |
| 60 id<TabControllerTarget> target_; // weak | 62 id<TabControllerTarget> target_; // weak |
| 61 TabController* owner_; // weak, owns me | 63 TabController* owner_; // weak, owns me |
| 62 }; | 64 }; |
| 63 | 65 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 // TabStripDragController. | 386 // TabStripDragController. |
| 385 - (BOOL)tabCanBeDragged:(TabController*)controller { | 387 - (BOOL)tabCanBeDragged:(TabController*)controller { |
| 386 return [[target_ dragController] tabCanBeDragged:controller]; | 388 return [[target_ dragController] tabCanBeDragged:controller]; |
| 387 } | 389 } |
| 388 | 390 |
| 389 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab { | 391 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab { |
| 390 [[target_ dragController] maybeStartDrag:event forTab:tab]; | 392 [[target_ dragController] maybeStartDrag:event forTab:tab]; |
| 391 } | 393 } |
| 392 | 394 |
| 393 @end | 395 @end |
| OLD | NEW |