| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 if (pref_name == browsing_data::prefs::kDeleteCache || | 72 if (pref_name == browsing_data::prefs::kDeleteCache || |
| 73 pref_name == browsing_data::prefs::kDeleteCacheBasic) { | 73 pref_name == browsing_data::prefs::kDeleteCacheBasic) { |
| 74 // Cache counter. | 74 // Cache counter. |
| 75 const auto* cache_result = | 75 const auto* cache_result = |
| 76 static_cast<const CacheCounter::CacheResult*>(result); | 76 static_cast<const CacheCounter::CacheResult*>(result); |
| 77 int64_t cache_size_bytes = cache_result->cache_size(); | 77 int64_t cache_size_bytes = cache_result->cache_size(); |
| 78 bool is_upper_limit = cache_result->is_upper_limit(); | 78 bool is_upper_limit = cache_result->is_upper_limit(); |
| 79 | 79 |
| 80 // Three cases: Nonzero result for the entire cache, nonzero result for | |
| 81 // a subset of cache (i.e. a finite time interval), and almost zero (< 1MB). | |
| 82 static const int kBytesInAMegabyte = 1024 * 1024; | 80 static const int kBytesInAMegabyte = 1024 * 1024; |
| 83 base::string16 size_string; | 81 // Almost zero (< 1MB). |
| 84 if (cache_size_bytes >= kBytesInAMegabyte) { | 82 if (cache_size_bytes < kBytesInAMegabyte) { |
| 85 base::string16 formatted_size = FormatBytesMBOrHigher(cache_size_bytes); | 83 return l10n_util::GetStringUTF16(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY); |
| 86 size_string = !is_upper_limit ? formatted_size | |
| 87 : l10n_util::GetStringFUTF16( | |
| 88 IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, | |
| 89 formatted_size); | |
| 90 } else { | |
| 91 size_string = | |
| 92 l10n_util::GetStringUTF16(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY); | |
| 93 } | 84 } |
| 85 // Nonzero result for the entire cache or nonzero result for |
| 86 // a subset of cache (i.e. a finite time interval). |
| 87 base::string16 formatted_size = FormatBytesMBOrHigher(cache_size_bytes); |
| 88 base::string16 size_string = |
| 89 !is_upper_limit |
| 90 ? formatted_size |
| 91 : l10n_util::GetStringFUTF16(IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, |
| 92 formatted_size); |
| 93 // For the basic tab, wrap the size in a sentence. |
| 94 if (pref_name == browsing_data::prefs::kDeleteCacheBasic) { | 94 if (pref_name == browsing_data::prefs::kDeleteCacheBasic) { |
| 95 return l10n_util::GetStringFUTF16(IDS_DEL_CACHE_COUNTER_BASIC, | 95 return l10n_util::GetStringFUTF16(IDS_DEL_CACHE_COUNTER_BASIC, |
| 96 size_string); | 96 size_string); |
| 97 } | 97 } |
| 98 return size_string; | 98 return size_string; |
| 99 } | 99 } |
| 100 if (pref_name == browsing_data::prefs::kDeleteCookiesBasic) { | 100 if (pref_name == browsing_data::prefs::kDeleteCookiesBasic) { |
| 101 // The basic tab doesn't show cookie counter results. | 101 // The basic tab doesn't show cookie counter results. |
| 102 NOTREACHED(); | 102 NOTREACHED(); |
| 103 } | 103 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 return base::ReplaceStringPlaceholders( | 156 return base::ReplaceStringPlaceholders( |
| 157 l10n_util::GetPluralStringFUTF16( | 157 l10n_util::GetPluralStringFUTF16( |
| 158 IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count), | 158 IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count), |
| 159 replacements, | 159 replacements, |
| 160 nullptr); | 160 nullptr); |
| 161 } | 161 } |
| 162 #endif | 162 #endif |
| 163 | 163 |
| 164 return browsing_data::GetCounterTextFromResult(result); | 164 return browsing_data::GetCounterTextFromResult(result); |
| 165 } | 165 } |
| OLD | NEW |