OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/options/clear_browser_data_handler.h" | 5 #include "chrome/browser/ui/webui/options/clear_browser_data_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
17 #include "base/metrics/sparse_histogram.h" | 17 #include "base/metrics/sparse_histogram.h" |
18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "chrome/app/chrome_command_ids.h" | 22 #include "chrome/app/chrome_command_ids.h" |
23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/browsing_data/autofill_counter.h" | 24 #include "chrome/browser/browsing_data/browsing_data_counter_factory.h" |
25 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 25 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
26 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 26 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
27 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 27 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
28 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 28 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
29 #include "chrome/browser/browsing_data/cache_counter.h" | |
30 #include "chrome/browser/browsing_data/history_counter.h" | |
31 #include "chrome/browser/browsing_data/media_licenses_counter.h" | |
32 #include "chrome/browser/browsing_data/passwords_counter.h" | |
33 #include "chrome/browser/history/web_history_service_factory.h" | 29 #include "chrome/browser/history/web_history_service_factory.h" |
34 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 30 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
35 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
36 #include "chrome/browser/sync/profile_sync_service_factory.h" | 32 #include "chrome/browser/sync/profile_sync_service_factory.h" |
37 #include "chrome/browser/ui/accelerator_utils.h" | 33 #include "chrome/browser/ui/accelerator_utils.h" |
38 #include "chrome/common/channel_info.h" | 34 #include "chrome/common/channel_info.h" |
39 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
40 #include "chrome/grit/generated_resources.h" | 36 #include "chrome/grit/generated_resources.h" |
41 #include "chrome/grit/locale_settings.h" | 37 #include "chrome/grit/locale_settings.h" |
42 #include "components/browsing_data/counters/browsing_data_counter.h" | 38 #include "components/browsing_data/counters/browsing_data_counter.h" |
(...skipping 13 matching lines...) Expand all Loading... |
56 "https://support.google.com/chrome/?p=settings_clear_browsing_data"; | 52 "https://support.google.com/chrome/?p=settings_clear_browsing_data"; |
57 | 53 |
58 const char kMyActivityUrlInFooter[] = | 54 const char kMyActivityUrlInFooter[] = |
59 "https://history.google.com/history/?utm_source=chrome_cbd"; | 55 "https://history.google.com/history/?utm_source=chrome_cbd"; |
60 | 56 |
61 const char kMyActivityUrlInDialog[] = | 57 const char kMyActivityUrlInDialog[] = |
62 "https://history.google.com/history/?utm_source=chrome_n"; | 58 "https://history.google.com/history/?utm_source=chrome_n"; |
63 | 59 |
64 const int kMaxTimesHistoryNoticeShown = 1; | 60 const int kMaxTimesHistoryNoticeShown = 1; |
65 | 61 |
| 62 const char* kCounterPrefs[] = { |
| 63 prefs::kDeleteBrowsingHistory, |
| 64 prefs::kDeleteCache, |
| 65 prefs::kDeleteFormData, |
| 66 prefs::kDeleteMediaLicenses, |
| 67 prefs::kDeletePasswords, |
| 68 }; |
| 69 |
66 } // namespace | 70 } // namespace |
67 | 71 |
68 namespace options { | 72 namespace options { |
69 | 73 |
70 ClearBrowserDataHandler::ClearBrowserDataHandler() | 74 ClearBrowserDataHandler::ClearBrowserDataHandler() |
71 : remover_(nullptr), | 75 : remover_(nullptr), |
72 sync_service_(nullptr), | 76 sync_service_(nullptr), |
73 should_show_history_notice_(false), | 77 should_show_history_notice_(false), |
74 should_show_history_deletion_dialog_(false), | 78 should_show_history_deletion_dialog_(false), |
75 weak_ptr_factory_(this) { | 79 weak_ptr_factory_(this) { |
(...skipping 10 matching lines...) Expand all Loading... |
86 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 90 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
87 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, prefs); | 91 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, prefs); |
88 allow_deleting_browser_history_.Init( | 92 allow_deleting_browser_history_.Init( |
89 prefs::kAllowDeletingBrowserHistory, | 93 prefs::kAllowDeletingBrowserHistory, |
90 prefs, | 94 prefs, |
91 base::Bind(&ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged, | 95 base::Bind(&ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged, |
92 base::Unretained(this))); | 96 base::Unretained(this))); |
93 | 97 |
94 if (AreCountersEnabled()) { | 98 if (AreCountersEnabled()) { |
95 Profile* profile = Profile::FromWebUI(web_ui()); | 99 Profile* profile = Profile::FromWebUI(web_ui()); |
96 AddCounter(base::WrapUnique(new PasswordsCounter(profile))); | 100 for (const std::string& pref : kCounterPrefs) { |
97 AddCounter(base::WrapUnique(new HistoryCounter(profile))); | 101 AddCounter( |
98 AddCounter(base::WrapUnique(new CacheCounter(profile))); | 102 BrowsingDataCounterFactory::GetForProfileAndPref(profile, pref)); |
99 AddCounter(base::WrapUnique(new AutofillCounter(profile))); | 103 } |
100 AddCounter(base::WrapUnique(new MediaLicensesCounter(profile))); | |
101 | 104 |
102 sync_service_ = ProfileSyncServiceFactory::GetForProfile(profile); | 105 sync_service_ = ProfileSyncServiceFactory::GetForProfile(profile); |
103 if (sync_service_) | 106 if (sync_service_) |
104 sync_service_->AddObserver(this); | 107 sync_service_->AddObserver(this); |
105 } | 108 } |
106 } | 109 } |
107 | 110 |
108 void ClearBrowserDataHandler::InitializePage() { | 111 void ClearBrowserDataHandler::InitializePage() { |
109 web_ui()->CallJavascriptFunctionUnsafe( | 112 web_ui()->CallJavascriptFunctionUnsafe( |
110 "ClearBrowserDataOverlay.createFooter", | 113 "ClearBrowserDataOverlay.createFooter", |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", | 423 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", |
421 should_show_history_notice_); | 424 should_show_history_notice_); |
422 } | 425 } |
423 | 426 |
424 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) { | 427 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) { |
425 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes). | 428 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes). |
426 should_show_history_deletion_dialog_ = show; | 429 should_show_history_deletion_dialog_ = show; |
427 } | 430 } |
428 | 431 |
429 } // namespace options | 432 } // namespace options |
OLD | NEW |