Commit d6700521 authored by David Jean's avatar David Jean Committed by Commit Bot

[ios] sync clear browsing settings for multi-window

Bug: 1079425
Change-Id: Ib39c9280714bd7f386d74979d9849f832957ad0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270063
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786302}
parent 90a19e49
......@@ -10,7 +10,7 @@
#include "base/ios/block_types.h"
class ChromeBrowserState;
@class ListItem;
@class TableViewItem;
namespace browsing_data {
enum class TimePeriod;
......@@ -24,8 +24,9 @@ enum class BrowsingDataRemoveMask;
timePeriod:(browsing_data::TimePeriod)timePeriod
removeMask:(BrowsingDataRemoveMask)removeMask
completionBlock:(ProceduralBlock)completionBlock;
// Updates contents of a cell for a given item.
- (void)updateCellsForItem:(ListItem*)item;
// Updates contents of a cell for a given item. Set reload to NO if a simple
// reconfigre is enough.
- (void)updateCellsForItem:(TableViewItem*)item reload:(BOOL)reload;
// Indicate to user that data has been cleared.
- (void)showBrowsingHistoryRemovedDialog;
......
......@@ -168,18 +168,6 @@
self.navigationController.toolbarHidden = NO;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
// Write data type cell selection states back to the browser state.
NSArray* dataTypeItems = [self.tableViewModel
itemsInSectionWithIdentifier:SectionIdentifierDataTypes];
for (TableViewClearBrowsingDataItem* dataTypeItem in dataTypeItems) {
DCHECK([dataTypeItem isKindOfClass:[TableViewClearBrowsingDataItem class]]);
self.browserState->GetPrefs()->SetBoolean(dataTypeItem.prefName,
dataTypeItem.checked);
}
}
- (void)loadModel {
[super loadModel];
[self.dataManager loadModel:self.tableViewModel];
......@@ -276,9 +264,10 @@
DCHECK([item isKindOfClass:[TableViewClearBrowsingDataItem class]]);
TableViewClearBrowsingDataItem* clearBrowsingDataItem =
base::mac::ObjCCastStrict<TableViewClearBrowsingDataItem>(item);
clearBrowsingDataItem.checked = !clearBrowsingDataItem.checked;
[self reconfigureCellsForItems:@[ clearBrowsingDataItem ]];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
self.browserState->GetPrefs()->SetBoolean(clearBrowsingDataItem.prefName,
!clearBrowsingDataItem.checked);
// UI update will be trigerred by data manager.
break;
}
default:
......@@ -297,15 +286,22 @@
#pragma mark - ClearBrowsingDataConsumer
- (void)updateCellsForItem:(ListItem*)item {
- (void)updateCellsForItem:(TableViewItem*)item reload:(BOOL)reload {
if (self.suppressTableViewUpdates)
return;
// Reload the item instead of reconfiguring it. This might update
// TableViewTextLinkItems which which can have different number of lines,
// thus the cell height needs to adapt accordingly.
[self reloadCellsForItems:@[ item ]
withRowAnimation:UITableViewRowAnimationAutomatic];
if (!reload) {
[self reconfigureCellsForItems:@[ item ]];
NSIndexPath* indexPath = [self.tableViewModel
indexPathForItem:static_cast<TableViewItem*>(item)];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
} else {
// Reload the item instead of reconfiguring it. This might update
// TableViewTextLinkItems which which can have different number of lines,
// thus the cell height needs to adapt accordingly.
[self reloadCellsForItems:@[ item ]
withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
- (void)removeBrowsingDataForBrowserState:(ChromeBrowserState*)browserState
......
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