| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cmath> | 9 #include <cmath> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 | 1240 |
| 1241 // Cancel any pending tab transition. | 1241 // Cancel any pending tab transition. |
| 1242 hoverTabSelector_->CancelTabTransition(); | 1242 hoverTabSelector_->CancelTabTransition(); |
| 1243 | 1243 |
| 1244 // Take closing tabs into account. | 1244 // Take closing tabs into account. |
| 1245 NSInteger index = [self indexFromModelIndex:modelIndex]; | 1245 NSInteger index = [self indexFromModelIndex:modelIndex]; |
| 1246 | 1246 |
| 1247 // Make a new tab. Load the contents of this tab from the nib and associate | 1247 // Make a new tab. Load the contents of this tab from the nib and associate |
| 1248 // the new controller with |contents| so it can be looked up later. | 1248 // the new controller with |contents| so it can be looked up later. |
| 1249 base::scoped_nsobject<TabContentsController> contentsController( | 1249 base::scoped_nsobject<TabContentsController> contentsController( |
| 1250 [[TabContentsController alloc] initWithContents:contents]); | 1250 [[TabContentsController alloc] |
| 1251 initWithContents:contents |
| 1252 isPopup:browser_->is_type_popup()]); |
| 1251 [tabContentsArray_ insertObject:contentsController atIndex:index]; | 1253 [tabContentsArray_ insertObject:contentsController atIndex:index]; |
| 1252 | 1254 |
| 1253 // Make a new tab and add it to the strip. Keep track of its controller. | 1255 // Make a new tab and add it to the strip. Keep track of its controller. |
| 1254 TabController* newController = [self newTab]; | 1256 TabController* newController = [self newTab]; |
| 1255 [newController setPinned:tabStripModel_->IsTabPinned(modelIndex)]; | 1257 [newController setPinned:tabStripModel_->IsTabPinned(modelIndex)]; |
| 1256 [newController setUrl:contents->GetURL()]; | 1258 [newController setUrl:contents->GetURL()]; |
| 1257 [tabArray_ insertObject:newController atIndex:index]; | 1259 [tabArray_ insertObject:newController atIndex:index]; |
| 1258 NSView* newView = [newController view]; | 1260 NSView* newView = [newController view]; |
| 1259 | 1261 |
| 1260 // Set the originating frame to just below the strip so that it animates | 1262 // Set the originating frame to just below the strip so that it animates |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 atIndex:(NSInteger)modelIndex { | 1357 atIndex:(NSInteger)modelIndex { |
| 1356 NSInteger index = [self indexFromModelIndex:modelIndex]; | 1358 NSInteger index = [self indexFromModelIndex:modelIndex]; |
| 1357 TabContentsController* oldController = | 1359 TabContentsController* oldController = |
| 1358 [tabContentsArray_ objectAtIndex:index]; | 1360 [tabContentsArray_ objectAtIndex:index]; |
| 1359 DCHECK_EQ(oldContents, [oldController webContents]); | 1361 DCHECK_EQ(oldContents, [oldController webContents]); |
| 1360 | 1362 |
| 1361 // Simply create a new TabContentsController for |newContents| and place it | 1363 // Simply create a new TabContentsController for |newContents| and place it |
| 1362 // into the array, replacing |oldContents|. An ActiveTabChanged notification | 1364 // into the array, replacing |oldContents|. An ActiveTabChanged notification |
| 1363 // will follow, at which point we will install the new view. | 1365 // will follow, at which point we will install the new view. |
| 1364 base::scoped_nsobject<TabContentsController> newController( | 1366 base::scoped_nsobject<TabContentsController> newController( |
| 1365 [[TabContentsController alloc] initWithContents:newContents]); | 1367 [[TabContentsController alloc] |
| 1368 initWithContents:newContents |
| 1369 isPopup:browser_->is_type_popup()]); |
| 1366 | 1370 |
| 1367 // Bye bye, |oldController|. | 1371 // Bye bye, |oldController|. |
| 1368 [tabContentsArray_ replaceObjectAtIndex:index withObject:newController]; | 1372 [tabContentsArray_ replaceObjectAtIndex:index withObject:newController]; |
| 1369 | 1373 |
| 1370 // Fake a tab changed notification to force tab titles and favicons to update. | 1374 // Fake a tab changed notification to force tab titles and favicons to update. |
| 1371 [self tabChangedWithContents:newContents | 1375 [self tabChangedWithContents:newContents |
| 1372 atIndex:modelIndex | 1376 atIndex:modelIndex |
| 1373 changeType:TabStripModelObserver::ALL]; | 1377 changeType:TabStripModelObserver::ALL]; |
| 1374 } | 1378 } |
| 1375 | 1379 |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2296 | 2300 |
| 2297 - (TabAlertState)alertStateForContents:(content::WebContents*)contents { | 2301 - (TabAlertState)alertStateForContents:(content::WebContents*)contents { |
| 2298 return chrome::GetTabAlertStateForContents(contents); | 2302 return chrome::GetTabAlertStateForContents(contents); |
| 2299 } | 2303 } |
| 2300 | 2304 |
| 2301 - (void)themeDidChangeNotification:(NSNotification*)notification { | 2305 - (void)themeDidChangeNotification:(NSNotification*)notification { |
| 2302 [newTabButton_ setImages]; | 2306 [newTabButton_ setImages]; |
| 2303 } | 2307 } |
| 2304 | 2308 |
| 2305 @end | 2309 @end |
| OLD | NEW |