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 "base/sys_string_conversions.h" | 7 #import "base/sys_string_conversions.h" |
8 #import "chrome/app/chrome_dll_resource.h" | 8 #import "chrome/app/chrome_dll_resource.h" |
9 #import "chrome/browser/browser.h" | 9 #import "chrome/browser/browser.h" |
10 #import "chrome/browser/cocoa/bookmark_bar_state_controller.h" | 10 #import "chrome/browser/cocoa/bookmark_bar_state_controller.h" |
(...skipping 277 matching lines...) Loading... |
288 if (inForeground) | 288 if (inForeground) |
289 [self swapInTabAtIndex:index]; | 289 [self swapInTabAtIndex:index]; |
290 } | 290 } |
291 | 291 |
292 // Called when a notification is received from the model to select a particular | 292 // Called when a notification is received from the model to select a particular |
293 // tab. Swaps in the toolbar and content area associated with |newContents|. | 293 // tab. Swaps in the toolbar and content area associated with |newContents|. |
294 - (void)selectTabWithContents:(TabContents*)newContents | 294 - (void)selectTabWithContents:(TabContents*)newContents |
295 previousContents:(TabContents*)oldContents | 295 previousContents:(TabContents*)oldContents |
296 atIndex:(NSInteger)index | 296 atIndex:(NSInteger)index |
297 userGesture:(bool)wasUserGesture { | 297 userGesture:(bool)wasUserGesture { |
298 int selectedIndex = 0; | |
299 for (TabController* current in tabArray_) { | |
300 if ([current selected]) { | |
301 break; | |
302 } | |
303 ++selectedIndex; | |
304 } | |
305 | |
306 // De-select all other tabs and select the new tab. | 298 // De-select all other tabs and select the new tab. |
307 int i = 0; | 299 int i = 0; |
308 for (TabController* current in tabArray_) { | 300 for (TabController* current in tabArray_) { |
309 [current setSelected:(i == index) ? YES : NO]; | 301 [current setSelected:(i == index) ? YES : NO]; |
310 ++i; | 302 ++i; |
311 } | 303 } |
312 | 304 |
313 // Make this the top-most tab in the strips's z order. | 305 // Make this the top-most tab in the strips's z order. |
314 NSView* selectedTab = [self viewAtIndex:index]; | 306 NSView* selectedTab = [self viewAtIndex:index]; |
315 [tabView_ addSubview:selectedTab positioned:NSWindowAbove relativeTo:nil]; | 307 [tabView_ addSubview:selectedTab positioned:NSWindowAbove relativeTo:nil]; |
316 | 308 |
317 // Tell the current tab to lose focus. | |
318 if (selectedIndex < (int)[tabArray_ count]) { | |
319 TabContentsController* selectedController = | |
320 [tabContentsArray_ objectAtIndex:selectedIndex]; | |
321 [selectedController defocusLocationBar]; | |
322 } | |
323 | |
324 // Tell the new tab contents it is about to become the selected tab. Here it | 309 // Tell the new tab contents it is about to become the selected tab. Here it |
325 // can do things like make sure the toolbar is up to date. | 310 // can do things like make sure the toolbar is up to date. |
326 TabContentsController* newController = | 311 TabContentsController* newController = |
327 [tabContentsArray_ objectAtIndex:index]; | 312 [tabContentsArray_ objectAtIndex:index]; |
328 [newController willBecomeSelectedTab]; | 313 [newController willBecomeSelectedTab]; |
329 | 314 |
330 // Relayout for new tabs and to let the selected tab grow to be larger in | 315 // Relayout for new tabs and to let the selected tab grow to be larger in |
331 // size than surrounding tabs if the user has many. | 316 // size than surrounding tabs if the user has many. |
332 [self layoutTabs]; | 317 [self layoutTabs]; |
333 | 318 |
(...skipping 153 matching lines...) Loading... |
487 NOTIMPLEMENTED(); | 472 NOTIMPLEMENTED(); |
488 } | 473 } |
489 | 474 |
490 void TabStripBridge::TabChangedAt(TabContents* contents, int index) { | 475 void TabStripBridge::TabChangedAt(TabContents* contents, int index) { |
491 [controller_ tabChangedWithContents:contents atIndex:index]; | 476 [controller_ tabChangedWithContents:contents atIndex:index]; |
492 } | 477 } |
493 | 478 |
494 void TabStripBridge::TabStripEmpty() { | 479 void TabStripBridge::TabStripEmpty() { |
495 NOTIMPLEMENTED(); | 480 NOTIMPLEMENTED(); |
496 } | 481 } |
OLD | NEW |