| OLD | NEW |
| 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 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 5 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browsing_data/cache_counter.h" | 10 #include "chrome/browser/browsing_data/cache_counter.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 pref_name == browsing_data::prefs::kDeleteCacheBasic) { | 80 pref_name == browsing_data::prefs::kDeleteCacheBasic) { |
| 81 // Cache counter. | 81 // Cache counter. |
| 82 const auto* cache_result = | 82 const auto* cache_result = |
| 83 static_cast<const CacheCounter::CacheResult*>(result); | 83 static_cast<const CacheCounter::CacheResult*>(result); |
| 84 int64_t cache_size_bytes = cache_result->cache_size(); | 84 int64_t cache_size_bytes = cache_result->cache_size(); |
| 85 bool is_upper_limit = cache_result->is_upper_limit(); | 85 bool is_upper_limit = cache_result->is_upper_limit(); |
| 86 | 86 |
| 87 // Three cases: Nonzero result for the entire cache, nonzero result for | 87 // Three cases: Nonzero result for the entire cache, nonzero result for |
| 88 // a subset of cache (i.e. a finite time interval), and almost zero (< 1MB). | 88 // a subset of cache (i.e. a finite time interval), and almost zero (< 1MB). |
| 89 static const int kBytesInAMegabyte = 1024 * 1024; | 89 static const int kBytesInAMegabyte = 1024 * 1024; |
| 90 base::string16 size_string; |
| 90 if (cache_size_bytes >= kBytesInAMegabyte) { | 91 if (cache_size_bytes >= kBytesInAMegabyte) { |
| 91 base::string16 formatted_size = FormatBytesMBOrHigher(cache_size_bytes); | 92 base::string16 formatted_size = FormatBytesMBOrHigher(cache_size_bytes); |
| 92 return !is_upper_limit | 93 size_string = !is_upper_limit ? formatted_size |
| 93 ? formatted_size | 94 : l10n_util::GetStringFUTF16( |
| 94 : l10n_util::GetStringFUTF16( | 95 IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, |
| 95 IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, formatted_size); | 96 formatted_size); |
| 97 } else { |
| 98 size_string = |
| 99 l10n_util::GetStringUTF16(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY); |
| 96 } | 100 } |
| 97 return l10n_util::GetStringUTF16(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY); | 101 if (pref_name == browsing_data::prefs::kDeleteCacheBasic) { |
| 102 return l10n_util::GetStringFUTF16(IDS_DEL_CACHE_COUNTER_BASIC, |
| 103 size_string); |
| 104 } |
| 105 return size_string; |
| 98 } | 106 } |
| 99 | 107 if (pref_name == browsing_data::prefs::kDeleteCookiesBasic) { |
| 108 // The basic tab doesn't show cookie counter results. |
| 109 NOTREACHED(); |
| 110 } |
| 100 if (pref_name == browsing_data::prefs::kDeleteCookies) { | 111 if (pref_name == browsing_data::prefs::kDeleteCookies) { |
| 101 // Site data counter. | 112 // Site data counter. |
| 102 DCHECK(IsSiteDataCounterEnabled()); | 113 DCHECK(IsSiteDataCounterEnabled()); |
| 103 browsing_data::BrowsingDataCounter::ResultInt origins = | 114 browsing_data::BrowsingDataCounter::ResultInt origins = |
| 104 static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>( | 115 static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>( |
| 105 result) | 116 result) |
| 106 ->Value(); | 117 ->Value(); |
| 107 return l10n_util::GetPluralStringFUTF16(IDS_DEL_COOKIES_COUNTER_ADVANCED, | 118 return l10n_util::GetPluralStringFUTF16(IDS_DEL_COOKIES_COUNTER_ADVANCED, |
| 108 origins); | 119 origins); |
| 109 } | 120 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return base::ReplaceStringPlaceholders( | 163 return base::ReplaceStringPlaceholders( |
| 153 l10n_util::GetPluralStringFUTF16( | 164 l10n_util::GetPluralStringFUTF16( |
| 154 IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count), | 165 IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count), |
| 155 replacements, | 166 replacements, |
| 156 nullptr); | 167 nullptr); |
| 157 } | 168 } |
| 158 #endif | 169 #endif |
| 159 | 170 |
| 160 return browsing_data::GetCounterTextFromResult(result); | 171 return browsing_data::GetCounterTextFromResult(result); |
| 161 } | 172 } |
| OLD | NEW |