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 @@ ...@@ -10,7 +10,7 @@
#include "base/ios/block_types.h" #include "base/ios/block_types.h"
class ChromeBrowserState; class ChromeBrowserState;
@class ListItem; @class TableViewItem;
namespace browsing_data { namespace browsing_data {
enum class TimePeriod; enum class TimePeriod;
...@@ -24,8 +24,9 @@ enum class BrowsingDataRemoveMask; ...@@ -24,8 +24,9 @@ enum class BrowsingDataRemoveMask;
timePeriod:(browsing_data::TimePeriod)timePeriod timePeriod:(browsing_data::TimePeriod)timePeriod
removeMask:(BrowsingDataRemoveMask)removeMask removeMask:(BrowsingDataRemoveMask)removeMask
completionBlock:(ProceduralBlock)completionBlock; completionBlock:(ProceduralBlock)completionBlock;
// Updates contents of a cell for a given item. // Updates contents of a cell for a given item. Set reload to NO if a simple
- (void)updateCellsForItem:(ListItem*)item; // reconfigre is enough.
- (void)updateCellsForItem:(TableViewItem*)item reload:(BOOL)reload;
// Indicate to user that data has been cleared. // Indicate to user that data has been cleared.
- (void)showBrowsingHistoryRemovedDialog; - (void)showBrowsingHistoryRemovedDialog;
......
...@@ -168,18 +168,6 @@ ...@@ -168,18 +168,6 @@
self.navigationController.toolbarHidden = NO; 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 { - (void)loadModel {
[super loadModel]; [super loadModel];
[self.dataManager loadModel:self.tableViewModel]; [self.dataManager loadModel:self.tableViewModel];
...@@ -276,9 +264,10 @@ ...@@ -276,9 +264,10 @@
DCHECK([item isKindOfClass:[TableViewClearBrowsingDataItem class]]); DCHECK([item isKindOfClass:[TableViewClearBrowsingDataItem class]]);
TableViewClearBrowsingDataItem* clearBrowsingDataItem = TableViewClearBrowsingDataItem* clearBrowsingDataItem =
base::mac::ObjCCastStrict<TableViewClearBrowsingDataItem>(item); base::mac::ObjCCastStrict<TableViewClearBrowsingDataItem>(item);
clearBrowsingDataItem.checked = !clearBrowsingDataItem.checked;
[self reconfigureCellsForItems:@[ clearBrowsingDataItem ]]; self.browserState->GetPrefs()->SetBoolean(clearBrowsingDataItem.prefName,
[self.tableView deselectRowAtIndexPath:indexPath animated:YES]; !clearBrowsingDataItem.checked);
// UI update will be trigerred by data manager.
break; break;
} }
default: default:
...@@ -297,15 +286,22 @@ ...@@ -297,15 +286,22 @@
#pragma mark - ClearBrowsingDataConsumer #pragma mark - ClearBrowsingDataConsumer
- (void)updateCellsForItem:(ListItem*)item { - (void)updateCellsForItem:(TableViewItem*)item reload:(BOOL)reload {
if (self.suppressTableViewUpdates) if (self.suppressTableViewUpdates)
return; return;
// Reload the item instead of reconfiguring it. This might update if (!reload) {
// TableViewTextLinkItems which which can have different number of lines, [self reconfigureCellsForItems:@[ item ]];
// thus the cell height needs to adapt accordingly. NSIndexPath* indexPath = [self.tableViewModel
[self reloadCellsForItems:@[ item ] indexPathForItem:static_cast<TableViewItem*>(item)];
withRowAnimation:UITableViewRowAnimationAutomatic]; [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 - (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