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

[iOS] Plugging "Google Activity Controls" and "Encryption" dialog

This patch enables to open "Google Activity Controls"[1] and "Encryption"[2] from
the Google services settings[3]

[1]: https://drive.google.com/open?id=1VenMSZPfe-7cM9trtLJgIJvQopqpdDWk
[2]: https://drive.google.com/open?id=1jrAQwjCcV3o_UnPjCasmisDPtmyWsE1u
[3]: https://drive.google.com/open?id=15GJUEJrTAgsREZ5zHjf6xO0ivwLhil8Q

Bug: 827072
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I000c348334242e6274b0de7cbd59b0eee23dd521
Reviewed-on: https://chromium-review.googlesource.com/1169163
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582595}
parent 7a14097d
...@@ -4,29 +4,43 @@ ...@@ -4,29 +4,43 @@
#import "ios/chrome/browser/ui/settings/google_services_settings_coordinator.h" #import "ios/chrome/browser/ui/settings/google_services_settings_coordinator.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/google/core/common/google_util.h" #include "components/google/core/common/google_util.h"
#include "ios/chrome/browser/application_context.h" #include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/signin/authentication_service.h"
#import "ios/chrome/browser/signin/authentication_service_factory.h" #import "ios/chrome/browser/signin/authentication_service_factory.h"
#include "ios/chrome/browser/sync/profile_sync_service_factory.h" #include "ios/chrome/browser/sync/profile_sync_service_factory.h"
#include "ios/chrome/browser/sync/sync_setup_service_factory.h" #include "ios/chrome/browser/sync/sync_setup_service_factory.h"
#import "ios/chrome/browser/ui/commands/application_commands.h" #import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h" #import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/icons/chrome_icon.h"
#import "ios/chrome/browser/ui/settings/google_services_settings_local_commands.h" #import "ios/chrome/browser/ui/settings/google_services_settings_local_commands.h"
#import "ios/chrome/browser/ui/settings/google_services_settings_mediator.h" #import "ios/chrome/browser/ui/settings/google_services_settings_mediator.h"
#import "ios/chrome/browser/ui/settings/google_services_settings_view_controller.h" #import "ios/chrome/browser/ui/settings/google_services_settings_view_controller.h"
#import "ios/chrome/browser/ui/settings/sync_encryption_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/sync_encryption_passphrase_collection_view_controller.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/signin/chrome_identity_browser_opener.h"
#include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h"
#include "net/base/mac/url_conversions.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
@interface GoogleServicesSettingsCoordinator ()< @interface GoogleServicesSettingsCoordinator ()<
ChromeIdentityBrowserOpener,
GoogleServicesSettingsLocalCommands, GoogleServicesSettingsLocalCommands,
GoogleServicesSettingsViewControllerPresentationDelegate> GoogleServicesSettingsViewControllerPresentationDelegate>
// Google services settings mediator. // Google services settings mediator.
@property(nonatomic, strong) GoogleServicesSettingsMediator* mediator; @property(nonatomic, strong) GoogleServicesSettingsMediator* mediator;
// Returns the authentication service.
@property(nonatomic, assign, readonly) AuthenticationService* authService;
@end @end
...@@ -55,8 +69,7 @@ ...@@ -55,8 +69,7 @@
syncService:syncService syncService:syncService
syncSetupService:syncSetupService]; syncSetupService:syncSetupService];
self.mediator.consumer = viewController; self.mediator.consumer = viewController;
self.mediator.authService = self.mediator.authService = self.authService;
AuthenticationServiceFactory::GetForBrowserState(self.browserState);
viewController.modelDelegate = self.mediator; viewController.modelDelegate = self.mediator;
viewController.serviceDelegate = self.mediator; viewController.serviceDelegate = self.mediator;
DCHECK(self.navigationController); DCHECK(self.navigationController);
...@@ -64,14 +77,54 @@ ...@@ -64,14 +77,54 @@
animated:YES]; animated:YES];
} }
#pragma mark - Private
- (void)closeGoogleActivitySettings:(id)sender {
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - Properties
- (AuthenticationService*)authService {
return AuthenticationServiceFactory::GetForBrowserState(self.browserState);
}
#pragma mark - GoogleServicesSettingsLocalCommands #pragma mark - GoogleServicesSettingsLocalCommands
- (void)openGoogleActivityControlsDialog { - (void)openGoogleActivityControlsDialog {
// Needs to be implemented. base::RecordAction(base::UserMetricsAction(
"Signin_AccountSettings_GoogleActivityControlsClicked"));
UINavigationController* settingsDetails =
ios::GetChromeBrowserProvider()
->GetChromeIdentityService()
->CreateWebAndAppSettingDetailsController(
self.authService->GetAuthenticatedIdentity(), self);
UIImage* closeIcon = [ChromeIcon closeIcon];
SEL action = @selector(closeGoogleActivitySettings:);
[settingsDetails.topViewController navigationItem].leftBarButtonItem =
[ChromeIcon templateBarButtonItemWithImage:closeIcon
target:self
action:action];
[self.navigationController presentViewController:settingsDetails
animated:YES
completion:nil];
} }
- (void)openEncryptionDialog { - (void)openEncryptionDialog {
// Needs to be implemented. browser_sync::ProfileSyncService* syncService =
ProfileSyncServiceFactory::GetForBrowserState(self.browserState);
SettingsRootCollectionViewController* controllerToPush;
// If there was a sync error, prompt the user to enter the passphrase.
// Otherwise, show the full encryption options.
if (syncService->IsPassphraseRequired()) {
controllerToPush = [[SyncEncryptionPassphraseCollectionViewController alloc]
initWithBrowserState:self.browserState];
} else {
controllerToPush = [[SyncEncryptionCollectionViewController alloc]
initWithBrowserState:self.browserState];
}
controllerToPush.dispatcher = self.dispatcher;
[self.navigationController pushViewController:controllerToPush animated:YES];
} }
- (void)openManageSyncedDataWebPage { - (void)openManageSyncedDataWebPage {
...@@ -91,4 +144,14 @@ ...@@ -91,4 +144,14 @@
[self.delegate googleServicesSettingsCoordinatorDidRemove:self]; [self.delegate googleServicesSettingsCoordinatorDidRemove:self];
} }
#pragma mark - ChromeIdentityBrowserOpener
- (void)openURL:(NSURL*)URL
view:(UIView*)view
viewController:(UIViewController*)viewController {
OpenNewTabCommand* command =
[OpenNewTabCommand commandWithURLFromChrome:net::GURLWithNSURL(URL)];
[self.dispatcher closeSettingsUIAndOpenURL:command];
}
@end @end
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