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") {
"handoff_table_view_controller.mm",
"privacy_coordinator.h",
"privacy_coordinator.mm",
"privacy_navigation_commands.h",
"privacy_table_view_controller.h",
"privacy_table_view_controller.mm",
]
......
......@@ -5,7 +5,11 @@
#import "ios/chrome/browser/ui/settings/privacy/privacy_coordinator.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/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"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -13,8 +17,10 @@
#endif
@interface PrivacyCoordinator () <
PrivacyNavigationCommands,
PrivacyTableViewControllerPresentationDelegate>
@property(nonatomic, strong) CommandDispatcher* dispatcher;
@property(nonatomic, strong) PrivacyTableViewController* viewController;
@end
......@@ -35,10 +41,12 @@
#pragma mark - ChromeCoordinator
- (void)start {
self.dispatcher = self.browser->GetCommandDispatcher();
self.viewController =
[[PrivacyTableViewController alloc] initWithBrowser:self.browser];
DCHECK(self.baseNavigationController);
self.viewController.handler = self;
[self.baseNavigationController pushViewController:self.viewController
animated:YES];
self.viewController.presentationDelegate = self;
......@@ -59,4 +67,24 @@
[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
// 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;
// The accessibility identifier of the privacy settings collection view.
extern NSString* const kPrivacyTableViewId;
@protocol PrivacyNavigationCommands;
// Delegate for presentation events related to
// PrivacyTableViewController.
@protocol PrivacyTableViewControllerPresentationDelegate
......@@ -34,6 +36,9 @@ extern NSString* const kPrivacyTableViewId;
- (instancetype)initWithStyle:(UITableViewStyle)style NS_UNAVAILABLE;
// Handler used to navigate inside the privacy.
@property(nonatomic, weak) id<PrivacyNavigationCommands> handler;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_PRIVACY_TABLE_VIEW_CONTROLLER_H_
......@@ -18,9 +18,8 @@
#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_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/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_table_view_controller_constants.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";
didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
NSInteger itemType = [self.tableViewModel itemTypeForIndexPath:indexPath];
// Items that push a new view controller.
UIViewController<SettingsRootViewControlling>* controller;
switch (itemType) {
case ItemTypeOtherDevicesHandoff:
controller = [[HandoffTableViewController alloc]
initWithBrowserState:_browserState];
[self.handler showHandoff];
break;
case ItemTypeClearBrowsingDataClear: {
ClearBrowsingDataTableViewController* clearBrowsingDataViewController =
[[ClearBrowsingDataTableViewController alloc]
initWithBrowser:_browser];
clearBrowsingDataViewController.delegate = self;
controller = clearBrowsingDataViewController;
case ItemTypeClearBrowsingDataClear:
[self.handler showClearBrowsingData];
break;
}
default:
break;
}
if (controller) {
controller.dispatcher = self.dispatcher;
[self.navigationController pushViewController:controller 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