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 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 tabStripModel_->ContainsIndex(modelIndex)); | 1257 tabStripModel_->ContainsIndex(modelIndex)); |
1258 | 1258 |
1259 // Cancel any pending tab transition. | 1259 // Cancel any pending tab transition. |
1260 hoverTabSelector_->CancelTabTransition(); | 1260 hoverTabSelector_->CancelTabTransition(); |
1261 | 1261 |
1262 // Take closing tabs into account. | 1262 // Take closing tabs into account. |
1263 NSInteger index = [self indexFromModelIndex:modelIndex]; | 1263 NSInteger index = [self indexFromModelIndex:modelIndex]; |
1264 | 1264 |
1265 // Make a new tab. Load the contents of this tab from the nib and associate | 1265 // Make a new tab. Load the contents of this tab from the nib and associate |
1266 // the new controller with |contents| so it can be looked up later. | 1266 // the new controller with |contents| so it can be looked up later. |
1267 const BOOL autoEmbedFullscreen = | |
1268 implicit_cast<content::WebContentsDelegate*>(browser_)-> | |
1269 EmbedsFullscreenWidget(); | |
1270 base::scoped_nsobject<TabContentsController> contentsController( | 1267 base::scoped_nsobject<TabContentsController> contentsController( |
1271 [[TabContentsController alloc] initWithContents:contents | 1268 [[TabContentsController alloc] initWithContents:contents]); |
1272 andAutoEmbedFullscreen:autoEmbedFullscreen]); | |
1273 [tabContentsArray_ insertObject:contentsController atIndex:index]; | 1269 [tabContentsArray_ insertObject:contentsController atIndex:index]; |
1274 | 1270 |
1275 // Make a new tab and add it to the strip. Keep track of its controller. | 1271 // Make a new tab and add it to the strip. Keep track of its controller. |
1276 TabController* newController = [self newTab]; | 1272 TabController* newController = [self newTab]; |
1277 [newController setMini:tabStripModel_->IsMiniTab(modelIndex)]; | 1273 [newController setMini:tabStripModel_->IsMiniTab(modelIndex)]; |
1278 [newController setPinned:tabStripModel_->IsTabPinned(modelIndex)]; | 1274 [newController setPinned:tabStripModel_->IsTabPinned(modelIndex)]; |
1279 [newController setApp:tabStripModel_->IsAppTab(modelIndex)]; | 1275 [newController setApp:tabStripModel_->IsAppTab(modelIndex)]; |
1280 [newController setUrl:contents->GetURL()]; | 1276 [newController setUrl:contents->GetURL()]; |
1281 [tabArray_ insertObject:newController atIndex:index]; | 1277 [tabArray_ insertObject:newController atIndex:index]; |
1282 NSView* newView = [newController view]; | 1278 NSView* newView = [newController view]; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 previousContents:(content::WebContents*)oldContents | 1377 previousContents:(content::WebContents*)oldContents |
1382 atIndex:(NSInteger)modelIndex { | 1378 atIndex:(NSInteger)modelIndex { |
1383 NSInteger index = [self indexFromModelIndex:modelIndex]; | 1379 NSInteger index = [self indexFromModelIndex:modelIndex]; |
1384 TabContentsController* oldController = | 1380 TabContentsController* oldController = |
1385 [tabContentsArray_ objectAtIndex:index]; | 1381 [tabContentsArray_ objectAtIndex:index]; |
1386 DCHECK_EQ(oldContents, [oldController webContents]); | 1382 DCHECK_EQ(oldContents, [oldController webContents]); |
1387 | 1383 |
1388 // Simply create a new TabContentsController for |newContents| and place it | 1384 // Simply create a new TabContentsController for |newContents| and place it |
1389 // into the array, replacing |oldContents|. An ActiveTabChanged notification | 1385 // into the array, replacing |oldContents|. An ActiveTabChanged notification |
1390 // will follow, at which point we will install the new view. | 1386 // will follow, at which point we will install the new view. |
1391 const BOOL autoEmbedFullscreen = | |
1392 implicit_cast<content::WebContentsDelegate*>(browser_)-> | |
1393 EmbedsFullscreenWidget(); | |
1394 base::scoped_nsobject<TabContentsController> newController( | 1387 base::scoped_nsobject<TabContentsController> newController( |
1395 [[TabContentsController alloc] initWithContents:newContents | 1388 [[TabContentsController alloc] initWithContents:newContents]); |
1396 andAutoEmbedFullscreen:autoEmbedFullscreen]); | |
1397 | 1389 |
1398 // Bye bye, |oldController|. | 1390 // Bye bye, |oldController|. |
1399 [tabContentsArray_ replaceObjectAtIndex:index withObject:newController]; | 1391 [tabContentsArray_ replaceObjectAtIndex:index withObject:newController]; |
1400 | 1392 |
1401 // Fake a tab changed notification to force tab titles and favicons to update. | 1393 // Fake a tab changed notification to force tab titles and favicons to update. |
1402 [self tabChangedWithContents:newContents | 1394 [self tabChangedWithContents:newContents |
1403 atIndex:modelIndex | 1395 atIndex:modelIndex |
1404 changeType:TabStripModelObserver::ALL]; | 1396 changeType:TabStripModelObserver::ALL]; |
1405 } | 1397 } |
1406 | 1398 |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2229 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) { | 2221 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) { |
2230 // View hierarchy of the contents view: | 2222 // View hierarchy of the contents view: |
2231 // NSView -- switchView, same for all tabs | 2223 // NSView -- switchView, same for all tabs |
2232 // +- NSView -- TabContentsController's view | 2224 // +- NSView -- TabContentsController's view |
2233 // +- TabContentsViewCocoa | 2225 // +- TabContentsViewCocoa |
2234 // | 2226 // |
2235 // Changing it? Do not forget to modify | 2227 // Changing it? Do not forget to modify |
2236 // -[TabStripController swapInTabAtIndex:] too. | 2228 // -[TabStripController swapInTabAtIndex:] too. |
2237 return [web_contents->GetNativeView() superview]; | 2229 return [web_contents->GetNativeView() superview]; |
2238 } | 2230 } |
OLD | NEW |