Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_controller.mm

Issue 2671743002: Separate state of basic and advanced tab in CBD dialog (Closed)
Patch Set: rebase and fix compilation Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_cont roller.h" 5 #import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_cont roller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/ios/ios_util.h" 10 #include "base/ios/ios_util.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 DCHECK(browserState); 185 DCHECK(browserState);
186 self = [super initWithStyle:CollectionViewControllerStyleAppBar]; 186 self = [super initWithStyle:CollectionViewControllerStyleAppBar];
187 if (self) { 187 if (self) {
188 self.accessibilityTraits |= UIAccessibilityTraitButton; 188 self.accessibilityTraits |= UIAccessibilityTraitButton;
189 189
190 _browserState = browserState; 190 _browserState = browserState;
191 if (experimental_flags::IsNewClearBrowsingDataUIEnabled()) { 191 if (experimental_flags::IsNewClearBrowsingDataUIEnabled()) {
192 int prefValue = browserState->GetPrefs()->GetInteger( 192 int prefValue = browserState->GetPrefs()->GetInteger(
193 browsing_data::prefs::kDeleteTimePeriod); 193 browsing_data::prefs::kDeleteTimePeriod);
194 prefValue = MAX(0, prefValue); 194 prefValue = MAX(0, prefValue);
195 if (prefValue > browsing_data::TIME_PERIOD_LAST) { 195 const int maxValue =
196 prefValue = browsing_data::TIME_PERIOD_LAST; 196 static_cast<int>(browsing_data::TimePeriod::TIME_PERIOD_LAST);
197 if (prefValue > maxValue) {
198 prefValue = maxValue;
197 } 199 }
198 _timePeriod = static_cast<browsing_data::TimePeriod>(prefValue); 200 _timePeriod = static_cast<browsing_data::TimePeriod>(prefValue);
199 } else { 201 } else {
200 _timePeriod = browsing_data::ALL_TIME; 202 _timePeriod = browsing_data::TimePeriod::ALL_TIME;
201 } 203 }
202 204
203 self.title = l10n_util::GetNSString(IDS_IOS_CLEAR_BROWSING_DATA_TITLE); 205 self.title = l10n_util::GetNSString(IDS_IOS_CLEAR_BROWSING_DATA_TITLE);
204 self.collectionViewAccessibilityIdentifier = 206 self.collectionViewAccessibilityIdentifier =
205 kClearBrowsingDataCollectionViewId; 207 kClearBrowsingDataCollectionViewId;
206 208
207 if (experimental_flags::IsNewClearBrowsingDataUIEnabled()) { 209 if (experimental_flags::IsNewClearBrowsingDataUIEnabled()) {
208 base::WeakNSObject<ClearBrowsingDataCollectionViewController> weakSelf( 210 base::WeakNSObject<ClearBrowsingDataCollectionViewController> weakSelf(
209 self); 211 self);
210 void (^dataClearedCallback)( 212 void (^dataClearedCallback)(
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 // Because of this, the lowest unit that can be used is MB. 798 // Because of this, the lowest unit that can be used is MB.
797 static const int kBytesInAMegabyte = 1 << 20; 799 static const int kBytesInAMegabyte = 1 << 20;
798 if (cacheSizeBytes >= kBytesInAMegabyte) { 800 if (cacheSizeBytes >= kBytesInAMegabyte) {
799 base::scoped_nsobject<NSByteCountFormatter> formatter( 801 base::scoped_nsobject<NSByteCountFormatter> formatter(
800 [[NSByteCountFormatter alloc] init]); 802 [[NSByteCountFormatter alloc] init]);
801 formatter.get().allowedUnits = NSByteCountFormatterUseAll & 803 formatter.get().allowedUnits = NSByteCountFormatterUseAll &
802 (~NSByteCountFormatterUseBytes) & 804 (~NSByteCountFormatterUseBytes) &
803 (~NSByteCountFormatterUseKB); 805 (~NSByteCountFormatterUseKB);
804 formatter.get().countStyle = NSByteCountFormatterCountStyleMemory; 806 formatter.get().countStyle = NSByteCountFormatterCountStyleMemory;
805 NSString* formattedSize = [formatter stringFromByteCount:cacheSizeBytes]; 807 NSString* formattedSize = [formatter stringFromByteCount:cacheSizeBytes];
806 return (_timePeriod == browsing_data::ALL_TIME) 808 return (_timePeriod == browsing_data::TimePeriod::ALL_TIME)
807 ? formattedSize 809 ? formattedSize
808 : l10n_util::GetNSStringF( 810 : l10n_util::GetNSStringF(
809 IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, 811 IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE,
810 base::SysNSStringToUTF16(formattedSize)); 812 base::SysNSStringToUTF16(formattedSize));
811 } 813 }
812 return l10n_util::GetNSString(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY); 814 return l10n_util::GetNSString(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY);
813 } 815 }
814 return base::SysUTF16ToNSString( 816 return base::SysUTF16ToNSString(
815 browsing_data::GetCounterTextFromResult(&result)); 817 browsing_data::GetCounterTextFromResult(&result));
816 } 818 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 893
892 #pragma mark TimeRangeSelectorCollectionViewControllerDelegate 894 #pragma mark TimeRangeSelectorCollectionViewControllerDelegate
893 895
894 - (void)timeRangeSelectorViewController: 896 - (void)timeRangeSelectorViewController:
895 (TimeRangeSelectorCollectionViewController*)collectionViewController 897 (TimeRangeSelectorCollectionViewController*)collectionViewController
896 didSelectTimePeriod:(browsing_data::TimePeriod)timePeriod { 898 didSelectTimePeriod:(browsing_data::TimePeriod)timePeriod {
897 _timePeriod = timePeriod; 899 _timePeriod = timePeriod;
898 } 900 }
899 901
900 @end 902 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698