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