Chromium Code Reviews| Index: ios/chrome/browser/ui/ntp/google_landing_controller.mm |
| diff --git a/ios/chrome/browser/ui/ntp/google_landing_controller.mm b/ios/chrome/browser/ui/ntp/google_landing_controller.mm |
| index b9f99f167d93e3d3e5042a7bbf04485a9d84d7e5..02c42aad82856120be5cf2c771a320309e01399b 100644 |
| --- a/ios/chrome/browser/ui/ntp/google_landing_controller.mm |
| +++ b/ios/chrome/browser/ui/ntp/google_landing_controller.mm |
| @@ -191,9 +191,6 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| UICollectionViewDelegateFlowLayout, |
| UIGestureRecognizerDelegate, |
| WhatsNewHeaderViewDelegate> { |
| - // The main view. |
| - base::scoped_nsobject<GoogleLandingView> _view; |
| - |
| // Fake omnibox. |
| base::scoped_nsobject<UIButton> _searchTapTarget; |
| @@ -393,32 +390,34 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| [_swipeGestureRecognizer |
| setDirection:UISwipeGestureRecognizerDirectionDown]; |
| - _view.reset( |
| - [[GoogleLandingView alloc] initWithFrame:[UIScreen mainScreen].bounds]); |
| - [_view setAutoresizingMask:UIViewAutoresizingFlexibleHeight | |
| - UIViewAutoresizingFlexibleWidth]; |
| - [_view setFrameDelegate:self]; |
| - |
| _focuser.reset(focuser); |
| _webToolbarDelegate.reset(webToolbarDelegate); |
| _tabModel.reset([tabModel retain]); |
| _scrolledToTop = NO; |
| _animateHeader = YES; |
| - // Initialise |shiftTilesDownStartTime| to a sentinel value to indicate that |
| - // the animation has not yet started. |
| - _shiftTilesDownStartTime = -1; |
| - _mostVisitedCellSize = |
| - [GoogleLandingController mostVisitedCellSizeForView:_view]; |
| - [self addDoodle]; |
| - [self addSearchField]; |
| - [self addMostVisited]; |
| - [self addOverscrollActions]; |
| - [self reload]; |
| } |
| return self; |
| } |
| +- (void)loadView { |
| + self.view = |
| + [[GoogleLandingView alloc] initWithFrame:[UIScreen mainScreen].bounds]; |
| + [self.view setAutoresizingMask:UIViewAutoresizingFlexibleHeight | |
| + UIViewAutoresizingFlexibleWidth]; |
| + [(GoogleLandingView*)self.view setFrameDelegate:self]; |
|
rohitrao (ping after 24h)
2017/04/12 12:45:09
You can redeclare the |view| property to be a Goog
justincohen
2017/04/12 14:23:12
Done.
|
| + // Initialise |shiftTilesDownStartTime| to a sentinel value to indicate that |
| + // the animation has not yet started. |
| + _shiftTilesDownStartTime = -1; |
| + _mostVisitedCellSize = |
| + [GoogleLandingController mostVisitedCellSizeForView:self.view]; |
| + [self addDoodle]; |
| + [self addSearchField]; |
| + [self addMostVisited]; |
| + [self addOverscrollActions]; |
| + [self reload]; |
| +} |
| + |
| + (CGSize)mostVisitedCellSizeForView:(UIView*)view { |
| if (IsIPadIdiom()) { |
| // On iPads, split-screen and slide-over may require showing smaller cells. |
| @@ -484,7 +483,7 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| } |
| - (CGFloat)viewWidth { |
| - return [_view frame].size.width; |
| + return [self.view frame].size.width; |
| } |
| - (int)numberOfColumns { |
| @@ -810,7 +809,7 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| - (void)updateSubviewFrames { |
| _mostVisitedCellSize = |
| - [GoogleLandingController mostVisitedCellSizeForView:_view]; |
| + [GoogleLandingController mostVisitedCellSizeForView:self.view]; |
| UICollectionViewFlowLayout* flowLayout = |
| base::mac::ObjCCastStrict<UICollectionViewFlowLayout>( |
| [_mostVisitedView collectionViewLayout]); |
| @@ -858,7 +857,7 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| // Initialize and add a panel with most visited sites. |
| - (void)addMostVisited { |
| - CGRect mostVisitedFrame = [_view bounds]; |
| + CGRect mostVisitedFrame = [self.view bounds]; |
| base::scoped_nsobject<UICollectionViewFlowLayout> flowLayout; |
| if (IsIPadIdiom()) |
| flowLayout.reset([[UICollectionViewFlowLayout alloc] init]); |
| @@ -891,7 +890,7 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| withReuseIdentifier:@"header"]; |
| [_mostVisitedView setAccessibilityIdentifier:@"Google Landing"]; |
| - [_view addSubview:_mostVisitedView]; |
| + [self.view addSubview:_mostVisitedView]; |
| _most_visited_sites = |
| IOSMostVisitedSitesFactory::NewForBrowserState(_browserState); |
| _most_visited_observer_bridge.reset( |
| @@ -938,9 +937,9 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| - (void)shiftTilesUp { |
| _scrolledToTop = YES; |
| - // Add gesture recognizer to background |_view| when omnibox is focused. |
| - [_view addGestureRecognizer:_tapGestureRecognizer]; |
| - [_view addGestureRecognizer:_swipeGestureRecognizer]; |
| + // Add gesture recognizer to background |self.view| when omnibox is focused. |
| + [self.view addGestureRecognizer:_tapGestureRecognizer]; |
| + [self.view addGestureRecognizer:_swipeGestureRecognizer]; |
| CGFloat pinnedOffsetY = [self pinnedOffsetY]; |
| _animateHeader = !IsIPadIdiom(); |
| @@ -1005,8 +1004,8 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| // Reshow views that are within range of the most visited collection view |
| // (if necessary). |
| - [_view removeGestureRecognizer:_tapGestureRecognizer]; |
| - [_view removeGestureRecognizer:_swipeGestureRecognizer]; |
| + [self.view removeGestureRecognizer:_tapGestureRecognizer]; |
| + [self.view removeGestureRecognizer:_swipeGestureRecognizer]; |
| // CADisplayLink is used for this animation instead of the standard UIView |
| // animation because the standard animation did not properly convert the |
| @@ -1490,7 +1489,7 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| } |
| - (CGFloat)alphaForBottomShadow { |
| - // Get the frame of the bottommost cell in |_view|'s coordinate system. |
| + // Get the frame of the bottommost cell in |self.view|'s coordinate system. |
| NSInteger section = SectionWithMostVisited; |
| // Account for the fact that the tableview may not yet contain |
| // |numberOfNonEmptyTilesShown| tiles because it hasn't been updated yet. |
| @@ -1507,7 +1506,8 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| CGRect cellFrameInSuperview = |
| [_mostVisitedView convertRect:lastCellFrame toView:self.view]; |
| - // Calculate when the bottom of the cell passes through the bottom of |_view|. |
| + // Calculate when the bottom of the cell passes through the bottom of |
| + // |self.view|. |
| CGFloat maxY = CGRectGetMaxY(cellFrameInSuperview); |
| CGFloat viewHeight = CGRectGetHeight(self.view.frame); |
| @@ -1517,10 +1517,6 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| return alpha; |
| } |
| -- (UIView*)view { |
| - return _view; |
| -} |
| - |
| #pragma mark - LogoAnimationControllerOwnerOwner |
| - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |