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 @@
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_local_commands.h"
@protocol ApplicationCommands;
@protocol UrlLoader;
@protocol HistoryLocalCommands;
@protocol HistoryPresentationDelegate;
......@@ -21,6 +22,9 @@
// Delegate for this coordinator.
@property(nonatomic, weak) id<HistoryLocalCommands> localDispatcher;
// Dispatcher for view controller.
@property(nonatomic, weak) id<ApplicationCommands> dispatcher;
// The UrlLoader used by this coordinator.
@property(nonatomic, weak) id<UrlLoader> loader;
......
......@@ -26,6 +26,7 @@
@end
@implementation HistoryClearBrowsingDataCoordinator
@synthesize dispatcher = _dispatcher;
@synthesize historyClearBrowsingDataNavigationController =
_historyClearBrowsingDataNavigationController;
@synthesize loader = _loader;
......@@ -38,6 +39,7 @@
initWithBrowserState:self.browserState];
clearBrowsingDataTableViewController.extendedLayoutIncludesOpaqueBars = YES;
clearBrowsingDataTableViewController.localDispatcher = self;
clearBrowsingDataTableViewController.dispatcher = self.dispatcher;
// Configure and present ClearBrowsingDataNavigationController.
self.historyClearBrowsingDataNavigationController =
[[TableViewNavigationController alloc]
......
......@@ -127,6 +127,7 @@
self.historyClearBrowsingDataCoordinator.presentationDelegate =
self.presentationDelegate;
self.historyClearBrowsingDataCoordinator.loader = self.loader;
self.historyClearBrowsingDataCoordinator.dispatcher = self.dispatcher;
[self.historyClearBrowsingDataCoordinator start];
} else {
[self.dispatcher showClearBrowsingDataSettingsFromViewController:
......
......@@ -22,17 +22,22 @@ enum class TimePeriod;
enum class BrowsingDataRemoveMask;
@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.
- (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|.
- (void)updateCounter:(NSInteger)itemType detailText:(NSString*)detailText;
// Indicate to user that data has been cleared.
- (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
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CLEAR_BROWSING_DATA_CONSUMER_H_
......@@ -11,6 +11,7 @@ namespace ios {
class ChromeBrowserState;
}
@protocol ApplicationCommands;
@protocol ClearBrowsingDataLocalCommands;
// TableView for clearing browsing data (including history,
......@@ -28,6 +29,9 @@ class ChromeBrowserState;
// Local Dispatcher for this ClearBrowsingDataTableView.
@property(nonatomic, weak) id<ClearBrowsingDataLocalCommands> localDispatcher;
// The dispatcher used by this ViewController.
@property(nonatomic, weak) id<ApplicationCommands> dispatcher;
@end
#endif // IOS_CHROME_BROWSER_UI_HISTORY_CLEAR_BROWSING_DATA_TABLE_VIEW_CONTROLLER_H_
......@@ -6,6 +6,7 @@
#include "base/mac/foundation_util.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"
#include "ios/chrome/browser/ui/settings/clear_browsing_data_local_commands.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_manager.h"
......@@ -30,7 +31,8 @@ class ChromeBrowserState;
}
@interface ClearBrowsingDataTableViewController ()<
TableViewTextLinkCellDelegate>
TableViewTextLinkCellDelegate,
ClearBrowsingDataConsumer>
// TODO(crbug.com/850699): remove direct dependency and replace with
// delegate.
......@@ -44,6 +46,7 @@ class ChromeBrowserState;
@implementation ClearBrowsingDataTableViewController
@synthesize browserState = _browserState;
@synthesize dataManager = _dataManager;
@synthesize dispatcher = _dispatcher;
@synthesize localDispatcher = _localDispatcher;
#pragma mark - ViewController Lifecycle.
......@@ -56,6 +59,7 @@ class ChromeBrowserState;
_dataManager = [[ClearBrowsingDataManager alloc]
initWithBrowserState:browserState
listType:ClearBrowsingDataListType::kListTypeTableView];
_dataManager.consumer = self;
}
return self;
}
......@@ -180,6 +184,22 @@ class ChromeBrowserState;
[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
- (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