Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ios/chrome/browser/ui/browser_view_controller.h" | 5 #import "ios/chrome/browser/ui/browser_view_controller.h" |
| 6 | 6 |
| 7 #import <AssetsLibrary/AssetsLibrary.h> | 7 #import <AssetsLibrary/AssetsLibrary.h> |
| 8 #import <MobileCoreServices/MobileCoreServices.h> | 8 #import <MobileCoreServices/MobileCoreServices.h> |
| 9 #import <PassKit/PassKit.h> | 9 #import <PassKit/PassKit.h> |
| 10 #import <Photos/Photos.h> | 10 #import <Photos/Photos.h> |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 @property(nonatomic, assign, getter=isInNewTabAnimation) BOOL inNewTabAnimation; | 565 @property(nonatomic, assign, getter=isInNewTabAnimation) BOOL inNewTabAnimation; |
| 566 // Whether BVC prefers to hide the status bar. This value is used to determine | 566 // Whether BVC prefers to hide the status bar. This value is used to determine |
| 567 // the response from the |prefersStatusBarHidden| method. | 567 // the response from the |prefersStatusBarHidden| method. |
| 568 @property(nonatomic, assign) BOOL hideStatusBar; | 568 @property(nonatomic, assign) BOOL hideStatusBar; |
| 569 // Whether the VoiceSearchBar should be displayed. | 569 // Whether the VoiceSearchBar should be displayed. |
| 570 @property(nonatomic, readonly) BOOL shouldShowVoiceSearchBar; | 570 @property(nonatomic, readonly) BOOL shouldShowVoiceSearchBar; |
| 571 // Coordinator for displaying a modal overlay with activity indicator to prevent | 571 // Coordinator for displaying a modal overlay with activity indicator to prevent |
| 572 // the user from interacting with the browser view. | 572 // the user from interacting with the browser view. |
| 573 @property(nonatomic, strong) | 573 @property(nonatomic, strong) |
| 574 ActivityOverlayCoordinator* activityOverlayCoordinator; | 574 ActivityOverlayCoordinator* activityOverlayCoordinator; |
| 575 // A block to be run when the |tabWasAdded:| method completes the animation | |
| 576 // for the presentation of a new tab. Can be used to record performance metrics. | |
| 577 @property(nonatomic, strong, nullable) | |
| 578 ProceduralBlock foregroundTabWasAddedCompletionBlock; | |
| 575 | 579 |
| 576 // The user agent type used to load the currently visible page. User agent type | 580 // The user agent type used to load the currently visible page. User agent type |
| 577 // is NONE if there is no visible page or visible page is a native page. | 581 // is NONE if there is no visible page or visible page is a native page. |
| 578 @property(nonatomic, assign, readonly) web::UserAgentType userAgentType; | 582 @property(nonatomic, assign, readonly) web::UserAgentType userAgentType; |
| 579 | 583 |
| 580 // Returns the header views, all the chrome on top of the page, including the | 584 // Returns the header views, all the chrome on top of the page, including the |
| 581 // ones that cannot be scrolled off screen by full screen. | 585 // ones that cannot be scrolled off screen by full screen. |
| 582 @property(nonatomic, strong, readonly) NSArray<HeaderDefinition*>* headerViews; | 586 @property(nonatomic, strong, readonly) NSArray<HeaderDefinition*>* headerViews; |
| 583 | 587 |
| 584 // BVC initialization: | 588 // BVC initialization: |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 | 929 |
| 926 @synthesize contentArea = _contentArea; | 930 @synthesize contentArea = _contentArea; |
| 927 @synthesize typingShield = _typingShield; | 931 @synthesize typingShield = _typingShield; |
| 928 @synthesize active = _active; | 932 @synthesize active = _active; |
| 929 @synthesize visible = _visible; | 933 @synthesize visible = _visible; |
| 930 @synthesize viewVisible = _viewVisible; | 934 @synthesize viewVisible = _viewVisible; |
| 931 @synthesize dismissingModal = _dismissingModal; | 935 @synthesize dismissingModal = _dismissingModal; |
| 932 @synthesize hideStatusBar = _hideStatusBar; | 936 @synthesize hideStatusBar = _hideStatusBar; |
| 933 @synthesize activityOverlayCoordinator = _activityOverlayCoordinator; | 937 @synthesize activityOverlayCoordinator = _activityOverlayCoordinator; |
| 934 @synthesize presenting = _presenting; | 938 @synthesize presenting = _presenting; |
| 939 @synthesize foregroundTabWasAddedCompletionBlock = | |
| 940 _foregroundTabWasAddedCompletionBlock; | |
| 935 | 941 |
| 936 #pragma mark - Object lifecycle | 942 #pragma mark - Object lifecycle |
| 937 | 943 |
| 938 - (instancetype)initWithTabModel:(TabModel*)model | 944 - (instancetype)initWithTabModel:(TabModel*)model |
| 939 browserState:(ios::ChromeBrowserState*)browserState | 945 browserState:(ios::ChromeBrowserState*)browserState |
| 940 dependencyFactory: | 946 dependencyFactory: |
| 941 (BrowserViewControllerDependencyFactory*)factory { | 947 (BrowserViewControllerDependencyFactory*)factory { |
| 942 self = [super initWithNibName:nil bundle:base::mac::FrameworkBundle()]; | 948 self = [super initWithNibName:nil bundle:base::mac::FrameworkBundle()]; |
| 943 if (self) { | 949 if (self) { |
| 944 DCHECK(factory); | 950 DCHECK(factory); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1191 [self setNeedsStatusBarAppearanceUpdate]; | 1197 [self setNeedsStatusBarAppearanceUpdate]; |
| 1192 } | 1198 } |
| 1193 | 1199 |
| 1194 #pragma mark - IBActions | 1200 #pragma mark - IBActions |
| 1195 | 1201 |
| 1196 - (void)shieldWasTapped:(id)sender { | 1202 - (void)shieldWasTapped:(id)sender { |
| 1197 [_toolbarController cancelOmniboxEdit]; | 1203 [_toolbarController cancelOmniboxEdit]; |
| 1198 } | 1204 } |
| 1199 | 1205 |
| 1200 - (void)newTab:(id)sender { | 1206 - (void)newTab:(id)sender { |
| 1207 // Observe the timing of the new tab creation, both MainController | |
| 1208 // and BrowserViewController call into this method on the correct BVC to | |
| 1209 // create new tabs making it preferable to doing this in | |
| 1210 // |chromeExecuteCommand:|. | |
| 1211 NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate]; | |
| 1212 BOOL offTheRecord = self.isOffTheRecord; | |
| 1213 self.foregroundTabWasAddedCompletionBlock = ^{ | |
| 1214 double duration = [NSDate timeIntervalSinceReferenceDate] - startTime; | |
|
Ilya Sherman
2017/05/23 22:55:22
Optional nit: Mebbe define a TimeDelta here, outsi
PL
2017/06/08 17:57:47
Done!
| |
| 1215 if (offTheRecord) { | |
| 1216 UMA_HISTOGRAM_TIMES("Toolbar.Menu.NewIncognitoTabPresentationDuration", | |
| 1217 base::TimeDelta::FromSecondsD(duration)); | |
| 1218 } else { | |
| 1219 UMA_HISTOGRAM_TIMES("Toolbar.Menu.NewTabPresentationDuration", | |
| 1220 base::TimeDelta::FromSecondsD(duration)); | |
| 1221 } | |
| 1222 }; | |
| 1223 | |
| 1201 [self setLastTapPoint:sender]; | 1224 [self setLastTapPoint:sender]; |
| 1202 DCHECK(self.visible || self.dismissingModal); | 1225 DCHECK(self.visible || self.dismissingModal); |
| 1203 Tab* currentTab = [_model currentTab]; | 1226 Tab* currentTab = [_model currentTab]; |
| 1204 if (currentTab) { | 1227 if (currentTab) { |
| 1205 [currentTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; | 1228 [currentTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; |
| 1206 } | 1229 } |
| 1207 [self addSelectedTabWithURL:GURL(kChromeUINewTabURL) | 1230 [self addSelectedTabWithURL:GURL(kChromeUINewTabURL) |
| 1208 transition:ui::PAGE_TRANSITION_TYPED]; | 1231 transition:ui::PAGE_TRANSITION_TYPED]; |
| 1209 } | 1232 } |
| 1210 | 1233 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1618 // Use the model's currentTab here because it is possible that it can | 1641 // Use the model's currentTab here because it is possible that it can |
| 1619 // be reset to a new value before the new Tab animation finished (e.g. | 1642 // be reset to a new value before the new Tab animation finished (e.g. |
| 1620 // if another Tab shows a dialog via |dialogPresenter|). However, that | 1643 // if another Tab shows a dialog via |dialogPresenter|). However, that |
| 1621 // tab's view hasn't been displayed yet because it was in a new tab | 1644 // tab's view hasn't been displayed yet because it was in a new tab |
| 1622 // animation. | 1645 // animation. |
| 1623 Tab* currentTab = [_model currentTab]; | 1646 Tab* currentTab = [_model currentTab]; |
| 1624 if (currentTab) { | 1647 if (currentTab) { |
| 1625 [self tabSelected:currentTab]; | 1648 [self tabSelected:currentTab]; |
| 1626 } | 1649 } |
| 1627 startVoiceSearchIfNecessaryBlock(); | 1650 startVoiceSearchIfNecessaryBlock(); |
| 1651 | |
| 1652 if (self.foregroundTabWasAddedCompletionBlock) { | |
| 1653 self.foregroundTabWasAddedCompletionBlock(); | |
| 1654 } | |
| 1628 }); | 1655 }); |
| 1629 } else { | 1656 } else { |
| 1630 // -updateSnapshotWithOverlay will force a screen redraw, so take the | 1657 // -updateSnapshotWithOverlay will force a screen redraw, so take the |
| 1631 // snapshot before adding the views needed for the background animation. | 1658 // snapshot before adding the views needed for the background animation. |
| 1632 Tab* topTab = [_model currentTab]; | 1659 Tab* topTab = [_model currentTab]; |
| 1633 UIImage* image = [topTab updateSnapshotWithOverlay:YES | 1660 UIImage* image = [topTab updateSnapshotWithOverlay:YES |
| 1634 visibleFrameOnly:self.isToolbarOnScreen]; | 1661 visibleFrameOnly:self.isToolbarOnScreen]; |
| 1635 // Add three layers in order on top of the contentArea for the animation: | 1662 // Add three layers in order on top of the contentArea for the animation: |
| 1636 // 1. The black "background" screen. | 1663 // 1. The black "background" screen. |
| 1637 UIView* background = [[UIView alloc] initWithFrame:[_contentArea bounds]]; | 1664 UIView* background = [[UIView alloc] initWithFrame:[_contentArea bounds]]; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1656 self.inNewTabAnimation = NO; | 1683 self.inNewTabAnimation = NO; |
| 1657 // Resnapshot the top card if it has its own toolbar, as the toolbar | 1684 // Resnapshot the top card if it has its own toolbar, as the toolbar |
| 1658 // will be captured in the new tab animation, but isn't desired for | 1685 // will be captured in the new tab animation, but isn't desired for |
| 1659 // the stack view snapshots. | 1686 // the stack view snapshots. |
| 1660 id nativeController = [self nativeControllerForTab:topTab]; | 1687 id nativeController = [self nativeControllerForTab:topTab]; |
| 1661 if ([nativeController conformsToProtocol:@protocol(ToolbarOwner)]) | 1688 if ([nativeController conformsToProtocol:@protocol(ToolbarOwner)]) |
| 1662 [topTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; | 1689 [topTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; |
| 1663 startVoiceSearchIfNecessaryBlock(); | 1690 startVoiceSearchIfNecessaryBlock(); |
| 1664 }); | 1691 }); |
| 1665 } | 1692 } |
| 1693 // Reset the foreground tab completion block so that it can never be | |
| 1694 // called more than once regardless of foreground/background tab appearances. | |
| 1695 self.foregroundTabWasAddedCompletionBlock = nil; | |
| 1666 } | 1696 } |
| 1667 | 1697 |
| 1668 #pragma mark - UI Configuration and Layout | 1698 #pragma mark - UI Configuration and Layout |
| 1669 | 1699 |
| 1670 - (void)updateWithTabModel:(TabModel*)model | 1700 - (void)updateWithTabModel:(TabModel*)model |
| 1671 browserState:(ios::ChromeBrowserState*)browserState { | 1701 browserState:(ios::ChromeBrowserState*)browserState { |
| 1672 DCHECK(model); | 1702 DCHECK(model); |
| 1673 DCHECK(browserState); | 1703 DCHECK(browserState); |
| 1674 DCHECK(!_model); | 1704 DCHECK(!_model); |
| 1675 DCHECK(!_browserState); | 1705 DCHECK(!_browserState); |
| (...skipping 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5175 | 5205 |
| 5176 - (UIView*)voiceSearchButton { | 5206 - (UIView*)voiceSearchButton { |
| 5177 return _voiceSearchButton; | 5207 return _voiceSearchButton; |
| 5178 } | 5208 } |
| 5179 | 5209 |
| 5180 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5210 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
| 5181 return [self currentLogoAnimationControllerOwner]; | 5211 return [self currentLogoAnimationControllerOwner]; |
| 5182 } | 5212 } |
| 5183 | 5213 |
| 5184 @end | 5214 @end |
| OLD | NEW |