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

Unified Diff: ios/chrome/browser/ui/ntp/new_tab_page_controller.mm

Issue 2820063003: Fix NTP parentViewController. (Closed)
Patch Set: Fix tests Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/ntp/new_tab_page_controller.mm
diff --git a/ios/chrome/browser/ui/ntp/new_tab_page_controller.mm b/ios/chrome/browser/ui/ntp/new_tab_page_controller.mm
index 21d0df203f3b9301612a86ed86825bebb9facb0e..438a168bde0de713307b6c65aa212e8b677dbc17 100644
--- a/ios/chrome/browser/ui/ntp/new_tab_page_controller.mm
+++ b/ios/chrome/browser/ui/ntp/new_tab_page_controller.mm
@@ -158,6 +158,16 @@ enum {
- (NewTabPage::PanelIdentifier)selectedPanelID;
@property(nonatomic, retain) NewTabPageView* ntpView;
+
+// To ease modernizing the NTP only the internal panels are being converted
+// to UIViewControllers. This means all the plumbing between the
+// BrowserViewController and the internal NTP panels (WebController, NTP)
+// hierarchy is skipped. While normally the logic to push and pop a view
+// controller would be owned by a coordinator, in this case the old NTP
+// controller adds and removes child view controllers itself when a load
+// is initiated, and when WebController calls -willBeDismissed.
+@property(nonatomic, assign) UIViewController* parentViewController;
+
@end
@implementation NewTabPageController
@@ -167,13 +177,14 @@ enum {
@synthesize parentViewController = parentViewController_;
- (id)initWithUrl:(const GURL&)url
- loader:(id<UrlLoader>)loader
- focuser:(id<OmniboxFocuser>)focuser
- ntpObserver:(id<NewTabPageControllerObserver>)ntpObserver
- browserState:(ios::ChromeBrowserState*)browserState
- colorCache:(NSMutableDictionary*)colorCache
- webToolbarDelegate:(id<WebToolbarDelegate>)webToolbarDelegate
- tabModel:(TabModel*)tabModel {
+ loader:(id<UrlLoader>)loader
+ focuser:(id<OmniboxFocuser>)focuser
+ ntpObserver:(id<NewTabPageControllerObserver>)ntpObserver
+ browserState:(ios::ChromeBrowserState*)browserState
+ colorCache:(NSMutableDictionary*)colorCache
+ webToolbarDelegate:(id<WebToolbarDelegate>)webToolbarDelegate
+ tabModel:(TabModel*)tabModel
+ parentViewController:(UIViewController*)parentViewController {
self = [super initWithNibName:nil url:url];
if (self) {
DCHECK(browserState);
@@ -182,6 +193,7 @@ enum {
browserState_ = browserState;
loader_ = loader;
newTabPageObserver_ = ntpObserver;
+ parentViewController_ = parentViewController;
focuser_.reset(focuser);
webToolbarDelegate_.reset(webToolbarDelegate);
tabModel_.reset([tabModel retain]);
@@ -499,6 +511,7 @@ enum {
}
- (BOOL)loadPanel:(NewTabPageBarItem*)item {
+ DCHECK(self.parentViewController);
UIView* view = nil;
UIViewController* panelController = nil;
BOOL created = NO;
« no previous file with comments | « ios/chrome/browser/ui/ntp/new_tab_page_controller.h ('k') | ios/chrome/browser/ui/ntp/new_tab_page_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698