| OLD | NEW |
| 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_panel_cell.h" | 5 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #import "ios/chrome/browser/tabs/tab.h" | 8 #import "ios/chrome/browser/tabs/tab.h" |
| 9 #import "ios/chrome/browser/ui/fade_truncated_label.h" | 9 #import "ios/chrome/browser/ui/fade_truncated_label.h" |
| 10 #import "ios/chrome/browser/ui/image_util.h" | 10 #import "ios/chrome/browser/ui/image_util.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 _currentPendingSnapshotRequest = | 232 _currentPendingSnapshotRequest = |
| 233 [[self cache] requestSnapshotForTab:tab | 233 [[self cache] requestSnapshotForTab:tab |
| 234 withSize:snapshotSize | 234 withSize:snapshotSize |
| 235 completionBlock:^(UIImage* image) { | 235 completionBlock:^(UIImage* image) { |
| 236 DCHECK([NSThread isMainThread]); | 236 DCHECK([NSThread isMainThread]); |
| 237 [weakCell setSnapshot:image]; | 237 [weakCell setSnapshot:image]; |
| 238 _currentPendingSnapshotRequest = {}; | 238 _currentPendingSnapshotRequest = {}; |
| 239 }]; | 239 }]; |
| 240 } | 240 } |
| 241 | 241 |
| 242 - (void)setSessionType:(ios_internal::SessionType)type { | 242 - (void)setSessionType:(TabSwitcherSessionType)type { |
| 243 UIColor* topBarBackgroundColor; | 243 UIColor* topBarBackgroundColor; |
| 244 UIColor* closeButtonTintColor; | 244 UIColor* closeButtonTintColor; |
| 245 UIColor* textColor; | 245 UIColor* textColor; |
| 246 UIColor* snapshotBackgroundColor; | 246 UIColor* snapshotBackgroundColor; |
| 247 if (type == ios_internal::SessionType::OFF_THE_RECORD_SESSION) { | 247 if (type == TabSwitcherSessionType::OFF_THE_RECORD_SESSION) { |
| 248 topBarBackgroundColor = [[MDCPalette greyPalette] tint700]; | 248 topBarBackgroundColor = [[MDCPalette greyPalette] tint700]; |
| 249 closeButtonTintColor = [[MDCPalette greyPalette] tint100]; | 249 closeButtonTintColor = [[MDCPalette greyPalette] tint100]; |
| 250 textColor = [[MDCPalette greyPalette] tint100]; | 250 textColor = [[MDCPalette greyPalette] tint100]; |
| 251 snapshotBackgroundColor = [[MDCPalette greyPalette] tint900]; | 251 snapshotBackgroundColor = [[MDCPalette greyPalette] tint900]; |
| 252 } else { | 252 } else { |
| 253 topBarBackgroundColor = [[MDCPalette greyPalette] tint100]; | 253 topBarBackgroundColor = [[MDCPalette greyPalette] tint100]; |
| 254 closeButtonTintColor = [[MDCPalette greyPalette] tint700]; | 254 closeButtonTintColor = [[MDCPalette greyPalette] tint700]; |
| 255 textColor = [[MDCPalette greyPalette] tint700]; | 255 textColor = [[MDCPalette greyPalette] tint700]; |
| 256 snapshotBackgroundColor = [UIColor whiteColor]; | 256 snapshotBackgroundColor = [UIColor whiteColor]; |
| 257 } | 257 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 return self; | 391 return self; |
| 392 } | 392 } |
| 393 | 393 |
| 394 - (void)setTitle:(NSString*)titleString { | 394 - (void)setTitle:(NSString*)titleString { |
| 395 [_titleLabel setText:titleString]; | 395 [_titleLabel setText:titleString]; |
| 396 [self contentView].accessibilityLabel = titleString; | 396 [self contentView].accessibilityLabel = titleString; |
| 397 } | 397 } |
| 398 | 398 |
| 399 - (void)setSessionGURL:(GURL const&)gurl | 399 - (void)setSessionGURL:(GURL const&)gurl |
| 400 withBrowserState:(ios::ChromeBrowserState*)browserState { | 400 withBrowserState:(ios::ChromeBrowserState*)browserState { |
| 401 ios_internal::FaviconGetterCompletionBlock block = ^(UIImage* favicon) { | 401 TabSwitcherFaviconGetterCompletionBlock block = ^(UIImage* favicon) { |
| 402 UIColor* imageDominantColor = | 402 UIColor* imageDominantColor = |
| 403 DominantColorForImage(gfx::Image(favicon), 1.0); | 403 DominantColorForImage(gfx::Image(favicon), 1.0); |
| 404 MDCPalette* dominantPalette = | 404 MDCPalette* dominantPalette = |
| 405 [MDCPalette paletteGeneratedFromColor:imageDominantColor]; | 405 [MDCPalette paletteGeneratedFromColor:imageDominantColor]; |
| 406 UIColor* backgroundColor = dominantPalette.tint300; | 406 UIColor* backgroundColor = dominantPalette.tint300; |
| 407 UIColor* textColor = | 407 UIColor* textColor = |
| 408 [MDFTextAccessibility textColorOnBackgroundColor:backgroundColor | 408 [MDFTextAccessibility textColorOnBackgroundColor:backgroundColor |
| 409 targetTextAlpha:kTitleLabelTextAlpha | 409 targetTextAlpha:kTitleLabelTextAlpha |
| 410 font:[_titleLabel font]]; | 410 font:[_titleLabel font]]; |
| 411 UIColor* iconColor = | 411 UIColor* iconColor = |
| 412 [MDFTextAccessibility textColorOnBackgroundColor:backgroundColor | 412 [MDFTextAccessibility textColorOnBackgroundColor:backgroundColor |
| 413 targetTextAlpha:kNewTabIconAlpha | 413 targetTextAlpha:kNewTabIconAlpha |
| 414 font:[_titleLabel font]]; | 414 font:[_titleLabel font]]; |
| 415 [_raisedButton setBackgroundColor:backgroundColor]; | 415 [_raisedButton setBackgroundColor:backgroundColor]; |
| 416 [_titleLabel setTextColor:textColor]; | 416 [_titleLabel setTextColor:textColor]; |
| 417 [_newTabIcon setTintColor:iconColor]; | 417 [_newTabIcon setTintColor:iconColor]; |
| 418 [_newTabIcon setAlpha:1.0]; | 418 [_newTabIcon setAlpha:1.0]; |
| 419 [_favicon setImage:favicon]; | 419 [_favicon setImage:favicon]; |
| 420 [UIView animateWithDuration:0.2 | 420 [UIView animateWithDuration:0.2 |
| 421 animations:^{ | 421 animations:^{ |
| 422 [_raisedButton setAlpha:1.0]; | 422 [_raisedButton setAlpha:1.0]; |
| 423 }]; | 423 }]; |
| 424 }; | 424 }; |
| 425 GURL gurlCopy = gurl; | 425 GURL gurlCopy = gurl; |
| 426 _faviconObtainer.reset([[NSBlockOperation blockOperationWithBlock:^{ | 426 _faviconObtainer.reset([[NSBlockOperation blockOperationWithBlock:^{ |
| 427 ios_internal::GetFavicon(gurlCopy, browserState, block); | 427 TabSwitcherGetFavicon(gurlCopy, browserState, block); |
| 428 }] retain]); | 428 }] retain]); |
| 429 NSOperationQueue* operationQueue = [NSOperationQueue mainQueue]; | 429 NSOperationQueue* operationQueue = [NSOperationQueue mainQueue]; |
| 430 [operationQueue addOperation:_faviconObtainer]; | 430 [operationQueue addOperation:_faviconObtainer]; |
| 431 } | 431 } |
| 432 | 432 |
| 433 - (void)setDelegate:(id<SessionCellDelegate>)delegate { | 433 - (void)setDelegate:(id<SessionCellDelegate>)delegate { |
| 434 _delegate = delegate; | 434 _delegate = delegate; |
| 435 } | 435 } |
| 436 | 436 |
| 437 - (void)cellPressed { | 437 - (void)cellPressed { |
| 438 [_delegate cellPressed:self]; | 438 [_delegate cellPressed:self]; |
| 439 } | 439 } |
| 440 | 440 |
| 441 - (void)prepareForReuse { | 441 - (void)prepareForReuse { |
| 442 [_newTabIcon setAlpha:0]; | 442 [_newTabIcon setAlpha:0]; |
| 443 [_faviconObtainer cancel]; | 443 [_faviconObtainer cancel]; |
| 444 _faviconObtainer.reset(); | 444 _faviconObtainer.reset(); |
| 445 [_raisedButton setAlpha:0]; | 445 [_raisedButton setAlpha:0]; |
| 446 [_raisedButton resetState]; | 446 [_raisedButton resetState]; |
| 447 [super prepareForReuse]; | 447 [super prepareForReuse]; |
| 448 } | 448 } |
| 449 | 449 |
| 450 @end | 450 @end |
| OLD | NEW |