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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_counter_utils.cc

Issue 2935443003: Properly construct 'less than' sentences (Closed)
Patch Set: fix string description Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_counter_utils_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool is_basic_tab = pref_name == browsing_data::prefs::kDeleteCacheBasic;
80 80
81 // Three cases: Nonzero result for the entire cache, nonzero result for 81 // Three cases: Nonzero result for the entire cache, nonzero result for
82 // 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).
83 static const int kBytesInAMegabyte = 1024 * 1024; 83 static const int kBytesInAMegabyte = 1024 * 1024;
84 base::string16 size_string;
85 if (cache_size_bytes >= kBytesInAMegabyte) { 84 if (cache_size_bytes >= kBytesInAMegabyte) {
86 base::string16 formatted_size = FormatBytesMBOrHigher(cache_size_bytes); 85 base::string16 formatted_size = FormatBytesMBOrHigher(cache_size_bytes);
87 size_string = !is_upper_limit ? formatted_size 86 if (!is_upper_limit) {
88 : l10n_util::GetStringFUTF16( 87 return is_basic_tab ? l10n_util::GetStringFUTF16(
89 IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, 88 IDS_DEL_CACHE_COUNTER_BASIC, formatted_size)
90 formatted_size); 89 : formatted_size;
91 } else { 90 }
92 size_string = l10n_util::GetStringUTF16( 91 return l10n_util::GetStringFUTF16(
93 is_basic_tab ? IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY_BASIC 92 is_basic_tab ? IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE_BASIC
94 : IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY); 93 : IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE,
94 formatted_size);
95 } 95 }
96 if (is_basic_tab) { 96 return l10n_util::GetStringUTF16(
97 // Wrap the size string inside a sentence. 97 is_basic_tab ? IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY_BASIC
98 return l10n_util::GetStringFUTF16(IDS_DEL_CACHE_COUNTER_BASIC, 98 : IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY);
99 size_string);
100 }
101 return size_string;
102 } 99 }
103 if (pref_name == browsing_data::prefs::kDeleteCookiesBasic) { 100 if (pref_name == browsing_data::prefs::kDeleteCookiesBasic) {
104 // The basic tab doesn't show cookie counter results. 101 // The basic tab doesn't show cookie counter results.
105 NOTREACHED(); 102 NOTREACHED();
106 } 103 }
107 if (pref_name == browsing_data::prefs::kDeleteCookies) { 104 if (pref_name == browsing_data::prefs::kDeleteCookies) {
108 // Site data counter. 105 // Site data counter.
109 DCHECK(IsSiteDataCounterEnabled()); 106 DCHECK(IsSiteDataCounterEnabled());
110 browsing_data::BrowsingDataCounter::ResultInt origins = 107 browsing_data::BrowsingDataCounter::ResultInt origins =
111 static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>( 108 static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return base::ReplaceStringPlaceholders( 156 return base::ReplaceStringPlaceholders(
160 l10n_util::GetPluralStringFUTF16( 157 l10n_util::GetPluralStringFUTF16(
161 IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count), 158 IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count),
162 replacements, 159 replacements,
163 nullptr); 160 nullptr);
164 } 161 }
165 #endif 162 #endif
166 163
167 return browsing_data::GetCounterTextFromResult(result); 164 return browsing_data::GetCounterTextFromResult(result);
168 } 165 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_counter_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698