Commit 3b0ad422 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Extract presentation from BookmarkPromoController

BookmarkPromoController is a helper for view objects that
currently displays UI via the dispatcher (eg, -showSignin:).
We want to extract presentation actions out of this
pseudo-view layer and into the VC layer.

Related to crrev.com/c/756362

Bug: 
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Id4a97c11f857a448fa8f51a50a3e2c06f4d0426a
Reviewed-on: https://chromium-review.googlesource.com/771698Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517110}
parent 7eb7c274
...@@ -141,10 +141,10 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -141,10 +141,10 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
// It is important to initialize the promo controller with the browser state // It is important to initialize the promo controller with the browser state
// passed in, as it could be incognito. // passed in, as it could be incognito.
_bookmarkPromoController = _bookmarkPromoController = [[BookmarkPromoController alloc]
[[BookmarkPromoController alloc] initWithBrowserState:browserState initWithBrowserState:browserState
delegate:self delegate:self
dispatcher:self.dispatcher]; presenter:self /* id<SigninPresenter> */];
} }
return self; return self;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@protocol ApplicationCommands; @protocol SigninPresenter;
namespace ios { namespace ios {
class ChromeBrowserState; class ChromeBrowserState;
...@@ -40,7 +40,7 @@ class PrefRegistrySyncable; ...@@ -40,7 +40,7 @@ class PrefRegistrySyncable;
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
delegate: delegate:
(id<BookmarkPromoControllerDelegate>)delegate (id<BookmarkPromoControllerDelegate>)delegate
dispatcher:(id<ApplicationCommands>)dispatcher; presenter:(id<SigninPresenter>)presenter;
// Presents the sign-in UI, presenting from |baseViewController|. // Presents the sign-in UI, presenting from |baseViewController|.
- (void)showSignInFromViewController:(UIViewController*)baseViewController; - (void)showSignInFromViewController:(UIViewController*)baseViewController;
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/pref_names.h" #include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/signin/signin_manager_factory.h" #include "ios/chrome/browser/signin/signin_manager_factory.h"
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/show_signin_command.h" #import "ios/chrome/browser/ui/commands/show_signin_command.h"
#import "ios/chrome/browser/ui/signin_interaction/public/signin_presenter.h"
#import "ios/chrome/browser/ui/ui_util.h" #import "ios/chrome/browser/ui/ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -52,8 +52,8 @@ class SignInObserver; ...@@ -52,8 +52,8 @@ class SignInObserver;
bool _promoDisplayedRecorded; bool _promoDisplayedRecorded;
} }
// Dispatcher for sending commands. // Presenter which can show signin UI.
@property(nonatomic, readonly, weak) id<ApplicationCommands> dispatcher; @property(nonatomic, readonly, weak) id<SigninPresenter> presenter;
// Records that the promo was displayed. Can be called several times per // Records that the promo was displayed. Can be called several times per
// instance but will effectively record the histogram only once per instance. // instance but will effectively record the histogram only once per instance.
...@@ -97,7 +97,7 @@ class SignInObserver : public SigninManagerBase::Observer { ...@@ -97,7 +97,7 @@ class SignInObserver : public SigninManagerBase::Observer {
@synthesize delegate = _delegate; @synthesize delegate = _delegate;
@synthesize promoState = _promoState; @synthesize promoState = _promoState;
@synthesize dispatcher = _dispatcher; @synthesize presenter = _presenter;
+ (void)registerBrowserStatePrefs:(user_prefs::PrefRegistrySyncable*)registry { + (void)registerBrowserStatePrefs:(user_prefs::PrefRegistrySyncable*)registry {
registry->RegisterBooleanPref(prefs::kIosBookmarkPromoAlreadySeen, false); registry->RegisterBooleanPref(prefs::kIosBookmarkPromoAlreadySeen, false);
...@@ -106,11 +106,11 @@ class SignInObserver : public SigninManagerBase::Observer { ...@@ -106,11 +106,11 @@ class SignInObserver : public SigninManagerBase::Observer {
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
delegate: delegate:
(id<BookmarkPromoControllerDelegate>)delegate (id<BookmarkPromoControllerDelegate>)delegate
dispatcher:(id<ApplicationCommands>)dispatcher { presenter:(id<SigninPresenter>)presenter {
self = [super init]; self = [super init];
if (self) { if (self) {
_delegate = delegate; _delegate = delegate;
_dispatcher = dispatcher; _presenter = presenter;
// Incognito browserState can go away before this class is released, this // Incognito browserState can go away before this class is released, this
// code avoids keeping a pointer to it. // code avoids keeping a pointer to it.
_isIncognito = browserState->IsOffTheRecord(); _isIncognito = browserState->IsOffTheRecord();
...@@ -145,7 +145,7 @@ class SignInObserver : public SigninManagerBase::Observer { ...@@ -145,7 +145,7 @@ class SignInObserver : public SigninManagerBase::Observer {
initWithOperation:AUTHENTICATION_OPERATION_SIGNIN initWithOperation:AUTHENTICATION_OPERATION_SIGNIN
accessPoint:signin_metrics::AccessPoint:: accessPoint:signin_metrics::AccessPoint::
ACCESS_POINT_BOOKMARK_MANAGER]; ACCESS_POINT_BOOKMARK_MANAGER];
[self.dispatcher showSignin:command baseViewController:baseViewController]; [self.presenter showSignin:command];
} }
- (void)hidePromoCell { - (void)hidePromoCell {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment