Commit e5cfa653 authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Implement clear data logic for ClearBrowsingDataTableViewController

- Makes ClearBrowsingDataTableViewController conform to ClearBrowsingDataConsumer.
- Mark methods related to IsNewClearBrowsingDataUIEnabled and show other forms of browsing history dialog in ClearBrowsingDataConsumer as optional

Change-Id: I24f8d1a259537ddf962383fa17079beaa16e0132
Reviewed-on: https://chromium-review.googlesource.com/1123652
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572320}
parent af2321ba
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h" #import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_local_commands.h" #import "ios/chrome/browser/ui/settings/clear_browsing_data_local_commands.h"
@protocol ApplicationCommands;
@protocol UrlLoader; @protocol UrlLoader;
@protocol HistoryLocalCommands; @protocol HistoryLocalCommands;
@protocol HistoryPresentationDelegate; @protocol HistoryPresentationDelegate;
...@@ -21,6 +22,9 @@ ...@@ -21,6 +22,9 @@
// Delegate for this coordinator. // Delegate for this coordinator.
@property(nonatomic, weak) id<HistoryLocalCommands> localDispatcher; @property(nonatomic, weak) id<HistoryLocalCommands> localDispatcher;
// Dispatcher for view controller.
@property(nonatomic, weak) id<ApplicationCommands> dispatcher;
// The UrlLoader used by this coordinator. // The UrlLoader used by this coordinator.
@property(nonatomic, weak) id<UrlLoader> loader; @property(nonatomic, weak) id<UrlLoader> loader;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
@end @end
@implementation HistoryClearBrowsingDataCoordinator @implementation HistoryClearBrowsingDataCoordinator
@synthesize dispatcher = _dispatcher;
@synthesize historyClearBrowsingDataNavigationController = @synthesize historyClearBrowsingDataNavigationController =
_historyClearBrowsingDataNavigationController; _historyClearBrowsingDataNavigationController;
@synthesize loader = _loader; @synthesize loader = _loader;
...@@ -38,6 +39,7 @@ ...@@ -38,6 +39,7 @@
initWithBrowserState:self.browserState]; initWithBrowserState:self.browserState];
clearBrowsingDataTableViewController.extendedLayoutIncludesOpaqueBars = YES; clearBrowsingDataTableViewController.extendedLayoutIncludesOpaqueBars = YES;
clearBrowsingDataTableViewController.localDispatcher = self; clearBrowsingDataTableViewController.localDispatcher = self;
clearBrowsingDataTableViewController.dispatcher = self.dispatcher;
// Configure and present ClearBrowsingDataNavigationController. // Configure and present ClearBrowsingDataNavigationController.
self.historyClearBrowsingDataNavigationController = self.historyClearBrowsingDataNavigationController =
[[TableViewNavigationController alloc] [[TableViewNavigationController alloc]
......
...@@ -127,6 +127,7 @@ ...@@ -127,6 +127,7 @@
self.historyClearBrowsingDataCoordinator.presentationDelegate = self.historyClearBrowsingDataCoordinator.presentationDelegate =
self.presentationDelegate; self.presentationDelegate;
self.historyClearBrowsingDataCoordinator.loader = self.loader; self.historyClearBrowsingDataCoordinator.loader = self.loader;
self.historyClearBrowsingDataCoordinator.dispatcher = self.dispatcher;
[self.historyClearBrowsingDataCoordinator start]; [self.historyClearBrowsingDataCoordinator start];
} else { } else {
[self.dispatcher showClearBrowsingDataSettingsFromViewController: [self.dispatcher showClearBrowsingDataSettingsFromViewController:
......
...@@ -22,17 +22,22 @@ enum class TimePeriod; ...@@ -22,17 +22,22 @@ enum class TimePeriod;
enum class BrowsingDataRemoveMask; enum class BrowsingDataRemoveMask;
@protocol ClearBrowsingDataConsumer<NSObject> @protocol ClearBrowsingDataConsumer<NSObject>
// Execute action to clear browsing data.
- (void)removeBrowsingDataForBrowserState:(ios::ChromeBrowserState*)browserState
timePeriod:(browsing_data::TimePeriod)timePeriod
removeMask:(BrowsingDataRemoveMask)removeMask
completionBlock:(ProceduralBlock)completionBlock;
// Updates contents of a cell for a given item. // Updates contents of a cell for a given item.
- (void)updateCellsForItem:(ListItem*)item; - (void)updateCellsForItem:(ListItem*)item;
// Only necessary for ClearBrowsingDataCollectionView to implement
// IsNewClearBrowsingDataUIEnabled experiment and to show a dialog about other
// forms of browsing history.
@optional
// Updates item of |itemType| with |detailText|. // Updates item of |itemType| with |detailText|.
- (void)updateCounter:(NSInteger)itemType detailText:(NSString*)detailText; - (void)updateCounter:(NSInteger)itemType detailText:(NSString*)detailText;
// Indicate to user that data has been cleared. // Indicate to user that data has been cleared.
- (void)showBrowsingHistoryRemovedDialog; - (void)showBrowsingHistoryRemovedDialog;
// Execute action to clear browsing data.
- (void)removeBrowsingDataForBrowserState:(ios::ChromeBrowserState*)browserState
timePeriod:(browsing_data::TimePeriod)timePeriod
removeMask:(BrowsingDataRemoveMask)removeMask
completionBlock:(ProceduralBlock)completionBlock;
@end @end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CLEAR_BROWSING_DATA_CONSUMER_H_ #endif // IOS_CHROME_BROWSER_UI_SETTINGS_CLEAR_BROWSING_DATA_CONSUMER_H_
...@@ -11,6 +11,7 @@ namespace ios { ...@@ -11,6 +11,7 @@ namespace ios {
class ChromeBrowserState; class ChromeBrowserState;
} }
@protocol ApplicationCommands;
@protocol ClearBrowsingDataLocalCommands; @protocol ClearBrowsingDataLocalCommands;
// TableView for clearing browsing data (including history, // TableView for clearing browsing data (including history,
...@@ -28,6 +29,9 @@ class ChromeBrowserState; ...@@ -28,6 +29,9 @@ class ChromeBrowserState;
// Local Dispatcher for this ClearBrowsingDataTableView. // Local Dispatcher for this ClearBrowsingDataTableView.
@property(nonatomic, weak) id<ClearBrowsingDataLocalCommands> localDispatcher; @property(nonatomic, weak) id<ClearBrowsingDataLocalCommands> localDispatcher;
// The dispatcher used by this ViewController.
@property(nonatomic, weak) id<ApplicationCommands> dispatcher;
@end @end
#endif // IOS_CHROME_BROWSER_UI_HISTORY_CLEAR_BROWSING_DATA_TABLE_VIEW_CONTROLLER_H_ #endif // IOS_CHROME_BROWSER_UI_HISTORY_CLEAR_BROWSING_DATA_TABLE_VIEW_CONTROLLER_H_
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "ios/chrome/browser/browsing_data/browsing_data_remove_mask.h" #include "ios/chrome/browser/browsing_data/browsing_data_remove_mask.h"
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/settings/cells/table_view_clear_browsing_data_item.h" #import "ios/chrome/browser/ui/settings/cells/table_view_clear_browsing_data_item.h"
#include "ios/chrome/browser/ui/settings/clear_browsing_data_local_commands.h" #include "ios/chrome/browser/ui/settings/clear_browsing_data_local_commands.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_manager.h" #import "ios/chrome/browser/ui/settings/clear_browsing_data_manager.h"
...@@ -30,7 +31,8 @@ class ChromeBrowserState; ...@@ -30,7 +31,8 @@ class ChromeBrowserState;
} }
@interface ClearBrowsingDataTableViewController ()< @interface ClearBrowsingDataTableViewController ()<
TableViewTextLinkCellDelegate> TableViewTextLinkCellDelegate,
ClearBrowsingDataConsumer>
// TODO(crbug.com/850699): remove direct dependency and replace with // TODO(crbug.com/850699): remove direct dependency and replace with
// delegate. // delegate.
...@@ -44,6 +46,7 @@ class ChromeBrowserState; ...@@ -44,6 +46,7 @@ class ChromeBrowserState;
@implementation ClearBrowsingDataTableViewController @implementation ClearBrowsingDataTableViewController
@synthesize browserState = _browserState; @synthesize browserState = _browserState;
@synthesize dataManager = _dataManager; @synthesize dataManager = _dataManager;
@synthesize dispatcher = _dispatcher;
@synthesize localDispatcher = _localDispatcher; @synthesize localDispatcher = _localDispatcher;
#pragma mark - ViewController Lifecycle. #pragma mark - ViewController Lifecycle.
...@@ -56,6 +59,7 @@ class ChromeBrowserState; ...@@ -56,6 +59,7 @@ class ChromeBrowserState;
_dataManager = [[ClearBrowsingDataManager alloc] _dataManager = [[ClearBrowsingDataManager alloc]
initWithBrowserState:browserState initWithBrowserState:browserState
listType:ClearBrowsingDataListType::kListTypeTableView]; listType:ClearBrowsingDataListType::kListTypeTableView];
_dataManager.consumer = self;
} }
return self; return self;
} }
...@@ -180,6 +184,22 @@ class ChromeBrowserState; ...@@ -180,6 +184,22 @@ class ChromeBrowserState;
[self.localDispatcher openURL:copiedURL]; [self.localDispatcher openURL:copiedURL];
} }
#pragma mark - ClearBrowsingDataConsumer
- (void)updateCellsForItem:(ListItem*)item {
[self reconfigureCellsForItems:@[ item ]];
}
- (void)removeBrowsingDataForBrowserState:(ios::ChromeBrowserState*)browserState
timePeriod:(browsing_data::TimePeriod)timePeriod
removeMask:(BrowsingDataRemoveMask)removeMask
completionBlock:(ProceduralBlock)completionBlock {
[self.dispatcher removeBrowsingDataForBrowserState:browserState
timePeriod:timePeriod
removeMask:removeMask
completionBlock:completionBlock];
}
#pragma mark - Private Helpers #pragma mark - Private Helpers
- (void)showClearBrowsingDataAlertController { - (void)showClearBrowsingDataAlertController {
......
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