| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 return l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_CALCULATING); | 69 return l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_CALCULATING); |
| 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 bool is_basic_tab = pref_name == browsing_data::prefs::kDeleteCacheBasic; |
| 79 | 80 |
| 80 // Three cases: Nonzero result for the entire cache, nonzero result for | 81 // 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 // a subset of cache (i.e. a finite time interval), and almost zero (< 1MB). |
| 82 static const int kBytesInAMegabyte = 1024 * 1024; | 83 static const int kBytesInAMegabyte = 1024 * 1024; |
| 83 base::string16 size_string; | 84 base::string16 size_string; |
| 84 if (cache_size_bytes >= kBytesInAMegabyte) { | 85 if (cache_size_bytes >= kBytesInAMegabyte) { |
| 85 base::string16 formatted_size = FormatBytesMBOrHigher(cache_size_bytes); | 86 base::string16 formatted_size = FormatBytesMBOrHigher(cache_size_bytes); |
| 86 size_string = !is_upper_limit ? formatted_size | 87 size_string = !is_upper_limit ? formatted_size |
| 87 : l10n_util::GetStringFUTF16( | 88 : l10n_util::GetStringFUTF16( |
| 88 IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, | 89 IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, |
| 89 formatted_size); | 90 formatted_size); |
| 90 } else { | 91 } else { |
| 91 size_string = | 92 size_string = l10n_util::GetStringUTF16( |
| 92 l10n_util::GetStringUTF16(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY); | 93 is_basic_tab ? IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY_BASIC |
| 94 : IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY); |
| 93 } | 95 } |
| 94 if (pref_name == browsing_data::prefs::kDeleteCacheBasic) { | 96 if (is_basic_tab) { |
| 97 // Wrap the size string inside a sentence. |
| 95 return l10n_util::GetStringFUTF16(IDS_DEL_CACHE_COUNTER_BASIC, | 98 return l10n_util::GetStringFUTF16(IDS_DEL_CACHE_COUNTER_BASIC, |
| 96 size_string); | 99 size_string); |
| 97 } | 100 } |
| 98 return size_string; | 101 return size_string; |
| 99 } | 102 } |
| 100 if (pref_name == browsing_data::prefs::kDeleteCookiesBasic) { | 103 if (pref_name == browsing_data::prefs::kDeleteCookiesBasic) { |
| 101 // The basic tab doesn't show cookie counter results. | 104 // The basic tab doesn't show cookie counter results. |
| 102 NOTREACHED(); | 105 NOTREACHED(); |
| 103 } | 106 } |
| 104 if (pref_name == browsing_data::prefs::kDeleteCookies) { | 107 if (pref_name == browsing_data::prefs::kDeleteCookies) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 return base::ReplaceStringPlaceholders( | 159 return base::ReplaceStringPlaceholders( |
| 157 l10n_util::GetPluralStringFUTF16( | 160 l10n_util::GetPluralStringFUTF16( |
| 158 IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count), | 161 IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count), |
| 159 replacements, | 162 replacements, |
| 160 nullptr); | 163 nullptr); |
| 161 } | 164 } |
| 162 #endif | 165 #endif |
| 163 | 166 |
| 164 return browsing_data::GetCounterTextFromResult(result); | 167 return browsing_data::GetCounterTextFromResult(result); |
| 165 } | 168 } |
| OLD | NEW |