Commit 5b952d9d authored by edchin's avatar edchin Committed by Commit Bot

[ios] Fix sync error infobar presentation.

The sync error infobar was presenting from a dismissed view controller.
This CL plumbs in the BVC as the sync presenter to the sync error
infobar.

Bug: 788377
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I26ee8ec25432d8eb482ff45d6320f4c2877702e4
Reviewed-on: https://chromium-review.googlesource.com/795651Reviewed-by: default avatarGregory Chatzinoff <gchatz@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520638}
parent 0ae589ea
......@@ -1258,6 +1258,7 @@ const int kExternalFilesCleanupDelaySeconds = 60;
[[WelcomeToChromeViewController alloc]
initWithBrowserState:_mainBrowserState
tabModel:self.mainTabModel
presenter:self.mainBVC
dispatcher:self.mainBVC.dispatcher];
UINavigationController* navController =
[[OrientationLimitingNavigationController alloc]
......
......@@ -10,6 +10,7 @@
#import <UIKit/UIKit.h>
#import "base/ios/block_types.h"
#import "ios/chrome/browser/ui/settings/sync_utils/sync_presenter.h"
#import "ios/chrome/browser/ui/side_swipe/side_swipe_controller.h"
#import "ios/chrome/browser/ui/toolbar/toolbar_owner.h"
#import "ios/chrome/browser/ui/toolbar/web_toolbar_delegate.h"
......@@ -33,7 +34,8 @@ class ChromeBrowserState;
// The top-level view controller for the browser UI. Manages other controllers
// which implement the interface.
@interface BrowserViewController : UIViewController<ToolbarOwner,
@interface BrowserViewController : UIViewController<SyncPresenter,
ToolbarOwner,
UrlLoader,
VoiceSearchPresenter,
WebToolbarDelegate>
......
......@@ -167,7 +167,6 @@
#import "ios/chrome/browser/ui/reading_list/reading_list_menu_notifier.h"
#include "ios/chrome/browser/ui/rtl_geometry.h"
#import "ios/chrome/browser/ui/sad_tab/sad_tab_legacy_coordinator.h"
#import "ios/chrome/browser/ui/settings/sync_utils/sync_presenter.h"
#import "ios/chrome/browser/ui/settings/sync_utils/sync_util.h"
#import "ios/chrome/browser/ui/side_swipe/side_swipe_controller.h"
#import "ios/chrome/browser/ui/signin_interaction/public/signin_presenter.h"
......@@ -409,7 +408,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
SnapshotOverlayProvider,
StoreKitLauncher,
SigninPresenter,
SyncPresenter,
TabDialogDelegate,
TabHeadersDelegate,
TabHistoryPresentation,
......
......@@ -15,6 +15,7 @@ extern NSString* const kSignInSkipButtonAccessibilityIdentifier;
namespace ios {
class ChromeBrowserState;
}
@protocol SyncPresenter;
@class TabModel;
// A ChromeSigninViewController that is used during the run.
......@@ -25,6 +26,7 @@ class ChromeBrowserState;
tabModel:(TabModel*)tabModel
firstRunConfig:(FirstRunConfiguration*)firstRunConfig
signInIdentity:(ChromeIdentity*)identity
presenter:(id<SyncPresenter>)presenter
dispatcher:(id<ApplicationCommands>)dispatcher;
@end
......
......@@ -14,7 +14,6 @@
#import "ios/chrome/browser/ui/commands/show_signin_command.h"
#import "ios/chrome/browser/ui/first_run/first_run_util.h"
#import "ios/chrome/browser/ui/promos/signin_promo_view_controller.h"
#import "ios/chrome/browser/ui/settings/sync_utils/sync_presenter.h"
#include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/public/provider/chrome/browser/chrome_browser_provider.h"
......@@ -33,22 +32,26 @@ NSString* const kSignInSkipButtonAccessibilityIdentifier =
@"SkipButtonAccessibilityIdentifier";
@interface FirstRunChromeSigninViewController ()<
ChromeSigninViewControllerDelegate,
SyncPresenter> {
ChromeSigninViewControllerDelegate> {
__weak TabModel* _tabModel;
FirstRunConfiguration* _firstRunConfig;
__weak ChromeIdentity* _identity;
BOOL _hasRecordedSigninStarted;
}
// Presenter for showing sync-related UI.
@property(nonatomic, readonly, weak) id<SyncPresenter> presenter;
@end
@implementation FirstRunChromeSigninViewController
@synthesize presenter = _presenter;
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
tabModel:(TabModel*)tabModel
firstRunConfig:(FirstRunConfiguration*)firstRunConfig
signInIdentity:(ChromeIdentity*)identity
presenter:(id<SyncPresenter>)presenter
dispatcher:(id<ApplicationCommands>)dispatcher {
self = [super
initWithBrowserState:browserState
......@@ -61,6 +64,7 @@ NSString* const kSignInSkipButtonAccessibilityIdentifier =
_tabModel = tabModel;
_firstRunConfig = firstRunConfig;
_identity = identity;
_presenter = presenter;
self.delegate = self;
}
return self;
......@@ -102,7 +106,7 @@ NSString* const kSignInSkipButtonAccessibilityIdentifier =
- (void)finishFirstRunAndDismissWithCompletion:(ProceduralBlock)completion {
DCHECK(self.presentingViewController);
FinishFirstRun(self.browserState, [_tabModel currentTab], _firstRunConfig,
self /* id<SyncPresenter> */);
self.presenter);
[self.presentingViewController dismissViewControllerAnimated:YES
completion:^{
FirstRunDismissed();
......@@ -182,24 +186,4 @@ NSString* const kSignInSkipButtonAccessibilityIdentifier =
IDS_IOS_FIRSTRUN_ACCOUNT_CONSISTENCY_SKIP_BUTTON);
}
#pragma mark - SyncPresenter
- (void)showReauthenticateSignin {
[self.dispatcher
showSignin:
[[ShowSigninCommand alloc]
initWithOperation:AUTHENTICATION_OPERATION_REAUTHENTICATE
accessPoint:signin_metrics::AccessPoint::
ACCESS_POINT_UNKNOWN]
baseViewController:self];
}
- (void)showSyncSettings {
[self.dispatcher showSyncSettingsFromViewController:self];
}
- (void)showSyncPassphraseSettings {
[self.dispatcher showSyncPassphraseSettingsFromViewController:self];
}
@end
......@@ -10,6 +10,7 @@
extern NSString* const kUMAMetricsButtonAccessibilityIdentifier;
@protocol ApplicationCommands;
@protocol SyncPresenter;
@class TabModel;
namespace ios {
......@@ -30,6 +31,7 @@ class ChromeBrowserState;
// which can be nil.
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
tabModel:(TabModel*)tabModel
presenter:(id<SyncPresenter>)presenter
dispatcher:(id<ApplicationCommands>)dispatcher
NS_DESIGNATED_INITIALIZER;
......
......@@ -55,6 +55,9 @@ const BOOL kDefaultStatsCheckboxValue = YES;
// The animation which occurs at launch has run.
@property(nonatomic, assign) BOOL ranLaunchAnimation;
// Presenter for showing sync-related UI.
@property(nonatomic, readonly, weak) id<SyncPresenter> presenter;
@property(nonatomic, readonly, weak) id<ApplicationCommands> dispatcher;
@end
......@@ -62,6 +65,7 @@ const BOOL kDefaultStatsCheckboxValue = YES;
@implementation WelcomeToChromeViewController
@synthesize ranLaunchAnimation = _ranLaunchAnimation;
@synthesize presenter = _presenter;
@synthesize dispatcher = _dispatcher;
+ (BOOL)defaultStatsCheckboxValue {
......@@ -78,6 +82,7 @@ const BOOL kDefaultStatsCheckboxValue = YES;
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
tabModel:(TabModel*)tabModel
presenter:(id<SyncPresenter>)presenter
dispatcher:(id<ApplicationCommands>)dispatcher {
DCHECK(browserState);
DCHECK(tabModel);
......@@ -85,6 +90,7 @@ const BOOL kDefaultStatsCheckboxValue = YES;
if (self) {
browserState_ = browserState;
tabModel_ = tabModel;
_presenter = presenter;
_dispatcher = dispatcher;
}
return self;
......@@ -173,6 +179,7 @@ const BOOL kDefaultStatsCheckboxValue = YES;
tabModel:tabModel_
firstRunConfig:firstRunConfig
signInIdentity:nil
presenter:self.presenter
dispatcher:self.dispatcher];
CATransition* transition = [CATransition animation];
......
......@@ -44,6 +44,7 @@ class WelcomeToChromeViewControllerTest : public PlatformTest {
controller_ = [[WelcomeToChromeViewController alloc]
initWithBrowserState:chrome_browser_state_.get()
tabModel:tabModel
presenter:nil
dispatcher:nil];
[controller_ loadView];
}
......
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