Commit 4e78688b authored by Ewann's avatar Ewann Committed by Commit Bot

[iOS] Updates privacy coordinator

This CL refactor the privacy table view controller.

Bug: 1064961
Change-Id: I2ae5c23305c3d26cd61388b0a3ef925ad146f004
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2126233Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754884}
parent 309dae88
...@@ -9,6 +9,7 @@ source_set("privacy") { ...@@ -9,6 +9,7 @@ source_set("privacy") {
"handoff_table_view_controller.mm", "handoff_table_view_controller.mm",
"privacy_coordinator.h", "privacy_coordinator.h",
"privacy_coordinator.mm", "privacy_coordinator.mm",
"privacy_navigation_commands.h",
"privacy_table_view_controller.h", "privacy_table_view_controller.h",
"privacy_table_view_controller.mm", "privacy_table_view_controller.mm",
] ]
......
...@@ -5,7 +5,11 @@ ...@@ -5,7 +5,11 @@
#import "ios/chrome/browser/ui/settings/privacy/privacy_coordinator.h" #import "ios/chrome/browser/ui/settings/privacy/privacy_coordinator.h"
#include "ios/chrome/browser/main/browser.h" #include "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h" #import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/privacy/handoff_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/privacy/privacy_navigation_commands.h"
#import "ios/chrome/browser/ui/settings/privacy/privacy_table_view_controller.h" #import "ios/chrome/browser/ui/settings/privacy/privacy_table_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -13,8 +17,10 @@ ...@@ -13,8 +17,10 @@
#endif #endif
@interface PrivacyCoordinator () < @interface PrivacyCoordinator () <
PrivacyNavigationCommands,
PrivacyTableViewControllerPresentationDelegate> PrivacyTableViewControllerPresentationDelegate>
@property(nonatomic, strong) CommandDispatcher* dispatcher;
@property(nonatomic, strong) PrivacyTableViewController* viewController; @property(nonatomic, strong) PrivacyTableViewController* viewController;
@end @end
...@@ -35,10 +41,12 @@ ...@@ -35,10 +41,12 @@
#pragma mark - ChromeCoordinator #pragma mark - ChromeCoordinator
- (void)start { - (void)start {
self.dispatcher = self.browser->GetCommandDispatcher();
self.viewController = self.viewController =
[[PrivacyTableViewController alloc] initWithBrowser:self.browser]; [[PrivacyTableViewController alloc] initWithBrowser:self.browser];
DCHECK(self.baseNavigationController); DCHECK(self.baseNavigationController);
self.viewController.handler = self;
[self.baseNavigationController pushViewController:self.viewController [self.baseNavigationController pushViewController:self.viewController
animated:YES]; animated:YES];
self.viewController.presentationDelegate = self; self.viewController.presentationDelegate = self;
...@@ -59,4 +67,24 @@ ...@@ -59,4 +67,24 @@
[self.delegate privacyCoordinatorViewControllerWasRemoved:self]; [self.delegate privacyCoordinatorViewControllerWasRemoved:self];
} }
#pragma mark - PrivacyNavigationCommands
- (void)showHandoff {
HandoffTableViewController* viewController =
[[HandoffTableViewController alloc]
initWithBrowserState:self.browserState];
viewController.dispatcher = self.viewController.dispatcher;
[self.baseNavigationController pushViewController:viewController
animated:YES];
}
- (void)showClearBrowsingData {
ClearBrowsingDataTableViewController* viewController =
[[ClearBrowsingDataTableViewController alloc]
initWithBrowser:self.browser];
viewController.dispatcher = self.viewController.dispatcher;
[self.baseNavigationController pushViewController:viewController
animated:YES];
}
@end @end
// Copyright 2020 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_SETTINGS_PRIVACY_PRIVACY_NAVIGATION_COMMANDS_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_PRIVACY_NAVIGATION_COMMANDS_H_
// Commands related to the privacy navigation inside the privacy view
// controller.
@protocol PrivacyNavigationCommands
// Shows Handoff screen.
- (void)showHandoff;
// Shows ClearBrowsingData screen.
- (void)showClearBrowsingData;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_PRIVACY_NAVIGATION_COMMANDS_H_
...@@ -13,6 +13,8 @@ class Browser; ...@@ -13,6 +13,8 @@ class Browser;
// The accessibility identifier of the privacy settings collection view. // The accessibility identifier of the privacy settings collection view.
extern NSString* const kPrivacyTableViewId; extern NSString* const kPrivacyTableViewId;
@protocol PrivacyNavigationCommands;
// Delegate for presentation events related to // Delegate for presentation events related to
// PrivacyTableViewController. // PrivacyTableViewController.
@protocol PrivacyTableViewControllerPresentationDelegate @protocol PrivacyTableViewControllerPresentationDelegate
...@@ -34,6 +36,9 @@ extern NSString* const kPrivacyTableViewId; ...@@ -34,6 +36,9 @@ extern NSString* const kPrivacyTableViewId;
- (instancetype)initWithStyle:(UITableViewStyle)style NS_UNAVAILABLE; - (instancetype)initWithStyle:(UITableViewStyle)style NS_UNAVAILABLE;
// Handler used to navigate inside the privacy.
@property(nonatomic, weak) id<PrivacyNavigationCommands> handler;
@end @end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_PRIVACY_TABLE_VIEW_CONTROLLER_H_ #endif // IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_PRIVACY_TABLE_VIEW_CONTROLLER_H_
...@@ -18,9 +18,8 @@ ...@@ -18,9 +18,8 @@
#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/settings/cells/settings_switch_cell.h" #import "ios/chrome/browser/ui/settings/cells/settings_switch_cell.h"
#import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_ui_delegate.h" #import "ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_ui_delegate.h"
#import "ios/chrome/browser/ui/settings/privacy/handoff_table_view_controller.h" #import "ios/chrome/browser/ui/settings/privacy/privacy_navigation_commands.h"
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h" #import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/chrome/browser/ui/settings/settings_table_view_controller_constants.h" #import "ios/chrome/browser/ui/settings/settings_table_view_controller_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_detail_icon_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_detail_icon_item.h"
...@@ -211,32 +210,16 @@ const char kGoogleServicesSettingsURL[] = "settings://open_google_services"; ...@@ -211,32 +210,16 @@ const char kGoogleServicesSettingsURL[] = "settings://open_google_services";
didSelectRowAtIndexPath:(NSIndexPath*)indexPath { didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
[super tableView:tableView didSelectRowAtIndexPath:indexPath]; [super tableView:tableView didSelectRowAtIndexPath:indexPath];
NSInteger itemType = [self.tableViewModel itemTypeForIndexPath:indexPath]; NSInteger itemType = [self.tableViewModel itemTypeForIndexPath:indexPath];
// Items that push a new view controller.
UIViewController<SettingsRootViewControlling>* controller;
switch (itemType) { switch (itemType) {
case ItemTypeOtherDevicesHandoff: case ItemTypeOtherDevicesHandoff:
controller = [[HandoffTableViewController alloc] [self.handler showHandoff];
initWithBrowserState:_browserState];
break; break;
case ItemTypeClearBrowsingDataClear: { case ItemTypeClearBrowsingDataClear:
ClearBrowsingDataTableViewController* clearBrowsingDataViewController = [self.handler showClearBrowsingData];
[[ClearBrowsingDataTableViewController alloc]
initWithBrowser:_browser];
clearBrowsingDataViewController.delegate = self;
controller = clearBrowsingDataViewController;
break; break;
}
default: default:
break; break;
} }
if (controller) {
controller.dispatcher = self.dispatcher;
[self.navigationController pushViewController:controller animated:YES];
}
[tableView deselectRowAtIndexPath:indexPath animated:YES]; [tableView deselectRowAtIndexPath:indexPath animated:YES];
} }
......
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