| 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/ntp/new_tab_page_controller.h" | 5 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #import "base/ios/weak_nsobject.h" | 9 #import "base/ios/weak_nsobject.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 // To ease modernizing the NTP only the internal panels are being converted | 166 // To ease modernizing the NTP only the internal panels are being converted |
| 167 // to UIViewControllers. This means all the plumbing between the | 167 // to UIViewControllers. This means all the plumbing between the |
| 168 // BrowserViewController and the internal NTP panels (WebController, NTP) | 168 // BrowserViewController and the internal NTP panels (WebController, NTP) |
| 169 // hierarchy is skipped. While normally the logic to push and pop a view | 169 // hierarchy is skipped. While normally the logic to push and pop a view |
| 170 // controller would be owned by a coordinator, in this case the old NTP | 170 // controller would be owned by a coordinator, in this case the old NTP |
| 171 // controller adds and removes child view controllers itself when a load | 171 // controller adds and removes child view controllers itself when a load |
| 172 // is initiated, and when WebController calls -willBeDismissed. | 172 // is initiated, and when WebController calls -willBeDismissed. |
| 173 @property(nonatomic, assign) UIViewController* parentViewController; | 173 @property(nonatomic, assign) UIViewController* parentViewController; |
| 174 | 174 |
| 175 // To ease modernizing the NTP a non-descript CommandDispatcher is passed thru |
| 176 // to be used by the reuabled NTP panels. |
| 177 @property(nonatomic, assign) id dispatcher; |
| 178 |
| 175 @end | 179 @end |
| 176 | 180 |
| 177 @implementation NewTabPageController | 181 @implementation NewTabPageController |
| 178 | 182 |
| 179 @synthesize ntpView = newTabPageView_; | 183 @synthesize ntpView = newTabPageView_; |
| 180 @synthesize swipeRecognizerProvider = swipeRecognizerProvider_; | 184 @synthesize swipeRecognizerProvider = swipeRecognizerProvider_; |
| 181 @synthesize parentViewController = parentViewController_; | 185 @synthesize parentViewController = parentViewController_; |
| 186 @synthesize dispatcher = dispatcher_; |
| 182 | 187 |
| 183 - (id)initWithUrl:(const GURL&)url | 188 - (id)initWithUrl:(const GURL&)url |
| 184 loader:(id<UrlLoader>)loader | 189 loader:(id<UrlLoader>)loader |
| 185 focuser:(id<OmniboxFocuser>)focuser | 190 focuser:(id<OmniboxFocuser>)focuser |
| 186 ntpObserver:(id<NewTabPageControllerObserver>)ntpObserver | 191 ntpObserver:(id<NewTabPageControllerObserver>)ntpObserver |
| 187 browserState:(ios::ChromeBrowserState*)browserState | 192 browserState:(ios::ChromeBrowserState*)browserState |
| 188 colorCache:(NSMutableDictionary*)colorCache | 193 colorCache:(NSMutableDictionary*)colorCache |
| 189 webToolbarDelegate:(id<WebToolbarDelegate>)webToolbarDelegate | 194 webToolbarDelegate:(id<WebToolbarDelegate>)webToolbarDelegate |
| 190 tabModel:(TabModel*)tabModel | 195 tabModel:(TabModel*)tabModel |
| 191 parentViewController:(UIViewController*)parentViewController { | 196 parentViewController:(UIViewController*)parentViewController |
| 197 dispatcher:(id)dispatcher { |
| 192 self = [super initWithNibName:nil url:url]; | 198 self = [super initWithNibName:nil url:url]; |
| 193 if (self) { | 199 if (self) { |
| 194 DCHECK(browserState); | 200 DCHECK(browserState); |
| 195 propertyReleaser_NewTabPageController_.Init(self, | 201 propertyReleaser_NewTabPageController_.Init(self, |
| 196 [NewTabPageController class]); | 202 [NewTabPageController class]); |
| 197 browserState_ = browserState; | 203 browserState_ = browserState; |
| 198 loader_ = loader; | 204 loader_ = loader; |
| 199 newTabPageObserver_ = ntpObserver; | 205 newTabPageObserver_ = ntpObserver; |
| 200 parentViewController_ = parentViewController; | 206 parentViewController_ = parentViewController; |
| 207 dispatcher_ = dispatcher; |
| 201 focuser_.reset(focuser); | 208 focuser_.reset(focuser); |
| 202 webToolbarDelegate_.reset(webToolbarDelegate); | 209 webToolbarDelegate_.reset(webToolbarDelegate); |
| 203 tabModel_.reset([tabModel retain]); | 210 tabModel_.reset([tabModel retain]); |
| 204 dominantColorCache_ = colorCache; | 211 dominantColorCache_ = colorCache; |
| 205 self.title = l10n_util::GetNSString(IDS_NEW_TAB_TITLE); | 212 self.title = l10n_util::GetNSString(IDS_NEW_TAB_TITLE); |
| 206 scrollInitialized_ = NO; | 213 scrollInitialized_ = NO; |
| 207 | 214 |
| 208 base::scoped_nsobject<UIScrollView> scrollView( | 215 base::scoped_nsobject<UIScrollView> scrollView( |
| 209 [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 412)]); | 216 [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 412)]); |
| 210 [scrollView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | | 217 [scrollView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 } | 540 } |
| 534 panelController = bookmarkController_; | 541 panelController = bookmarkController_; |
| 535 view = [bookmarkController_ view]; | 542 view = [bookmarkController_ view]; |
| 536 [bookmarkController_ setDelegate:self]; | 543 [bookmarkController_ setDelegate:self]; |
| 537 } else if (item.identifier == NewTabPage::kMostVisitedPanel) { | 544 } else if (item.identifier == NewTabPage::kMostVisitedPanel) { |
| 538 if (!googleLandingController_) { | 545 if (!googleLandingController_) { |
| 539 googleLandingController_.reset([[GoogleLandingController alloc] init]); | 546 googleLandingController_.reset([[GoogleLandingController alloc] init]); |
| 540 googleLandingMediator_.reset([[GoogleLandingMediator alloc] | 547 googleLandingMediator_.reset([[GoogleLandingMediator alloc] |
| 541 initWithConsumer:googleLandingController_ | 548 initWithConsumer:googleLandingController_ |
| 542 browserState:browserState_ | 549 browserState:browserState_ |
| 543 loader:loader_ | |
| 544 focuser:focuser_ | |
| 545 webToolbarDelegate:webToolbarDelegate_ | |
| 546 webStateList:[tabModel_ webStateList]]); | 550 webStateList:[tabModel_ webStateList]]); |
| 547 [googleLandingController_ setDataSource:googleLandingMediator_]; | 551 [googleLandingController_ setDataSource:googleLandingMediator_]; |
| 552 [googleLandingController_ setDispatcher:self.dispatcher]; |
| 553 [googleLandingMediator_ setDispatcher:self.dispatcher]; |
| 548 } | 554 } |
| 549 panelController = googleLandingController_; | 555 panelController = googleLandingController_; |
| 550 view = [googleLandingController_ view]; | 556 view = [googleLandingController_ view]; |
| 551 [googleLandingController_ setDelegate:self]; | 557 [googleLandingController_ setDelegate:self]; |
| 552 } else if (item.identifier == NewTabPage::kOpenTabsPanel) { | 558 } else if (item.identifier == NewTabPage::kOpenTabsPanel) { |
| 553 if (!openTabsController_) | 559 if (!openTabsController_) |
| 554 openTabsController_.reset([[RecentTabsPanelController alloc] | 560 openTabsController_.reset([[RecentTabsPanelController alloc] |
| 555 initWithLoader:loader_ | 561 initWithLoader:loader_ |
| 556 browserState:browserState_]); | 562 browserState:browserState_]); |
| 557 // TODO(crbug.com/708319): Also set panelController for opentabs here. | 563 // TODO(crbug.com/708319): Also set panelController for opentabs here. |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 | 737 |
| 732 - (void)updateNtpBarShadowForPanelController: | 738 - (void)updateNtpBarShadowForPanelController: |
| 733 (id<NewTabPagePanelProtocol>)ntpPanelController { | 739 (id<NewTabPagePanelProtocol>)ntpPanelController { |
| 734 if (currentController_ != ntpPanelController) | 740 if (currentController_ != ntpPanelController) |
| 735 return; | 741 return; |
| 736 [self.ntpView.tabBar | 742 [self.ntpView.tabBar |
| 737 setShadowAlpha:[ntpPanelController alphaForBottomShadow]]; | 743 setShadowAlpha:[ntpPanelController alphaForBottomShadow]]; |
| 738 } | 744 } |
| 739 | 745 |
| 740 @end | 746 @end |
| OLD | NEW |