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 { | |
Robert Sesek
2011/08/09 15:20:37
Add this to the TabControllerTarget protocol.
bashi
2011/08/10 06:52:30
Done.
| |
749 int index = [self modelIndexForTabView:sender]; | |
750 if (tabStripModel_->ContainsIndex(index)) | |
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 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2021 NSInteger index = [self indexFromModelIndex:modelIndex]; | 2030 NSInteger index = [self indexFromModelIndex:modelIndex]; |
2022 BrowserWindowController* controller = | 2031 BrowserWindowController* controller = |
2023 (BrowserWindowController*)[[switchView_ window] windowController]; | 2032 (BrowserWindowController*)[[switchView_ window] windowController]; |
2024 DCHECK(index >= 0); | 2033 DCHECK(index >= 0); |
2025 if (index >= 0) { | 2034 if (index >= 0) { |
2026 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; | 2035 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; |
2027 } | 2036 } |
2028 } | 2037 } |
2029 | 2038 |
2030 @end | 2039 @end |
OLD | NEW |