Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.mm

Issue 2810193002: [ObjC ARC] Converts ios/chrome/browser/ui/tab_switcher:tab_switcher to ARC. (Closed)
Patch Set: comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.h" 5 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.h"
6 6
7 #include "base/ios/block_types.h" 7 #include "base/ios/block_types.h"
8 #include "base/ios/weak_nsobject.h"
9 #include "base/mac/scoped_nsobject.h"
10 #include "base/metrics/user_metrics.h" 8 #include "base/metrics/user_metrics.h"
11 #include "base/metrics/user_metrics_action.h" 9 #include "base/metrics/user_metrics_action.h"
12 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
13 #include "components/browser_sync/profile_sync_service.h" 11 #include "components/browser_sync/profile_sync_service.h"
14 #include "components/sessions/core/tab_restore_service_helper.h" 12 #include "components/sessions/core/tab_restore_service_helper.h"
15 #include "components/sync/driver/sync_service.h" 13 #include "components/sync/driver/sync_service.h"
16 #include "components/sync_sessions/open_tabs_ui_delegate.h" 14 #include "components/sync_sessions/open_tabs_ui_delegate.h"
17 #import "ios/chrome/browser/browser_state/chrome_browser_state.h" 15 #import "ios/chrome/browser/browser_state/chrome_browser_state.h"
18 #include "ios/chrome/browser/chrome_url_constants.h" 16 #include "ios/chrome/browser/chrome_url_constants.h"
19 #import "ios/chrome/browser/metrics/tab_usage_recorder.h" 17 #import "ios/chrome/browser/metrics/tab_usage_recorder.h"
(...skipping 26 matching lines...) Expand all
46 #include "ios/chrome/browser/ui/ui_util.h" 44 #include "ios/chrome/browser/ui/ui_util.h"
47 #import "ios/chrome/browser/ui/uikit_ui_util.h" 45 #import "ios/chrome/browser/ui/uikit_ui_util.h"
48 #include "ios/chrome/grit/ios_strings.h" 46 #include "ios/chrome/grit/ios_strings.h"
49 #include "ios/chrome/grit/ios_theme_resources.h" 47 #include "ios/chrome/grit/ios_theme_resources.h"
50 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h" 48 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h"
51 #import "ios/web/public/navigation_manager.h" 49 #import "ios/web/public/navigation_manager.h"
52 #include "ios/web/public/referrer.h" 50 #include "ios/web/public/referrer.h"
53 #include "ui/base/l10n/l10n_util.h" 51 #include "ui/base/l10n/l10n_util.h"
54 #include "ui/base/l10n/l10n_util_mac.h" 52 #include "ui/base/l10n/l10n_util_mac.h"
55 53
54 #if !defined(__has_feature) || !__has_feature(objc_arc)
55 #error "This file requires ARC support."
56 #endif
57
56 namespace { 58 namespace {
57 59
58 // Offsets for computing the panels' indexes in the TabSwitcherView. 60 // Offsets for computing the panels' indexes in the TabSwitcherView.
59 const int kSignInPromoPanelIndex = 2; 61 const int kSignInPromoPanelIndex = 2;
60 const int kHeaderDistantSessionIndexOffset = 2; 62 const int kHeaderDistantSessionIndexOffset = 2;
61 const int kLocalTabsOffTheRecordPanelIndex = 0; 63 const int kLocalTabsOffTheRecordPanelIndex = 0;
62 const int kLocalTabsOnTheRecordPanelIndex = 1; 64 const int kLocalTabsOnTheRecordPanelIndex = 1;
63 // The duration of the tab switcher toggle animation. 65 // The duration of the tab switcher toggle animation.
64 const CGFloat kTransitionAnimationDuration = 0.25; 66 const CGFloat kTransitionAnimationDuration = 0.25;
65 // The height of the browser view controller header. 67 // The height of the browser view controller header.
(...skipping 18 matching lines...) Expand all
84 TabSwitcherHeaderViewDataSource, 86 TabSwitcherHeaderViewDataSource,
85 TabSwitcherPanelControllerDelegate> { 87 TabSwitcherPanelControllerDelegate> {
86 // weak. 88 // weak.
87 ios::ChromeBrowserState* _browserState; 89 ios::ChromeBrowserState* _browserState;
88 // weak. 90 // weak.
89 id<TabSwitcherDelegate> _delegate; 91 id<TabSwitcherDelegate> _delegate;
90 // The model selected when the tab switcher was toggled. 92 // The model selected when the tab switcher was toggled.
91 // weak. 93 // weak.
92 TabModel* _onLoadActiveModel; 94 TabModel* _onLoadActiveModel;
93 // The view this controller manages. 95 // The view this controller manages.
94 base::scoped_nsobject<TabSwitcherView> _tabSwitcherView; 96 TabSwitcherView* _tabSwitcherView;
95 // The list of panels controllers for distant sessions. 97 // The list of panels controllers for distant sessions.
96 base::scoped_nsobject<NSMutableArray> _controllersOfDistantSessions; 98 NSMutableArray* _controllersOfDistantSessions;
97 // The panel controllers for the local sessions. 99 // The panel controllers for the local sessions.
98 base::scoped_nsobject<TabSwitcherPanelController> _onTheRecordSession; 100 TabSwitcherPanelController* _onTheRecordSession;
99 base::scoped_nsobject<TabSwitcherPanelController> _offTheRecordSession; 101 TabSwitcherPanelController* _offTheRecordSession;
100 // The model storing the state of what is shown by the tab switcher. 102 // The model storing the state of what is shown by the tab switcher.
101 base::scoped_nsobject<TabSwitcherModel> _tabSwitcherModel; 103 TabSwitcherModel* _tabSwitcherModel;
102 // Stores the current sign-in panel type. 104 // Stores the current sign-in panel type.
103 TabSwitcherSignInPanelsType _signInPanelType; 105 TabSwitcherSignInPanelsType _signInPanelType;
104 // Cache for the panel's cells. 106 // Cache for the panel's cells.
105 base::scoped_nsobject<TabSwitcherCache> _cache; 107 TabSwitcherCache* _cache;
106 // Stores the background color of the window when the tab switcher was 108 // Stores the background color of the window when the tab switcher was
107 // presented. 109 // presented.
108 base::scoped_nsobject<UIColor> _initialWindowBackgroundColor; 110 UIColor* _initialWindowBackgroundColor;
109 // Indicate whether a previous promo panel header cell should be removed or 111 // Indicate whether a previous promo panel header cell should be removed or
110 // added. 112 // added.
111 BOOL _shouldRemovePromoPanelHeaderCell; 113 BOOL _shouldRemovePromoPanelHeaderCell;
112 BOOL _shouldAddPromoPanelHeaderCell; 114 BOOL _shouldAddPromoPanelHeaderCell;
113 } 115 }
114 116
115 // Updates the window background color to the tab switcher's background color. 117 // Updates the window background color to the tab switcher's background color.
116 // The original background color can be restored by calling 118 // The original background color can be restored by calling
117 // -restoreWindowBackgroundColor. 119 // -restoreWindowBackgroundColor.
118 - (void)updateWindowBackgroundColor; 120 - (void)updateWindowBackgroundColor;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 mainTabModel:(TabModel*)mainTabModel 188 mainTabModel:(TabModel*)mainTabModel
187 otrTabModel:(TabModel*)otrTabModel 189 otrTabModel:(TabModel*)otrTabModel
188 activeTabModel:(TabModel*)activeTabModel { 190 activeTabModel:(TabModel*)activeTabModel {
189 DCHECK(mainTabModel); 191 DCHECK(mainTabModel);
190 DCHECK(otrTabModel); 192 DCHECK(otrTabModel);
191 DCHECK(activeTabModel == otrTabModel || activeTabModel == mainTabModel); 193 DCHECK(activeTabModel == otrTabModel || activeTabModel == mainTabModel);
192 self = [super initWithNibName:nil bundle:nil]; 194 self = [super initWithNibName:nil bundle:nil];
193 if (self) { 195 if (self) {
194 _browserState = browserState; 196 _browserState = browserState;
195 _onLoadActiveModel = activeTabModel; 197 _onLoadActiveModel = activeTabModel;
196 _cache.reset([[TabSwitcherCache alloc] init]); 198 _cache = [[TabSwitcherCache alloc] init];
197 [_cache setMainTabModel:mainTabModel otrTabModel:otrTabModel]; 199 [_cache setMainTabModel:mainTabModel otrTabModel:otrTabModel];
198 _tabSwitcherModel.reset([[TabSwitcherModel alloc] 200 _tabSwitcherModel =
199 initWithBrowserState:browserState 201 [[TabSwitcherModel alloc] initWithBrowserState:browserState
200 delegate:self 202 delegate:self
201 mainTabModel:mainTabModel 203 mainTabModel:mainTabModel
202 otrTabModel:otrTabModel 204 otrTabModel:otrTabModel
203 withCache:_cache]); 205 withCache:_cache];
204 _controllersOfDistantSessions.reset([[NSMutableArray alloc] init]); 206 _controllersOfDistantSessions = [[NSMutableArray alloc] init];
205 [self loadTabSwitcherView]; 207 [self loadTabSwitcherView];
206 _onTheRecordSession.reset([[TabSwitcherPanelController alloc] 208 _onTheRecordSession = [[TabSwitcherPanelController alloc]
207 initWithModel:_tabSwitcherModel 209 initWithModel:_tabSwitcherModel
208 forLocalSessionOfType:TabSwitcherSessionType::REGULAR_SESSION 210 forLocalSessionOfType:TabSwitcherSessionType::REGULAR_SESSION
209 withCache:_cache 211 withCache:_cache
210 browserState:_browserState]); 212 browserState:_browserState];
211 [_onTheRecordSession setDelegate:self]; 213 [_onTheRecordSession setDelegate:self];
212 _offTheRecordSession.reset([[TabSwitcherPanelController alloc] 214 _offTheRecordSession = [[TabSwitcherPanelController alloc]
213 initWithModel:_tabSwitcherModel 215 initWithModel:_tabSwitcherModel
214 forLocalSessionOfType:TabSwitcherSessionType::OFF_THE_RECORD_SESSION 216 forLocalSessionOfType:TabSwitcherSessionType::OFF_THE_RECORD_SESSION
215 withCache:_cache 217 withCache:_cache
216 browserState:_browserState]); 218 browserState:_browserState];
217 [_offTheRecordSession setDelegate:self]; 219 [_offTheRecordSession setDelegate:self];
218 [_tabSwitcherView addPanelView:[_offTheRecordSession view] 220 [_tabSwitcherView addPanelView:[_offTheRecordSession view]
219 atIndex:kLocalTabsOffTheRecordPanelIndex]; 221 atIndex:kLocalTabsOffTheRecordPanelIndex];
220 [_tabSwitcherView addPanelView:[_onTheRecordSession view] 222 [_tabSwitcherView addPanelView:[_onTheRecordSession view]
221 atIndex:kLocalTabsOnTheRecordPanelIndex]; 223 atIndex:kLocalTabsOnTheRecordPanelIndex];
222 [self addPromoPanelForSignInPanelType:[_tabSwitcherModel signInPanelType]]; 224 [self addPromoPanelForSignInPanelType:[_tabSwitcherModel signInPanelType]];
223 [[_tabSwitcherView headerView] reloadData]; 225 [[_tabSwitcherView headerView] reloadData];
224 [_tabSwitcherModel syncedSessionsChanged]; 226 [_tabSwitcherModel syncedSessionsChanged];
225 [self selectPanelForTabModel:_onLoadActiveModel]; 227 [self selectPanelForTabModel:_onLoadActiveModel];
226 } 228 }
227 return self; 229 return self;
228 } 230 }
229 231
230 #pragma mark - UIViewController 232 #pragma mark - UIViewController
231 233
232 - (BOOL)prefersStatusBarHidden { 234 - (BOOL)prefersStatusBarHidden {
233 return NO; 235 return NO;
234 } 236 }
235 237
236 - (UIStatusBarStyle)preferredStatusBarStyle { 238 - (UIStatusBarStyle)preferredStatusBarStyle {
237 return UIStatusBarStyleLightContent; 239 return UIStatusBarStyleLightContent;
238 } 240 }
239 241
240 - (CGRect)tabSwitcherInitialFrame { 242 - (CGRect)tabSwitcherInitialFrame {
241 return [[UIScreen mainScreen] bounds]; 243 return [[UIScreen mainScreen] bounds];
242 } 244 }
243 245
244 - (void)loadTabSwitcherView { 246 - (void)loadTabSwitcherView {
245 DCHECK(![_tabSwitcherView superview]); 247 DCHECK(![_tabSwitcherView superview]);
246 _tabSwitcherView.reset( 248 _tabSwitcherView =
247 [[TabSwitcherView alloc] initWithFrame:[self tabSwitcherInitialFrame]]); 249 [[TabSwitcherView alloc] initWithFrame:[self tabSwitcherInitialFrame]];
248 [_tabSwitcherView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | 250 [_tabSwitcherView setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
249 UIViewAutoresizingFlexibleHeight]; 251 UIViewAutoresizingFlexibleHeight];
250 [_tabSwitcherView setDelegate:self]; 252 [_tabSwitcherView setDelegate:self];
251 [[_tabSwitcherView headerView] setDelegate:self]; 253 [[_tabSwitcherView headerView] setDelegate:self];
252 [[_tabSwitcherView headerView] setDataSource:self]; 254 [[_tabSwitcherView headerView] setDataSource:self];
253 } 255 }
254 256
255 - (void)viewDidLoad { 257 - (void)viewDidLoad {
256 [super viewDidLoad]; 258 [super viewDidLoad];
257 [self.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | 259 [self.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
258 UIViewAutoresizingFlexibleHeight]; 260 UIViewAutoresizingFlexibleHeight];
259 [_tabSwitcherView setFrame:self.view.bounds]; 261 [_tabSwitcherView setFrame:self.view.bounds];
260 [self.view addSubview:_tabSwitcherView]; 262 [self.view addSubview:_tabSwitcherView];
261 } 263 }
262 264
263 #pragma mark - UIResponder 265 #pragma mark - UIResponder
264 266
265 - (NSArray*)keyCommands { 267 - (NSArray*)keyCommands {
266 base::WeakNSObject<TabSwitcherController> weakSelf(self); 268 __weak TabSwitcherController* weakSelf = self;
267 return @[ 269 return @[
268 [UIKeyCommand 270 [UIKeyCommand
269 cr_keyCommandWithInput:@"t" 271 cr_keyCommandWithInput:@"t"
270 modifierFlags:UIKeyModifierCommand 272 modifierFlags:UIKeyModifierCommand
271 title:l10n_util::GetNSStringWithFixup( 273 title:l10n_util::GetNSStringWithFixup(
272 IDS_IOS_TOOLS_MENU_NEW_TAB) 274 IDS_IOS_TOOLS_MENU_NEW_TAB)
273 action:^{ 275 action:^{
274 base::scoped_nsobject<TabSwitcherController> 276 TabSwitcherController* strongSelf = weakSelf;
275 strongSelf([weakSelf retain]);
276 if (!strongSelf) 277 if (!strongSelf)
277 return; 278 return;
278 if ([strongSelf currentPanelIndex] == 279 if ([strongSelf currentPanelIndex] ==
279 kLocalTabsOffTheRecordPanelIndex) { 280 kLocalTabsOffTheRecordPanelIndex) {
280 [strongSelf openNewTabInPanelAtIndex: 281 [strongSelf openNewTabInPanelAtIndex:
281 kLocalTabsOffTheRecordPanelIndex]; 282 kLocalTabsOffTheRecordPanelIndex];
282 } else { 283 } else {
283 [strongSelf openNewTabInPanelAtIndex: 284 [strongSelf openNewTabInPanelAtIndex:
284 kLocalTabsOnTheRecordPanelIndex]; 285 kLocalTabsOnTheRecordPanelIndex];
285 } 286 }
(...skipping 13 matching lines...) Expand all
299 title:l10n_util::GetNSStringWithFixup( 300 title:l10n_util::GetNSStringWithFixup(
300 IDS_IOS_KEYBOARD_REOPEN_CLOSED_TAB) 301 IDS_IOS_KEYBOARD_REOPEN_CLOSED_TAB)
301 action:^{ 302 action:^{
302 [weakSelf reopenClosedTab]; 303 [weakSelf reopenClosedTab];
303 }], 304 }],
304 [UIKeyCommand 305 [UIKeyCommand
305 cr_keyCommandWithInput:@"n" 306 cr_keyCommandWithInput:@"n"
306 modifierFlags:UIKeyModifierCommand 307 modifierFlags:UIKeyModifierCommand
307 title:nil 308 title:nil
308 action:^{ 309 action:^{
309 base::scoped_nsobject<TabSwitcherController> 310 TabSwitcherController* strongSelf = weakSelf;
310 strongSelf([weakSelf retain]);
311 if (!strongSelf) 311 if (!strongSelf)
312 return; 312 return;
313 if ([strongSelf currentPanelIndex] == 313 if ([strongSelf currentPanelIndex] ==
314 kLocalTabsOffTheRecordPanelIndex) { 314 kLocalTabsOffTheRecordPanelIndex) {
315 [strongSelf openNewTabInPanelAtIndex: 315 [strongSelf openNewTabInPanelAtIndex:
316 kLocalTabsOffTheRecordPanelIndex]; 316 kLocalTabsOffTheRecordPanelIndex];
317 } else { 317 } else {
318 [strongSelf openNewTabInPanelAtIndex: 318 [strongSelf openNewTabInPanelAtIndex:
319 kLocalTabsOnTheRecordPanelIndex]; 319 kLocalTabsOnTheRecordPanelIndex];
320 } 320 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 default: 403 default:
404 [super chromeExecuteCommand:sender]; 404 [super chromeExecuteCommand:sender];
405 break; 405 break;
406 } 406 }
407 } 407 }
408 408
409 #pragma mark - Private 409 #pragma mark - Private
410 410
411 - (void)updateWindowBackgroundColor { 411 - (void)updateWindowBackgroundColor {
412 DCHECK(!_initialWindowBackgroundColor); 412 DCHECK(!_initialWindowBackgroundColor);
413 _initialWindowBackgroundColor.reset( 413 _initialWindowBackgroundColor = self.view.window.backgroundColor;
414 [self.view.window.backgroundColor retain]);
415 self.view.window.backgroundColor = [[MDCPalette greyPalette] tint900]; 414 self.view.window.backgroundColor = [[MDCPalette greyPalette] tint900];
416 } 415 }
417 416
418 - (void)restoreWindowBackgroundColor { 417 - (void)restoreWindowBackgroundColor {
419 self.view.window.backgroundColor = _initialWindowBackgroundColor; 418 self.view.window.backgroundColor = _initialWindowBackgroundColor;
420 _initialWindowBackgroundColor.reset(); 419 _initialWindowBackgroundColor = nil;
421 } 420 }
422 421
423 - (UIView*)snapshotViewForView:(UIView*)inputView 422 - (UIView*)snapshotViewForView:(UIView*)inputView
424 withModel:(TabModel*)tabModel 423 withModel:(TabModel*)tabModel
425 option:(SnapshotViewOption)option { 424 option:(SnapshotViewOption)option {
426 if (inputView) { 425 if (inputView) {
427 if (option == SnapshotViewOption::SNAPSHOT_VIEW) { 426 if (option == SnapshotViewOption::SNAPSHOT_VIEW) {
428 UIView* view = [inputView snapshotViewAfterScreenUpdates:NO]; 427 UIView* view = [inputView snapshotViewAfterScreenUpdates:NO];
429 if (view) 428 if (view)
430 return view; 429 return view;
431 } 430 }
432 // If the view has just been created, it has not been rendered by Core 431 // If the view has just been created, it has not been rendered by Core
433 // Animation and the snapshot view can't be generated. In that case we 432 // Animation and the snapshot view can't be generated. In that case we
434 // trigger a client side rendering of the view and use the rendered image 433 // trigger a client side rendering of the view and use the rendered image
435 // as the backing store of a view layer. 434 // as the backing store of a view layer.
436 UIGraphicsBeginImageContextWithOptions(inputView.bounds.size, 435 UIGraphicsBeginImageContextWithOptions(inputView.bounds.size,
437 inputView.opaque, 0); 436 inputView.opaque, 0);
438 [inputView.layer renderInContext:UIGraphicsGetCurrentContext()]; 437 [inputView.layer renderInContext:UIGraphicsGetCurrentContext()];
439 UIImage* screenshot = UIGraphicsGetImageFromCurrentImageContext(); 438 UIImage* screenshot = UIGraphicsGetImageFromCurrentImageContext();
440 UIGraphicsEndImageContext(); 439 UIGraphicsEndImageContext();
441 UIView* view = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; 440 UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
442 [view layer].contents = static_cast<id>(screenshot.CGImage); 441 [view layer].contents = static_cast<id>(screenshot.CGImage);
443 return view; 442 return view;
444 } else { 443 } else {
445 // When the input view is nil, we can't generate a snapshot so a placeholder 444 // When the input view is nil, we can't generate a snapshot so a placeholder
446 // is returned. 445 // is returned.
447 UIColor* backgroundColor = [tabModel isOffTheRecord] 446 UIColor* backgroundColor = [tabModel isOffTheRecord]
448 ? [[MDCPalette greyPalette] tint700] 447 ? [[MDCPalette greyPalette] tint700]
449 : [[MDCPalette greyPalette] tint100]; 448 : [[MDCPalette greyPalette] tint100];
450 UIView* placeholdView = 449 UIView* placeholdView = [[UIView alloc] initWithFrame:CGRectZero];
451 [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
452 placeholdView.backgroundColor = backgroundColor; 450 placeholdView.backgroundColor = backgroundColor;
453 return placeholdView; 451 return placeholdView;
454 } 452 }
455 } 453 }
456 454
457 - (TabSwitcherTransitionContextContent*)transitionContextContentForTabModel: 455 - (TabSwitcherTransitionContextContent*)transitionContextContentForTabModel:
458 (TabModel*)tabModel { 456 (TabModel*)tabModel {
459 if ([tabModel isOffTheRecord]) 457 if ([tabModel isOffTheRecord])
460 return self.transitionContext.incognitoContent; 458 return self.transitionContext.incognitoContent;
461 else 459 else
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 548
551 // Compute initial and final toolbar screenshot frames. 549 // Compute initial and final toolbar screenshot frames.
552 const CGRect initialToolbarFrame = toolbarController.view.frame; 550 const CGRect initialToolbarFrame = toolbarController.view.frame;
553 CGRect initialToolbarScreenshotFrame = CGRectMake( 551 CGRect initialToolbarScreenshotFrame = CGRectMake(
554 0, 0, initialToolbarFrame.size.width, initialToolbarFrame.size.height); 552 0, 0, initialToolbarFrame.size.width, initialToolbarFrame.size.height);
555 553
556 const CGFloat cellTopBarHeight = tabSwitcherLocalSessionCellTopBarHeight(); 554 const CGFloat cellTopBarHeight = tabSwitcherLocalSessionCellTopBarHeight();
557 CGRect finalToolbarScreenshotFrame = 555 CGRect finalToolbarScreenshotFrame =
558 CGRectMake(0, 0, selectedCellFrame.size.width, cellTopBarHeight); 556 CGRectMake(0, 0, selectedCellFrame.size.width, cellTopBarHeight);
559 557
560 base::scoped_nsobject<UIImageView> tabScreenshotImageView( 558 UIImageView* tabScreenshotImageView =
561 [[UIImageView alloc] initWithFrame:CGRectZero]); 559 [[UIImageView alloc] initWithFrame:CGRectZero];
562 560
563 base::WeakNSObject<UIImageView> weakTabScreenshotImageView( 561 __weak UIImageView* weakTabScreenshotImageView = tabScreenshotImageView;
564 tabScreenshotImageView.get());
565 562
566 if ([self initialTabModelAndTabIDMatchesTabModel:tabModel 563 if ([self initialTabModelAndTabIDMatchesTabModel:tabModel
567 tabID:selectedTab.tabId]) { 564 tabID:selectedTab.tabId]) {
568 tabScreenshotImageView.get().image = 565 tabScreenshotImageView.image = self.transitionContext.tabSnapshotImage;
569 self.transitionContext.tabSnapshotImage;
570 } else { 566 } else {
571 // If transitioning to a different tab than the one animated in 567 // If transitioning to a different tab than the one animated in
572 // from, a new snapshot should be generated instead of using the transition 568 // from, a new snapshot should be generated instead of using the transition
573 // context 569 // context
574 tabScreenshotImageView.get().image = 570 tabScreenshotImageView.image =
575 [self updateScreenshotForCellIfNeeded:selectedCell tabModel:tabModel]; 571 [self updateScreenshotForCellIfNeeded:selectedCell tabModel:tabModel];
576 [selectedTab retrieveSnapshot:^(UIImage* snapshot) { 572 [selectedTab retrieveSnapshot:^(UIImage* snapshot) {
577 [weakTabScreenshotImageView setImage:snapshot]; 573 [weakTabScreenshotImageView setImage:snapshot];
578 }]; 574 }];
579 } 575 }
580 576
581 const CGSize tabScreenshotImageSize = tabScreenshotImageView.get().image.size; 577 const CGSize tabScreenshotImageSize = tabScreenshotImageView.image.size;
582 578
583 CGRect initialTabScreenshotFrame = CGRectZero; 579 CGRect initialTabScreenshotFrame = CGRectZero;
584 const CGSize toolbarSize = toolbarController.view.bounds.size; 580 const CGSize toolbarSize = toolbarController.view.bounds.size;
585 CGSize initialTabTargetSize = 581 CGSize initialTabTargetSize =
586 CGSizeMake(initialTabFrame.size.width, 582 CGSizeMake(initialTabFrame.size.width,
587 initialTabFrame.size.height - toolbarSize.height); 583 initialTabFrame.size.height - toolbarSize.height);
588 CGSize revisedTargetSize = CGSizeZero; 584 CGSize revisedTargetSize = CGSizeZero;
589 CalculateProjection(tabScreenshotImageSize, initialTabTargetSize, 585 CalculateProjection(tabScreenshotImageSize, initialTabTargetSize,
590 ProjectionMode::kAspectFill, revisedTargetSize, 586 ProjectionMode::kAspectFill, revisedTargetSize,
591 initialTabScreenshotFrame); 587 initialTabScreenshotFrame);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 std::swap(initialToolbarScreenshotFrame, finalToolbarScreenshotFrame); 625 std::swap(initialToolbarScreenshotFrame, finalToolbarScreenshotFrame);
630 } else { 626 } else {
631 [tabStripPlaceholderView foldWithCompletion:^{ 627 [tabStripPlaceholderView foldWithCompletion:^{
632 [tabStripPlaceholderView removeFromSuperview]; 628 [tabStripPlaceholderView removeFromSuperview];
633 }]; 629 }];
634 } 630 }
635 631
636 tabStripPlaceholderView.frame = tabStripInitialFrame; 632 tabStripPlaceholderView.frame = tabStripInitialFrame;
637 633
638 // Create and setup placeholder view and subviews. 634 // Create and setup placeholder view and subviews.
639 base::scoped_nsobject<UIView> placeholderView( 635 UIView* placeholderView = [[UIView alloc] initWithFrame:initialTabFrame];
640 [[UIView alloc] initWithFrame:initialTabFrame]);
641 [placeholderView setClipsToBounds:YES]; 636 [placeholderView setClipsToBounds:YES];
642 [placeholderView setUserInteractionEnabled:NO]; 637 [placeholderView setUserInteractionEnabled:NO];
643 638
644 tabScreenshotImageView.get().frame = initialTabScreenshotFrame; 639 tabScreenshotImageView.frame = initialTabScreenshotFrame;
645 tabScreenshotImageView.get().contentMode = UIViewContentModeScaleToFill; 640 tabScreenshotImageView.contentMode = UIViewContentModeScaleToFill;
646 tabScreenshotImageView.get().autoresizingMask = UIViewAutoresizingNone; 641 tabScreenshotImageView.autoresizingMask = UIViewAutoresizingNone;
647 [placeholderView addSubview:tabScreenshotImageView]; 642 [placeholderView addSubview:tabScreenshotImageView];
648 643
649 // Try using a snapshot view for dismissal animation because it's faster and 644 // Try using a snapshot view for dismissal animation because it's faster and
650 // the collection view has already been rendered. Use a client rendering 645 // the collection view has already been rendered. Use a client rendering
651 // otherwise. 646 // otherwise.
652 SnapshotViewOption snapshotOption = SnapshotViewOption::SNAPSHOT_VIEW; 647 SnapshotViewOption snapshotOption = SnapshotViewOption::SNAPSHOT_VIEW;
653 if (transitionType == TransitionType::TRANSITION_PRESENT) 648 if (transitionType == TransitionType::TRANSITION_PRESENT)
654 snapshotOption = SnapshotViewOption::CLIENT_RENDERING; 649 snapshotOption = SnapshotViewOption::CLIENT_RENDERING;
655 650
656 UIView* finalToolbarScreenshotImageView = 651 UIView* finalToolbarScreenshotImageView =
657 [self snapshotViewForView:selectedCell.topBar 652 [self snapshotViewForView:selectedCell.topBar
658 withModel:tabModel 653 withModel:tabModel
659 option:snapshotOption]; 654 option:snapshotOption];
660 finalToolbarScreenshotImageView.autoresizingMask = UIViewAutoresizingNone; 655 finalToolbarScreenshotImageView.autoresizingMask = UIViewAutoresizingNone;
661 finalToolbarScreenshotImageView.frame = initialToolbarScreenshotFrame; 656 finalToolbarScreenshotImageView.frame = initialToolbarScreenshotFrame;
662 [placeholderView addSubview:finalToolbarScreenshotImageView]; 657 [placeholderView addSubview:finalToolbarScreenshotImageView];
663 658
664 UIView* toolbarScreenshotImageView = 659 UIView* toolbarScreenshotImageView =
665 transitionContextContent.toolbarSnapshotView; 660 transitionContextContent.toolbarSnapshotView;
666 toolbarScreenshotImageView.autoresizingMask = UIViewAutoresizingNone; 661 toolbarScreenshotImageView.autoresizingMask = UIViewAutoresizingNone;
667 toolbarScreenshotImageView.frame = initialToolbarScreenshotFrame; 662 toolbarScreenshotImageView.frame = initialToolbarScreenshotFrame;
668 [placeholderView addSubview:toolbarScreenshotImageView]; 663 [placeholderView addSubview:toolbarScreenshotImageView];
669 664
670 base::scoped_nsobject<UIImageView> toolbarShadowImageView( 665 UIImageView* toolbarShadowImageView =
671 [[UIImageView alloc] initWithFrame:shadowInitialFrame]); 666 [[UIImageView alloc] initWithFrame:shadowInitialFrame];
672 [toolbarShadowImageView setAutoresizingMask:UIViewAutoresizingNone]; 667 [toolbarShadowImageView setAutoresizingMask:UIViewAutoresizingNone];
673 [toolbarShadowImageView setImage:NativeImage(IDR_IOS_TOOLBAR_SHADOW)]; 668 [toolbarShadowImageView setImage:NativeImage(IDR_IOS_TOOLBAR_SHADOW)];
674 [placeholderView addSubview:toolbarShadowImageView]; 669 [placeholderView addSubview:toolbarShadowImageView];
675 670
676 [self.view addSubview:placeholderView]; 671 [self.view addSubview:placeholderView];
677 672
678 [selectedCell setHidden:YES]; 673 [selectedCell setHidden:YES];
679 toolbarScreenshotImageView.alpha = 674 toolbarScreenshotImageView.alpha =
680 (transitionType == TransitionType::TRANSITION_DISMISS) ? 0 : 1.0; 675 (transitionType == TransitionType::TRANSITION_DISMISS) ? 0 : 1.0;
681 676
682 base::WeakNSObject<TabSwitcherController> weakSelf(self); 677 __weak TabSwitcherController* weakSelf = self;
683 void (^completionBlock)(BOOL) = ^(BOOL finished) { 678 void (^completionBlock)(BOOL) = ^(BOOL finished) {
684 base::scoped_nsobject<TabSwitcherController> strongSelf([weakSelf retain]); 679 TabSwitcherController* strongSelf = weakSelf;
685 680
686 [tabStripPlaceholderView removeFromSuperview]; 681 [tabStripPlaceholderView removeFromSuperview];
687 [toolbarScreenshotImageView removeFromSuperview]; 682 [toolbarScreenshotImageView removeFromSuperview];
688 [selectedCell setHidden:NO]; 683 [selectedCell setHidden:NO];
689 [placeholderView removeFromSuperview]; 684 [placeholderView removeFromSuperview];
690 685
691 if (transitionType == TransitionType::TRANSITION_DISMISS) { 686 if (transitionType == TransitionType::TRANSITION_DISMISS) {
692 [strongSelf restoreWindowBackgroundColor]; 687 [strongSelf restoreWindowBackgroundColor];
693 if (finished) { 688 if (finished) {
694 [strongSelf setTransitionContext:nil]; 689 [strongSelf setTransitionContext:nil];
695 } 690 }
696 } 691 }
697 [[[strongSelf delegate] tabSwitcherTransitionToolbarOwner] 692 [[[strongSelf delegate] tabSwitcherTransitionToolbarOwner]
698 reparentToolbarController]; 693 reparentToolbarController];
699 [[strongSelf view] setUserInteractionEnabled:YES]; 694 [[strongSelf view] setUserInteractionEnabled:YES];
700 completion(); 695 completion();
701 }; 696 };
702 697
703 ProceduralBlock animationBlock = ^{ 698 ProceduralBlock animationBlock = ^{
704 toolbarScreenshotImageView.alpha = 699 toolbarScreenshotImageView.alpha =
705 transitionType == TransitionType::TRANSITION_DISMISS ? 1.0 : 0; 700 transitionType == TransitionType::TRANSITION_DISMISS ? 1.0 : 0;
706 tabStripPlaceholderView.frame = tabStripFinalFrame; 701 tabStripPlaceholderView.frame = tabStripFinalFrame;
707 toolbarShadowImageView.get().frame = shadowFinalFrame; 702 toolbarShadowImageView.frame = shadowFinalFrame;
708 placeholderView.get().frame = finalTabFrame; 703 placeholderView.frame = finalTabFrame;
709 toolbarScreenshotImageView.frame = finalToolbarScreenshotFrame; 704 toolbarScreenshotImageView.frame = finalToolbarScreenshotFrame;
710 finalToolbarScreenshotImageView.frame = finalToolbarScreenshotFrame; 705 finalToolbarScreenshotImageView.frame = finalToolbarScreenshotFrame;
711 tabScreenshotImageView.get().frame = finalTabScreenshotFrame; 706 tabScreenshotImageView.frame = finalTabScreenshotFrame;
712 }; 707 };
713 708
714 [UIView animateWithDuration:animated ? kTransitionAnimationDuration : 0 709 [UIView animateWithDuration:animated ? kTransitionAnimationDuration : 0
715 delay:0 710 delay:0
716 options:UIViewAnimationCurveEaseInOut 711 options:UIViewAnimationCurveEaseInOut
717 animations:animationBlock 712 animations:animationBlock
718 completion:completionBlock]; 713 completion:completionBlock];
719 } 714 }
720 715
721 - (BOOL)initialTabModelAndTabIDMatchesTabModel:(nonnull TabModel*)tabModel 716 - (BOOL)initialTabModelAndTabIDMatchesTabModel:(nonnull TabModel*)tabModel
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 (selectedTabModel == [_tabSwitcherModel otrTabModel]) 780 (selectedTabModel == [_tabSwitcherModel otrTabModel])
786 ? kLocalTabsOffTheRecordPanelIndex 781 ? kLocalTabsOffTheRecordPanelIndex
787 : kLocalTabsOnTheRecordPanelIndex; 782 : kLocalTabsOnTheRecordPanelIndex;
788 [_tabSwitcherView selectPanelAtIndex:selectedPanel]; 783 [_tabSwitcherView selectPanelAtIndex:selectedPanel];
789 } 784 }
790 785
791 - (TabSwitcherPanelController*)panelControllerForTabModel:(TabModel*)tabModel { 786 - (TabSwitcherPanelController*)panelControllerForTabModel:(TabModel*)tabModel {
792 DCHECK(tabModel == [_tabSwitcherModel mainTabModel] || 787 DCHECK(tabModel == [_tabSwitcherModel mainTabModel] ||
793 tabModel == [_tabSwitcherModel otrTabModel]); 788 tabModel == [_tabSwitcherModel otrTabModel]);
794 if (tabModel == [_tabSwitcherModel mainTabModel]) 789 if (tabModel == [_tabSwitcherModel mainTabModel])
795 return _onTheRecordSession.get(); 790 return _onTheRecordSession;
796 if (tabModel == [_tabSwitcherModel otrTabModel]) 791 if (tabModel == [_tabSwitcherModel otrTabModel])
797 return _offTheRecordSession.get(); 792 return _offTheRecordSession;
798 return nil; 793 return nil;
799 } 794 }
800 795
801 - (void)tabSwitcherDismissWithModel:(TabModel*)model { 796 - (void)tabSwitcherDismissWithModel:(TabModel*)model {
802 [self tabSwitcherDismissWithModel:model animated:YES]; 797 [self tabSwitcherDismissWithModel:model animated:YES];
803 } 798 }
804 799
805 - (void)tabSwitcherDismissWithModel:(TabModel*)model animated:(BOOL)animated { 800 - (void)tabSwitcherDismissWithModel:(TabModel*)model animated:(BOOL)animated {
806 [self tabSwitcherDismissWithModel:model 801 [self tabSwitcherDismissWithModel:model
807 animated:animated 802 animated:animated
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 // with the indexes in |_controllersOfDistantSessions|. 940 // with the indexes in |_controllersOfDistantSessions|.
946 for (NSNumber* objCIndex in [removedIndexes reverseObjectEnumerator]) { 941 for (NSNumber* objCIndex in [removedIndexes reverseObjectEnumerator]) {
947 int index = [objCIndex intValue]; 942 int index = [objCIndex intValue];
948 [_tabSwitcherView removePanelViewAtIndex:index + offset]; 943 [_tabSwitcherView removePanelViewAtIndex:index + offset];
949 [_controllersOfDistantSessions removeObjectAtIndex:index]; 944 [_controllersOfDistantSessions removeObjectAtIndex:index];
950 } 945 }
951 946
952 for (NSNumber* objCIndex in insertedIndexes) { 947 for (NSNumber* objCIndex in insertedIndexes) {
953 int index = [objCIndex intValue]; 948 int index = [objCIndex intValue];
954 std::string tag = [_tabSwitcherModel tagOfDistantSessionAtIndex:index]; 949 std::string tag = [_tabSwitcherModel tagOfDistantSessionAtIndex:index];
955 base::scoped_nsobject<TabSwitcherPanelController> panelController( 950 TabSwitcherPanelController* panelController =
956 [[TabSwitcherPanelController alloc] initWithModel:_tabSwitcherModel 951 [[TabSwitcherPanelController alloc] initWithModel:_tabSwitcherModel
957 forDistantSessionWithTag:tag 952 forDistantSessionWithTag:tag
958 browserState:_browserState]); 953 browserState:_browserState];
959 [panelController setDelegate:self]; 954 [panelController setDelegate:self];
960 [_tabSwitcherView addPanelView:[panelController view] 955 [_tabSwitcherView addPanelView:[panelController view]
961 atIndex:index + offset]; 956 atIndex:index + offset];
962 [_controllersOfDistantSessions insertObject:panelController.get() 957 [_controllersOfDistantSessions insertObject:panelController atIndex:index];
963 atIndex:index];
964 } 958 }
965 959
966 // Update the header view. 960 // Update the header view.
967 // The header view's content is created using the panel's content. 961 // The header view's content is created using the panel's content.
968 [[_tabSwitcherView headerView] reloadData]; 962 [[_tabSwitcherView headerView] reloadData];
969 } 963 }
970 964
971 - (void)distantSessionMayNeedUpdate:(std::string const&)tag { 965 - (void)distantSessionMayNeedUpdate:(std::string const&)tag {
972 for (TabSwitcherPanelController* panel in _controllersOfDistantSessions 966 for (TabSwitcherPanelController* panel in _controllersOfDistantSessions) {
973 .get()) {
974 DCHECK([panel isKindOfClass:[TabSwitcherPanelController class]]); 967 DCHECK([panel isKindOfClass:[TabSwitcherPanelController class]]);
975 if ([panel sessionTag] == tag) { 968 if ([panel sessionTag] == tag) {
976 [panel updateCollectionViewIfNeeded]; 969 [panel updateCollectionViewIfNeeded];
977 return; 970 return;
978 } 971 }
979 } 972 }
980 } 973 }
981 974
982 - (void)localSessionMayNeedUpdate:(TabSwitcherSessionType)type { 975 - (void)localSessionMayNeedUpdate:(TabSwitcherSessionType)type {
983 if (type == TabSwitcherSessionType::REGULAR_SESSION) { 976 if (type == TabSwitcherSessionType::REGULAR_SESSION) {
(...skipping 18 matching lines...) Expand all
1002 } else { 995 } else {
1003 _shouldAddPromoPanelHeaderCell = YES; 996 _shouldAddPromoPanelHeaderCell = YES;
1004 } 997 }
1005 [self addPromoPanelForSignInPanelType:newPanelType]; 998 [self addPromoPanelForSignInPanelType:newPanelType];
1006 } 999 }
1007 1000
1008 - (void)addPromoPanelForSignInPanelType:(TabSwitcherSignInPanelsType)panelType { 1001 - (void)addPromoPanelForSignInPanelType:(TabSwitcherSignInPanelsType)panelType {
1009 _signInPanelType = panelType; 1002 _signInPanelType = panelType;
1010 if (panelType != TabSwitcherSignInPanelsType::NO_PANEL) { 1003 if (panelType != TabSwitcherSignInPanelsType::NO_PANEL) {
1011 TabSwitcherPanelOverlayView* panelView = 1004 TabSwitcherPanelOverlayView* panelView =
1012 [[[TabSwitcherPanelOverlayView alloc] initWithFrame:CGRectZero 1005 [[TabSwitcherPanelOverlayView alloc] initWithFrame:CGRectZero
1013 browserState:_browserState] 1006 browserState:_browserState];
1014 autorelease];
1015 [panelView setOverlayType:PanelOverlayTypeFromSignInPanelsType(panelType)]; 1007 [panelView setOverlayType:PanelOverlayTypeFromSignInPanelsType(panelType)];
1016 [_tabSwitcherView addPanelView:panelView atIndex:kSignInPromoPanelIndex]; 1008 [_tabSwitcherView addPanelView:panelView atIndex:kSignInPromoPanelIndex];
1017 } 1009 }
1018 } 1010 }
1019 1011
1020 - (CGSize)sizeForItemAtIndex:(NSUInteger)index 1012 - (CGSize)sizeForItemAtIndex:(NSUInteger)index
1021 inSession:(TabSwitcherSessionType)session { 1013 inSession:(TabSwitcherSessionType)session {
1022 switch (session) { 1014 switch (session) {
1023 case TabSwitcherSessionType::OFF_THE_RECORD_SESSION: 1015 case TabSwitcherSessionType::OFF_THE_RECORD_SESSION:
1024 return [[_offTheRecordSession view] cellSize]; 1016 return [[_offTheRecordSession view] cellSize];
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 if (![_tabSwitcherModel distantSessionCount]) { 1063 if (![_tabSwitcherModel distantSessionCount]) {
1072 // Display promo panel cell if there is no distant sessions. 1064 // Display promo panel cell if there is no distant sessions.
1073 return [TabSwitcherSessionCellData otherDevicesSessionCellData]; 1065 return [TabSwitcherSessionCellData otherDevicesSessionCellData];
1074 } else { 1066 } else {
1075 index -= kHeaderDistantSessionIndexOffset; 1067 index -= kHeaderDistantSessionIndexOffset;
1076 1068
1077 sync_sessions::SyncedSession::DeviceType deviceType = 1069 sync_sessions::SyncedSession::DeviceType deviceType =
1078 sync_sessions::SyncedSession::TYPE_UNSET; 1070 sync_sessions::SyncedSession::TYPE_UNSET;
1079 NSString* cellTitle = nil; 1071 NSString* cellTitle = nil;
1080 1072
1081 if (index < _controllersOfDistantSessions.get().count) { 1073 if (index < _controllersOfDistantSessions.count) {
1082 TabSwitcherPanelController* panel = 1074 TabSwitcherPanelController* panel =
1083 [_controllersOfDistantSessions objectAtIndex:index]; 1075 [_controllersOfDistantSessions objectAtIndex:index];
1084 const synced_sessions::DistantSession* distantSession = 1076 const synced_sessions::DistantSession* distantSession =
1085 [panel distantSession]; 1077 [panel distantSession];
1086 deviceType = distantSession->device_type; 1078 deviceType = distantSession->device_type;
1087 cellTitle = base::SysUTF8ToNSString(distantSession->name); 1079 cellTitle = base::SysUTF8ToNSString(distantSession->name);
1088 } 1080 }
1089 TabSwitcherSessionCellType cellType; 1081 TabSwitcherSessionCellType cellType;
1090 switch (deviceType) { 1082 switch (deviceType) {
1091 case sync_sessions::SyncedSession::TYPE_PHONE: 1083 case sync_sessions::SyncedSession::TYPE_PHONE:
1092 cellType = kPhoneRemoteSessionCell; 1084 cellType = kPhoneRemoteSessionCell;
1093 break; 1085 break;
1094 case sync_sessions::SyncedSession::TYPE_TABLET: 1086 case sync_sessions::SyncedSession::TYPE_TABLET:
1095 cellType = kTabletRemoteSessionCell; 1087 cellType = kTabletRemoteSessionCell;
1096 break; 1088 break;
1097 default: 1089 default:
1098 cellType = kLaptopRemoteSessionCell; 1090 cellType = kLaptopRemoteSessionCell;
1099 break; 1091 break;
1100 } 1092 }
1101 TabSwitcherSessionCellData* sessionData = 1093 TabSwitcherSessionCellData* sessionData =
1102 [[[TabSwitcherSessionCellData alloc] initWithSessionCellType:cellType] 1094 [[TabSwitcherSessionCellData alloc] initWithSessionCellType:cellType];
1103 autorelease];
1104 sessionData.title = cellTitle; 1095 sessionData.title = cellTitle;
1105 return sessionData; 1096 return sessionData;
1106 } 1097 }
1107 } 1098 }
1108 } 1099 }
1109 1100
1110 - (NSInteger)tabSwitcherHeaderViewSelectedPanelIndex { 1101 - (NSInteger)tabSwitcherHeaderViewSelectedPanelIndex {
1111 return [_tabSwitcherView currentPanelIndex]; 1102 return [_tabSwitcherView currentPanelIndex];
1112 } 1103 }
1113 1104
1114 #pragma mark - TabSwitcherViewDelegate 1105 #pragma mark - TabSwitcherViewDelegate
1115 1106
1116 - (void)openNewTabInPanelAtIndex:(NSInteger)panelIndex { 1107 - (void)openNewTabInPanelAtIndex:(NSInteger)panelIndex {
1117 CHECK(panelIndex >= 0); 1108 CHECK(panelIndex >= 0);
1118 DCHECK([self isPanelIndexForLocalSession:panelIndex]); 1109 DCHECK([self isPanelIndexForLocalSession:panelIndex]);
1119 const NSInteger tag = (panelIndex == kLocalTabsOnTheRecordPanelIndex) 1110 const NSInteger tag = (panelIndex == kLocalTabsOnTheRecordPanelIndex)
1120 ? IDC_NEW_TAB 1111 ? IDC_NEW_TAB
1121 : IDC_NEW_INCOGNITO_TAB; 1112 : IDC_NEW_INCOGNITO_TAB;
1122 if (tag == IDC_NEW_INCOGNITO_TAB) { 1113 if (tag == IDC_NEW_INCOGNITO_TAB) {
1123 base::RecordAction( 1114 base::RecordAction(
1124 base::UserMetricsAction("MobileTabSwitcherCreateIncognitoTab")); 1115 base::UserMetricsAction("MobileTabSwitcherCreateIncognitoTab"));
1125 } else { 1116 } else {
1126 base::RecordAction( 1117 base::RecordAction(
1127 base::UserMetricsAction("MobileTabSwitcherCreateNonIncognitoTab")); 1118 base::UserMetricsAction("MobileTabSwitcherCreateNonIncognitoTab"));
1128 } 1119 }
1129 // Create and execute command to create the tab. 1120 // Create and execute command to create the tab.
1130 base::scoped_nsobject<GenericChromeCommand> command( 1121 GenericChromeCommand* command =
1131 [[GenericChromeCommand alloc] initWithTag:tag]); 1122 [[GenericChromeCommand alloc] initWithTag:tag];
1132 [self chromeExecuteCommand:command]; 1123 [self chromeExecuteCommand:command];
1133 } 1124 }
1134 1125
1135 - (ios_internal::NewTabButtonStyle)buttonStyleForPanelAtIndex: 1126 - (ios_internal::NewTabButtonStyle)buttonStyleForPanelAtIndex:
1136 (NSInteger)panelIndex { 1127 (NSInteger)panelIndex {
1137 CHECK(panelIndex >= 0); 1128 CHECK(panelIndex >= 0);
1138 switch (panelIndex) { 1129 switch (panelIndex) {
1139 case kLocalTabsOnTheRecordPanelIndex: 1130 case kLocalTabsOnTheRecordPanelIndex:
1140 if ([_onTheRecordSession shouldShowNewTabButton]) { 1131 if ([_onTheRecordSession shouldShowNewTabButton]) {
1141 return ios_internal::NewTabButtonStyle::BLUE; 1132 return ios_internal::NewTabButtonStyle::BLUE;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 base::UserMetricsAction("MobileTabSwitcherCloseNonIncognitoTab")); 1212 base::UserMetricsAction("MobileTabSwitcherCloseNonIncognitoTab"));
1222 } 1213 }
1223 } 1214 }
1224 1215
1225 - (void)tabSwitcherPanelControllerDidUpdateOverlayViewVisibility: 1216 - (void)tabSwitcherPanelControllerDidUpdateOverlayViewVisibility:
1226 (TabSwitcherPanelController*)tabSwitcherPanelController { 1217 (TabSwitcherPanelController*)tabSwitcherPanelController {
1227 [_tabSwitcherView updateOverlayButtonState]; 1218 [_tabSwitcherView updateOverlayButtonState];
1228 } 1219 }
1229 1220
1230 @end 1221 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698