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/ui/webui/settings/settings_clear_browsing_data_handler. h" | 5 #include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler. h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
13 #include "chrome/browser/browsing_data/autofill_counter.h" | 13 #include "chrome/browser/browsing_data/autofill_counter.h" |
14 #include "chrome/browser/browsing_data/browsing_data_counter_factory.h" | |
14 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 15 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
15 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 17 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
17 #include "chrome/browser/browsing_data/cache_counter.h" | 18 #include "chrome/browser/browsing_data/cache_counter.h" |
msramek
2016/07/07 11:55:33
None of the .*counter\.h includes is needed anymor
ioanap
2016/07/07 16:30:48
Done.
| |
18 #include "chrome/browser/browsing_data/downloads_counter.h" | 19 #include "chrome/browser/browsing_data/downloads_counter.h" |
19 #include "chrome/browser/browsing_data/history_counter.h" | 20 #include "chrome/browser/browsing_data/history_counter.h" |
20 #include "chrome/browser/browsing_data/hosted_apps_counter.h" | 21 #include "chrome/browser/browsing_data/hosted_apps_counter.h" |
21 #include "chrome/browser/browsing_data/media_licenses_counter.h" | 22 #include "chrome/browser/browsing_data/media_licenses_counter.h" |
22 #include "chrome/browser/browsing_data/passwords_counter.h" | 23 #include "chrome/browser/browsing_data/passwords_counter.h" |
23 #include "chrome/browser/history/web_history_service_factory.h" | 24 #include "chrome/browser/history/web_history_service_factory.h" |
24 #include "chrome/browser/sync/profile_sync_service_factory.h" | 25 #include "chrome/browser/sync/profile_sync_service_factory.h" |
25 #include "chrome/common/channel_info.h" | 26 #include "chrome/common/channel_info.h" |
26 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
27 #include "components/browsing_data/pref_names.h" | 28 #include "components/browsing_data/pref_names.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 "cr.webUIListenerCallback", | 209 "cr.webUIListenerCallback", |
209 base::StringValue("browsing-history-pref-changed"), | 210 base::StringValue("browsing-history-pref-changed"), |
210 base::FundamentalValue( | 211 base::FundamentalValue( |
211 profile_->GetPrefs()->GetBoolean( | 212 profile_->GetPrefs()->GetBoolean( |
212 prefs::kAllowDeletingBrowserHistory))); | 213 prefs::kAllowDeletingBrowserHistory))); |
213 } | 214 } |
214 | 215 |
215 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) { | 216 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) { |
216 AllowJavascript(); | 217 AllowJavascript(); |
217 | 218 |
218 // TODO(msramek): Simplify this using a factory. | 219 // TODO(msramek): Simplify this using a factory. |
msramek
2016/07/07 11:55:33
We're already using a factory, but (apart from rem
ioanap
2016/07/07 16:30:48
Thank you!
Done.
| |
219 AddCounter(base::WrapUnique(new AutofillCounter(profile_))); | 220 AddCounter(base::WrapUnique(BrowsingDataCounterFactory::GetForPreference( |
220 AddCounter(base::WrapUnique(new CacheCounter(profile_))); | 221 prefs::kDeleteFormData, profile_))); |
221 AddCounter(base::WrapUnique(new DownloadsCounter(profile_))); | 222 AddCounter(base::WrapUnique(BrowsingDataCounterFactory::GetForPreference( |
222 AddCounter(base::WrapUnique(new HistoryCounter(profile_))); | 223 prefs::kDeleteCache, profile_))); |
223 AddCounter(base::WrapUnique(new HostedAppsCounter(profile_))); | 224 AddCounter(base::WrapUnique(BrowsingDataCounterFactory::GetForPreference( |
224 AddCounter(base::WrapUnique(new PasswordsCounter(profile_))); | 225 prefs::kDeleteDownloadHistory, profile_))); |
225 AddCounter(base::WrapUnique(new MediaLicensesCounter(profile_))); | 226 AddCounter(base::WrapUnique(BrowsingDataCounterFactory::GetForPreference( |
227 prefs::kDeleteBrowsingHistory, profile_))); | |
228 AddCounter(base::WrapUnique(BrowsingDataCounterFactory::GetForPreference( | |
229 prefs::kDeleteHostedAppsData, profile_))); | |
230 AddCounter(base::WrapUnique(BrowsingDataCounterFactory::GetForPreference( | |
231 prefs::kDeletePasswords, profile_))); | |
232 AddCounter(base::WrapUnique(BrowsingDataCounterFactory::GetForPreference( | |
233 prefs::kDeleteMediaLicenses, profile_))); | |
226 | 234 |
227 OnStateChanged(); | 235 OnStateChanged(); |
228 RefreshHistoryNotice(); | 236 RefreshHistoryNotice(); |
229 } | 237 } |
230 | 238 |
231 void ClearBrowsingDataHandler::OnStateChanged() { | 239 void ClearBrowsingDataHandler::OnStateChanged() { |
232 CallJavascriptFunction( | 240 CallJavascriptFunction( |
233 "cr.webUIListenerCallback", | 241 "cr.webUIListenerCallback", |
234 base::StringValue("update-footer"), | 242 base::StringValue("update-footer"), |
235 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), | 243 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 void ClearBrowsingDataHandler::UpdateCounterText( | 293 void ClearBrowsingDataHandler::UpdateCounterText( |
286 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { | 294 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { |
287 CallJavascriptFunction( | 295 CallJavascriptFunction( |
288 "cr.webUIListenerCallback", | 296 "cr.webUIListenerCallback", |
289 base::StringValue("update-counter-text"), | 297 base::StringValue("update-counter-text"), |
290 base::StringValue(result->source()->GetPrefName()), | 298 base::StringValue(result->source()->GetPrefName()), |
291 base::StringValue(GetCounterTextFromResult(result.get()))); | 299 base::StringValue(GetCounterTextFromResult(result.get()))); |
292 } | 300 } |
293 | 301 |
294 } // namespace settings | 302 } // namespace settings |
OLD | NEW |