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" |
11 #include "chrome/browser/browsing_data/media_licenses_counter.h" | 11 #include "chrome/browser/browsing_data/media_licenses_counter.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/chrome_features.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
15 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
16 #include "components/browsing_data/core/pref_names.h" | 17 #include "components/browsing_data/core/pref_names.h" |
17 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
18 #include "components/strings/grit/components_strings.h" | 19 #include "components/strings/grit/components_strings.h" |
19 #include "extensions/features/features.h" | 20 #include "extensions/features/features.h" |
20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/text/bytes_formatting.h" | 22 #include "ui/base/text/bytes_formatting.h" |
22 | 23 |
23 #if BUILDFLAG(ENABLE_EXTENSIONS) | 24 #if BUILDFLAG(ENABLE_EXTENSIONS) |
24 #include "base/numerics/safe_conversions.h" | 25 #include "base/numerics/safe_conversions.h" |
25 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
26 #include "chrome/browser/browsing_data/hosted_apps_counter.h" | 27 #include "chrome/browser/browsing_data/hosted_apps_counter.h" |
27 #endif | 28 #endif |
28 | 29 |
29 #if defined(OS_ANDROID) | |
30 #include "chrome/browser/android/chrome_feature_list.h" | |
31 #endif | |
32 | 30 |
33 bool AreCountersEnabled() { | 31 bool AreCountersEnabled() { |
34 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 32 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
35 switches::kEnableClearBrowsingDataCounters)) { | 33 switches::kEnableClearBrowsingDataCounters)) { |
36 return true; | 34 return true; |
37 } | 35 } |
38 | 36 |
39 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 37 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
40 switches::kDisableClearBrowsingDataCounters)) { | 38 switches::kDisableClearBrowsingDataCounters)) { |
41 return false; | 39 return false; |
42 } | 40 } |
43 | 41 |
44 // Enabled by default. | 42 // Enabled by default. |
45 return true; | 43 return true; |
46 } | 44 } |
47 | 45 |
48 bool IsSiteDataCounterEnabled() { | 46 bool IsSiteDataCounterEnabled() { |
49 #if defined(OS_ANDROID) | |
50 // Only use the site data counter for the new CBD ui. | 47 // Only use the site data counter for the new CBD ui. |
51 return base::FeatureList::IsEnabled(chrome::android::kTabsInCBD); | 48 return base::FeatureList::IsEnabled(features::kTabsInCbd); |
52 #else | |
53 // Don't use the counter on other platforms that don't yet have the new ui. | |
54 return false; | |
55 #endif | |
56 } | 49 } |
57 | 50 |
58 // A helper function to display the size of cache in units of MB or higher. | 51 // A helper function to display the size of cache in units of MB or higher. |
59 // We need this, as 1 MB is the lowest nonzero cache size displayed by the | 52 // We need this, as 1 MB is the lowest nonzero cache size displayed by the |
60 // counter. | 53 // counter. |
61 base::string16 FormatBytesMBOrHigher( | 54 base::string16 FormatBytesMBOrHigher( |
62 browsing_data::BrowsingDataCounter::ResultInt bytes) { | 55 browsing_data::BrowsingDataCounter::ResultInt bytes) { |
63 if (ui::GetByteDisplayUnits(bytes) >= ui::DataUnits::DATA_UNITS_MEBIBYTE) | 56 if (ui::GetByteDisplayUnits(bytes) >= ui::DataUnits::DATA_UNITS_MEBIBYTE) |
64 return ui::FormatBytes(bytes); | 57 return ui::FormatBytes(bytes); |
65 | 58 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return base::ReplaceStringPlaceholders( | 156 return base::ReplaceStringPlaceholders( |
164 l10n_util::GetPluralStringFUTF16( | 157 l10n_util::GetPluralStringFUTF16( |
165 IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count), | 158 IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count), |
166 replacements, | 159 replacements, |
167 nullptr); | 160 nullptr); |
168 } | 161 } |
169 #endif | 162 #endif |
170 | 163 |
171 return browsing_data::GetCounterTextFromResult(result); | 164 return browsing_data::GetCounterTextFromResult(result); |
172 } | 165 } |
OLD | NEW |