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)) | |
Robert Sesek
2011/08/19 15:36:25
nit: braces {} around multi-line bodies
bashi
2011/08/22 06:43:48
Done.
| |
751 tabStripModel_->ExecuteContextMenuCommand( | |
752 index, TabStripModel::CommandCloseOtherTabs); | |
753 } | |
754 | |
746 // Dispatch context menu commands for the given tab controller. | 755 // Dispatch context menu commands for the given tab controller. |
747 - (void)commandDispatch:(TabStripModel::ContextMenuCommand)command | 756 - (void)commandDispatch:(TabStripModel::ContextMenuCommand)command |
748 forController:(TabController*)controller { | 757 forController:(TabController*)controller { |
749 int index = [self modelIndexForTabView:[controller view]]; | 758 int index = [self modelIndexForTabView:[controller view]]; |
750 if (tabStripModel_->ContainsIndex(index)) | 759 if (tabStripModel_->ContainsIndex(index)) |
751 tabStripModel_->ExecuteContextMenuCommand(index, command); | 760 tabStripModel_->ExecuteContextMenuCommand(index, command); |
752 } | 761 } |
753 | 762 |
754 // Returns YES if the specificed command should be enabled for the given | 763 // Returns YES if the specificed command should be enabled for the given |
755 // controller. | 764 // controller. |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2028 NSInteger index = [self indexFromModelIndex:modelIndex]; | 2037 NSInteger index = [self indexFromModelIndex:modelIndex]; |
2029 BrowserWindowController* controller = | 2038 BrowserWindowController* controller = |
2030 (BrowserWindowController*)[[switchView_ window] windowController]; | 2039 (BrowserWindowController*)[[switchView_ window] windowController]; |
2031 DCHECK(index >= 0); | 2040 DCHECK(index >= 0); |
2032 if (index >= 0) { | 2041 if (index >= 0) { |
2033 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; | 2042 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; |
2034 } | 2043 } |
2035 } | 2044 } |
2036 | 2045 |
2037 @end | 2046 @end |
OLD | NEW |