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/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
12 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 12 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
13 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 13 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
14 #include "chrome/browser/history/web_history_service_factory.h" | 14 #include "chrome/browser/history/web_history_service_factory.h" |
15 #include "chrome/browser/sync/profile_sync_service_factory.h" | 15 #include "chrome/browser/sync/profile_sync_service_factory.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "components/browsing_data/pref_names.h" |
17 #include "components/browsing_data_ui/history_notice_utils.h" | 18 #include "components/browsing_data_ui/history_notice_utils.h" |
18 #include "components/prefs/pref_service.h" | 19 #include "components/prefs/pref_service.h" |
19 #include "content/public/browser/web_ui.h" | 20 #include "content/public/browser/web_ui.h" |
20 | 21 |
21 namespace settings { | 22 namespace settings { |
22 | 23 |
23 ClearBrowsingDataHandler::ClearBrowsingDataHandler(content::WebUI* webui) | 24 ClearBrowsingDataHandler::ClearBrowsingDataHandler(content::WebUI* webui) |
24 : sync_service_(nullptr), | 25 : sync_service_(nullptr), |
25 sync_service_observer_(this), | 26 sync_service_observer_(this), |
26 remover_(nullptr), | 27 remover_(nullptr), |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 }; | 143 }; |
143 static size_t num_other_types = arraysize(other_types); | 144 static size_t num_other_types = arraysize(other_types); |
144 int checked_other_types = std::count_if( | 145 int checked_other_types = std::count_if( |
145 other_types, other_types + num_other_types, | 146 other_types, other_types + num_other_types, |
146 [prefs](const std::string& pref) { return prefs->GetBoolean(pref); }); | 147 [prefs](const std::string& pref) { return prefs->GetBoolean(pref); }); |
147 UMA_HISTOGRAM_SPARSE_SLOWLY( | 148 UMA_HISTOGRAM_SPARSE_SLOWLY( |
148 "History.ClearBrowsingData.PasswordsDeletion.AdditionalDatatypesCount", | 149 "History.ClearBrowsingData.PasswordsDeletion.AdditionalDatatypesCount", |
149 checked_other_types); | 150 checked_other_types); |
150 } | 151 } |
151 | 152 |
152 int period_selected = prefs->GetInteger(prefs::kDeleteTimePeriod); | 153 int period_selected = |
| 154 prefs->GetInteger(browsing_data::prefs::kDeleteTimePeriod); |
153 remover_ = BrowsingDataRemoverFactory::GetForBrowserContext(profile); | 155 remover_ = BrowsingDataRemoverFactory::GetForBrowserContext(profile); |
154 remover_->AddObserver(this); | 156 remover_->AddObserver(this); |
155 remover_->Remove( | 157 remover_->Remove(BrowsingDataRemover::Period( |
156 BrowsingDataRemover::Period( | 158 static_cast<browsing_data::TimePeriod>(period_selected)), |
157 static_cast<BrowsingDataRemover::TimePeriod>(period_selected)), | 159 remove_mask, origin_mask); |
158 remove_mask, origin_mask); | |
159 } | 160 } |
160 | 161 |
161 void ClearBrowsingDataHandler::OnBrowsingDataRemoverDone() { | 162 void ClearBrowsingDataHandler::OnBrowsingDataRemoverDone() { |
162 remover_->RemoveObserver(this); | 163 remover_->RemoveObserver(this); |
163 remover_ = nullptr; | 164 remover_ = nullptr; |
164 ResolveJavascriptCallback( | 165 ResolveJavascriptCallback( |
165 base::StringValue(webui_callback_id_), | 166 base::StringValue(webui_callback_id_), |
166 *base::Value::CreateNullValue()); | 167 *base::Value::CreateNullValue()); |
167 webui_callback_id_.clear(); | 168 webui_callback_id_.clear(); |
168 } | 169 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 void ClearBrowsingDataHandler::UpdateHistoryNotice(bool show) { | 202 void ClearBrowsingDataHandler::UpdateHistoryNotice(bool show) { |
202 should_show_history_footer_ = show; | 203 should_show_history_footer_ = show; |
203 OnStateChanged(); | 204 OnStateChanged(); |
204 | 205 |
205 UMA_HISTOGRAM_BOOLEAN( | 206 UMA_HISTOGRAM_BOOLEAN( |
206 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", | 207 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", |
207 should_show_history_footer_); | 208 should_show_history_footer_); |
208 } | 209 } |
209 | 210 |
210 } // namespace settings | 211 } // namespace settings |
OLD | NEW |