Commit 6c31ebb1 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Add a way to close the ConsentBump

This CL adds a delegate for the ConsentBumpCoordinator, notifying it
when the coordinator is finished, with the option chosed by the user.

Bug: 866506
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ia192a4e34da1daab1b969c86d91ea14e1738fcaf
Reviewed-on: https://chromium-review.googlesource.com/1162161
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580840}
parent aed19d52
...@@ -9,6 +9,7 @@ source_set("consent_bump") { ...@@ -9,6 +9,7 @@ source_set("consent_bump") {
sources = [ sources = [
"consent_bump_coordinator.h", "consent_bump_coordinator.h",
"consent_bump_coordinator.mm", "consent_bump_coordinator.mm",
"consent_bump_coordinator_delegate.h",
"consent_bump_mediator.h", "consent_bump_mediator.h",
"consent_bump_mediator.mm", "consent_bump_mediator.mm",
"consent_bump_personalization_coordinator.h", "consent_bump_personalization_coordinator.h",
...@@ -31,6 +32,7 @@ source_set("consent_bump_ui") { ...@@ -31,6 +32,7 @@ source_set("consent_bump_ui") {
"consent_bump_consumer.h", "consent_bump_consumer.h",
"consent_bump_option_button.h", "consent_bump_option_button.h",
"consent_bump_option_button.mm", "consent_bump_option_button.mm",
"consent_bump_option_type.h",
"consent_bump_personalization_view_controller.h", "consent_bump_personalization_view_controller.h",
"consent_bump_personalization_view_controller.mm", "consent_bump_personalization_view_controller.mm",
"consent_bump_view_controller.h", "consent_bump_view_controller.h",
......
...@@ -7,12 +7,17 @@ ...@@ -7,12 +7,17 @@
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h" #import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
@protocol ConsentBumpCoordinatorDelegate;
// Coordinator handling the consent bump. // Coordinator handling the consent bump.
@interface ConsentBumpCoordinator : ChromeCoordinator @interface ConsentBumpCoordinator : ChromeCoordinator
// ViewController associated with this coordinator. // ViewController associated with this coordinator.
@property(nonatomic, strong, readonly) UIViewController* viewController; @property(nonatomic, strong, readonly) UIViewController* viewController;
// Delegate for this coordinator.
@property(nonatomic, weak) id<ConsentBumpCoordinatorDelegate> delegate;
@end @end
#endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_COORDINATOR_H_ #endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_COORDINATOR_H_
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_coordinator.h" #import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_coordinator.h"
#include "base/logging.h"
#import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_coordinator_delegate.h"
#import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_mediator.h" #import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_mediator.h"
#import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_personalization_coordinator.h" #import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_personalization_coordinator.h"
#import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_view_controller.h" #import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_view_controller.h"
...@@ -36,6 +38,7 @@ ...@@ -36,6 +38,7 @@
@implementation ConsentBumpCoordinator @implementation ConsentBumpCoordinator
@synthesize delegate = _delegate;
@synthesize presentedCoordinatorType = _presentedCoordinatorType; @synthesize presentedCoordinatorType = _presentedCoordinatorType;
@synthesize consentBumpViewController = _consentBumpViewController; @synthesize consentBumpViewController = _consentBumpViewController;
@synthesize unifiedConsentCoordinator = _unifiedConsentCoordinator; @synthesize unifiedConsentCoordinator = _unifiedConsentCoordinator;
...@@ -82,15 +85,31 @@ ...@@ -82,15 +85,31 @@
- (void)consentBumpViewControllerDidTapPrimaryButton: - (void)consentBumpViewControllerDidTapPrimaryButton:
(ConsentBumpViewController*)consentBumpViewController { (ConsentBumpViewController*)consentBumpViewController {
ConsentBumpOptionType type = ConsentBumpOptionTypeNotSet;
switch (self.presentedCoordinatorType) { switch (self.presentedCoordinatorType) {
case ConsentBumpScreenUnifiedConsent: case ConsentBumpScreenUnifiedConsent:
// TODO(crbug.com/866506): Consent bump accepted. type = ConsentBumpOptionTypeTurnOn;
break; break;
case ConsentBumpScreenPersonalization: case ConsentBumpScreenPersonalization:
// TODO(crbug.com/866506): Clarify what should be the behavior at this type = self.personalizationCoordinator.selectedOption;
// point.
break; break;
} }
switch (type) {
case ConsentBumpOptionTypeNoChange:
// TODO(crbug.com/866506): Implement metrics.
break;
case ConsentBumpOptionTypeReview:
// TODO(crbug.com/866506): Implement metrics.
break;
case ConsentBumpOptionTypeTurnOn:
// TODO(crbug.com/866506): Implement metrics + sync updates.
break;
case ConsentBumpOptionTypeNotSet:
NOTREACHED();
break;
}
[self.delegate consentBumpCoordinator:self
didFinishNeedingToShowSettings:(type == ConsentBumpOptionTypeReview)];
} }
- (void)consentBumpViewControllerDidTapSecondaryButton: - (void)consentBumpViewControllerDidTapSecondaryButton:
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_COORDINATOR_DELEGATE_H_
#define IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_COORDINATOR_DELEGATE_H_
#import <Foundation/Foundation.h>
@class ConsentBumpCoordinator;
// Protocol defining a delegate for the ConsentBump coordinator.
@protocol ConsentBumpCoordinatorDelegate
// Notifies the delegate that the |coordinator| has finished with the type
// |optionType|.
- (void)consentBumpCoordinator:(ConsentBumpCoordinator*)coordinator
didFinishNeedingToShowSettings:(BOOL)shouldShowSettings;
@end
#endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_COORDINATOR_DELEGATE_H_
...@@ -7,13 +7,7 @@ ...@@ -7,13 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
// Different option types. #import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_option_type.h"
typedef NS_ENUM(NSInteger, ConsentBumpOptionType) {
ConsentBumpOptionTypeDefault = 0,
ConsentBumpOptionTypeNoChange,
ConsentBumpOptionTypeReview,
ConsentBumpOptionTypeTurnOn
};
// Button defining a consent bump option. // Button defining a consent bump option.
@interface ConsentBumpOptionButton : UIButton @interface ConsentBumpOptionButton : UIButton
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_OPTION_TYPE_H_
#define IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_OPTION_TYPE_H_
#import <Foundation/Foundation.h>
// Different option types.
typedef NS_ENUM(NSInteger, ConsentBumpOptionType) {
ConsentBumpOptionTypeNotSet = 0,
ConsentBumpOptionTypeNoChange,
ConsentBumpOptionTypeReview,
ConsentBumpOptionTypeTurnOn
};
#endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_OPTION_TYPE_H_
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#ifndef IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_PERSONALIZATION_COORDINATOR_H_ #ifndef IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_PERSONALIZATION_COORDINATOR_H_
#define IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_PERSONALIZATION_COORDINATOR_H_ #define IOS_CHROME_BROWSER_UI_AUTHENTICATION_CONSENT_BUMP_CONSENT_BUMP_PERSONALIZATION_COORDINATOR_H_
#import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_option_button.h" #import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_option_type.h"
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h" #import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
// Coordinator for handling the ConsentBump Personalization screen. // Coordinator for handling the ConsentBump Personalization screen.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_option_button.h" #import "ios/chrome/browser/ui/authentication/consent_bump/consent_bump_option_type.h"
// View controller displaying the Personalization screen. // View controller displaying the Personalization screen.
@interface ConsentBumpPersonalizationViewController : UIViewController @interface ConsentBumpPersonalizationViewController : UIViewController
......
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