| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_strip_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 TabStripModel::CLOSE_USER_GESTURE | | 736 TabStripModel::CLOSE_USER_GESTURE | |
| 737 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | 737 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); |
| 738 } else { | 738 } else { |
| 739 // Use the standard window close if this is the last tab | 739 // Use the standard window close if this is the last tab |
| 740 // this prevents the tab from being removed from the model until after | 740 // this prevents the tab from being removed from the model until after |
| 741 // the window dissapears | 741 // the window dissapears |
| 742 [[tabStripView_ window] performClose:nil]; | 742 [[tabStripView_ window] performClose:nil]; |
| 743 } | 743 } |
| 744 } | 744 } |
| 745 | 745 |
| 746 // Called when the user closes all tabs except for the current tab. |
| 747 // Invoke the |CommandCloseOtherTabs| context menu command. |
| 748 - (void)closeOtherTabs:(id)sender { |
| 749 int index = [self modelIndexForTabView:sender]; |
| 750 if (tabStripModel_->ContainsIndex(index)) { |
| 751 tabStripModel_->ExecuteContextMenuCommand( |
| 752 index, TabStripModel::CommandCloseOtherTabs); |
| 753 } |
| 754 } |
| 755 |
| 746 // Dispatch context menu commands for the given tab controller. | 756 // Dispatch context menu commands for the given tab controller. |
| 747 - (void)commandDispatch:(TabStripModel::ContextMenuCommand)command | 757 - (void)commandDispatch:(TabStripModel::ContextMenuCommand)command |
| 748 forController:(TabController*)controller { | 758 forController:(TabController*)controller { |
| 749 int index = [self modelIndexForTabView:[controller view]]; | 759 int index = [self modelIndexForTabView:[controller view]]; |
| 750 if (tabStripModel_->ContainsIndex(index)) | 760 if (tabStripModel_->ContainsIndex(index)) |
| 751 tabStripModel_->ExecuteContextMenuCommand(index, command); | 761 tabStripModel_->ExecuteContextMenuCommand(index, command); |
| 752 } | 762 } |
| 753 | 763 |
| 754 // Returns YES if the specificed command should be enabled for the given | 764 // Returns YES if the specificed command should be enabled for the given |
| 755 // controller. | 765 // controller. |
| (...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 NSInteger index = [self indexFromModelIndex:modelIndex]; | 2038 NSInteger index = [self indexFromModelIndex:modelIndex]; |
| 2029 BrowserWindowController* controller = | 2039 BrowserWindowController* controller = |
| 2030 (BrowserWindowController*)[[switchView_ window] windowController]; | 2040 (BrowserWindowController*)[[switchView_ window] windowController]; |
| 2031 DCHECK(index >= 0); | 2041 DCHECK(index >= 0); |
| 2032 if (index >= 0) { | 2042 if (index >= 0) { |
| 2033 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; | 2043 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; |
| 2034 } | 2044 } |
| 2035 } | 2045 } |
| 2036 | 2046 |
| 2037 @end | 2047 @end |
| OLD | NEW |