[iOS] Always show data counts in CBDCollectionView

- iOS Clear Browsing Data CollectionView
- It was among the goals of the new Clear Browsing Data UI (behind the new-clear-browsing-data-ui flag) to show the browsing data counting results in each entry's detail text label, depending on the selection state of an item.
- This change carries out the current plan, which is to show data counts regardless of the selection states (still behind the flag).

Bug: 945255
Change-Id: I823a3e5da209b0e1318b4124178275599df7b48a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1536188
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: Huanzhong Huang <huanzhong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644234}
diff --git a/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_collection_view_controller.mm b/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_collection_view_controller.mm
index 1722652..c26a747 100644
--- a/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_collection_view_controller.mm
+++ b/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_collection_view_controller.mm
@@ -154,8 +154,6 @@
       scoped_observer_->Add(
           BrowsingDataRemoverFactory::GetForBrowserState(browserState));
     }
-
-    [self restartCounters:BrowsingDataRemoveMask::REMOVE_ALL];
   }
   return self;
 }
@@ -166,6 +164,11 @@
   [self loadModel];
 }
 
+- (void)viewWillAppear:(BOOL)animated {
+  [super viewWillAppear:animated];
+  [self restartCounters:BrowsingDataRemoveMask::REMOVE_ALL];
+}
+
 #pragma mark CollectionViewController
 
 - (void)loadModel {
@@ -306,17 +309,9 @@
       if (clearDataItem.accessoryType == MDCCollectionViewCellAccessoryNone) {
         clearDataItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark;
         _browserState->GetPrefs()->SetBoolean(clearDataItem.prefName, true);
-        if (itemType == ItemTypeDataTypeCookiesSiteData &&
-            IsNewClearBrowsingDataUIEnabled()) {
-          [self updateCounter:itemType
-                   detailText:l10n_util::GetNSString(IDS_DEL_COOKIES_COUNTER)];
-        }
       } else {
         clearDataItem.accessoryType = MDCCollectionViewCellAccessoryNone;
         _browserState->GetPrefs()->SetBoolean(clearDataItem.prefName, false);
-        if (IsNewClearBrowsingDataUIEnabled()) {
-          [self updateCounter:itemType detailText:@""];
-        }
       }
       [self reconfigureCellsForItems:@[ clearDataItem ]];
       break;
@@ -378,6 +373,16 @@
     [historyItem restartCounter];
   }
 
+  if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_CACHE)) {
+    NSIndexPath* indexPath = [self.collectionViewModel
+        indexPathForItemType:ItemTypeDataTypeCache
+           sectionIdentifier:SectionIdentifierDataTypes];
+    ClearBrowsingDataItem* cacheItem =
+        base::mac::ObjCCastStrict<ClearBrowsingDataItem>(
+            [model itemAtIndexPath:indexPath]);
+    [cacheItem restartCounter];
+  }
+
   if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_PASSWORDS)) {
     NSIndexPath* indexPath = [self.collectionViewModel
         indexPathForItemType:ItemTypeDataTypeSavedPasswords
diff --git a/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_manager.mm b/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_manager.mm
index 96a0c0a..57bc0ee 100644
--- a/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_manager.mm
+++ b/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_manager.mm
@@ -385,8 +385,7 @@
     // Because there is no counter for cookies, an explanatory text is
     // displayed.
     if (itemType == ItemTypeDataTypeCookiesSiteData &&
-        IsNewClearBrowsingDataUIEnabled() &&
-        prefs->GetBoolean(browsing_data::prefs::kDeleteCookies)) {
+        IsNewClearBrowsingDataUIEnabled()) {
       collectionClearDataItem.detailText =
           l10n_util::GetNSString(IDS_DEL_COOKIES_COUNTER);
     }