| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cocoa/tab_strip_controller.h" | 5 #import "chrome/browser/cocoa/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 | 10 |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 TabContentsController* newController = | 889 TabContentsController* newController = |
| 890 [tabContentsArray_ objectAtIndex:index]; | 890 [tabContentsArray_ objectAtIndex:index]; |
| 891 [newController willBecomeSelectedTab]; | 891 [newController willBecomeSelectedTab]; |
| 892 | 892 |
| 893 // Relayout for new tabs and to let the selected tab grow to be larger in | 893 // Relayout for new tabs and to let the selected tab grow to be larger in |
| 894 // size than surrounding tabs if the user has many. This also raises the | 894 // size than surrounding tabs if the user has many. This also raises the |
| 895 // selected tab to the top. | 895 // selected tab to the top. |
| 896 [self layoutTabs]; | 896 [self layoutTabs]; |
| 897 | 897 |
| 898 if (oldContents) { | 898 if (oldContents) { |
| 899 oldContents->view()->StoreFocus(); | 899 int index = browser_->GetIndexOfController(&(oldContents->controller())); |
| 900 oldContents->WasHidden(); | 900 if (index != -1) { // When closing a tab, the old tab may be gone. |
| 901 TabContentsController* oldController = |
| 902 [tabContentsArray_ objectAtIndex:index]; |
| 903 [oldController willBecomeUnselectedTab]; |
| 904 oldContents->view()->StoreFocus(); |
| 905 oldContents->WasHidden(); |
| 906 } |
| 901 } | 907 } |
| 902 | 908 |
| 903 // Swap in the contents for the new tab. | 909 // Swap in the contents for the new tab. |
| 904 [self swapInTabAtIndex:modelIndex]; | 910 [self swapInTabAtIndex:modelIndex]; |
| 905 | 911 |
| 906 if (newContents) { | 912 if (newContents) { |
| 907 newContents->DidBecomeSelected(); | 913 newContents->DidBecomeSelected(); |
| 908 newContents->view()->RestoreFocus(); | 914 newContents->view()->RestoreFocus(); |
| 909 | 915 |
| 910 if (newContents->find_ui_active()) | 916 if (newContents->find_ui_active()) |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 // Show next sheet | 1489 // Show next sheet |
| 1484 NSWindowController* controller = [[tab window] windowController]; | 1490 NSWindowController* controller = [[tab window] windowController]; |
| 1485 DCHECK([controller isKindOfClass:[BrowserWindowController class]]); | 1491 DCHECK([controller isKindOfClass:[BrowserWindowController class]]); |
| 1486 windows.front()->Realize( | 1492 windows.front()->Realize( |
| 1487 static_cast<BrowserWindowController*>(controller)); | 1493 static_cast<BrowserWindowController*>(controller)); |
| 1488 } | 1494 } |
| 1489 } | 1495 } |
| 1490 } | 1496 } |
| 1491 | 1497 |
| 1492 @end | 1498 @end |
| OLD | NEW |