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" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 prefs->SetInteger( | 234 prefs->SetInteger( |
235 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes, | 235 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes, |
236 notice_shown_times + 1); | 236 notice_shown_times + 1); |
237 } | 237 } |
238 | 238 |
239 UMA_HISTOGRAM_BOOLEAN( | 239 UMA_HISTOGRAM_BOOLEAN( |
240 "History.ClearBrowsingData.ShownHistoryNoticeAfterClearing", show_notice); | 240 "History.ClearBrowsingData.ShownHistoryNoticeAfterClearing", show_notice); |
241 | 241 |
242 ResolveJavascriptCallback( | 242 ResolveJavascriptCallback( |
243 base::StringValue(webui_callback_id), | 243 base::StringValue(webui_callback_id), |
244 base::FundamentalValue(show_notice)); | 244 base::Value(show_notice)); |
245 task_observer_.reset(); | 245 task_observer_.reset(); |
246 } | 246 } |
247 | 247 |
248 void ClearBrowsingDataHandler::OnBrowsingHistoryPrefChanged() { | 248 void ClearBrowsingDataHandler::OnBrowsingHistoryPrefChanged() { |
249 CallJavascriptFunction( | 249 CallJavascriptFunction( |
250 "cr.webUIListenerCallback", | 250 "cr.webUIListenerCallback", |
251 base::StringValue("browsing-history-pref-changed"), | 251 base::StringValue("browsing-history-pref-changed"), |
252 base::FundamentalValue( | 252 base::Value( |
253 profile_->GetPrefs()->GetBoolean( | 253 profile_->GetPrefs()->GetBoolean( |
254 prefs::kAllowDeletingBrowserHistory))); | 254 prefs::kAllowDeletingBrowserHistory))); |
255 } | 255 } |
256 | 256 |
257 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) { | 257 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) { |
258 AllowJavascript(); | 258 AllowJavascript(); |
259 const base::Value* callback_id; | 259 const base::Value* callback_id; |
260 CHECK(args->Get(0, &callback_id)); | 260 CHECK(args->Get(0, &callback_id)); |
261 | 261 |
262 task_observer_.reset(); | 262 task_observer_.reset(); |
263 counters_.clear(); | 263 counters_.clear(); |
264 | 264 |
265 for (const std::string& pref : kCounterPrefs) { | 265 for (const std::string& pref : kCounterPrefs) { |
266 AddCounter( | 266 AddCounter( |
267 BrowsingDataCounterFactory::GetForProfileAndPref(profile_, pref)); | 267 BrowsingDataCounterFactory::GetForProfileAndPref(profile_, pref)); |
268 } | 268 } |
269 | 269 |
270 OnStateChanged(); | 270 OnStateChanged(); |
271 RefreshHistoryNotice(); | 271 RefreshHistoryNotice(); |
272 | 272 |
273 ResolveJavascriptCallback( | 273 ResolveJavascriptCallback( |
274 *callback_id, | 274 *callback_id, |
275 *base::Value::CreateNullValue() /* Promise<void> */); | 275 *base::Value::CreateNullValue() /* Promise<void> */); |
276 } | 276 } |
277 | 277 |
278 void ClearBrowsingDataHandler::OnStateChanged() { | 278 void ClearBrowsingDataHandler::OnStateChanged() { |
279 CallJavascriptFunction( | 279 CallJavascriptFunction( |
280 "cr.webUIListenerCallback", | 280 "cr.webUIListenerCallback", |
281 base::StringValue("update-footer"), | 281 base::StringValue("update-footer"), |
282 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), | 282 base::Value(sync_service_ && sync_service_->IsSyncActive()), |
283 base::FundamentalValue(show_history_footer_)); | 283 base::Value(show_history_footer_)); |
284 } | 284 } |
285 | 285 |
286 void ClearBrowsingDataHandler::RefreshHistoryNotice() { | 286 void ClearBrowsingDataHandler::RefreshHistoryNotice() { |
287 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( | 287 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( |
288 sync_service_, | 288 sync_service_, |
289 WebHistoryServiceFactory::GetForProfile(profile_), | 289 WebHistoryServiceFactory::GetForProfile(profile_), |
290 base::Bind(&ClearBrowsingDataHandler::UpdateHistoryNotice, | 290 base::Bind(&ClearBrowsingDataHandler::UpdateHistoryNotice, |
291 weak_ptr_factory_.GetWeakPtr())); | 291 weak_ptr_factory_.GetWeakPtr())); |
292 | 292 |
293 // If the dialog with history notice has been shown less than | 293 // If the dialog with history notice has been shown less than |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 void ClearBrowsingDataHandler::UpdateCounterText( | 332 void ClearBrowsingDataHandler::UpdateCounterText( |
333 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { | 333 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { |
334 CallJavascriptFunction( | 334 CallJavascriptFunction( |
335 "cr.webUIListenerCallback", | 335 "cr.webUIListenerCallback", |
336 base::StringValue("update-counter-text"), | 336 base::StringValue("update-counter-text"), |
337 base::StringValue(result->source()->GetPrefName()), | 337 base::StringValue(result->source()->GetPrefName()), |
338 base::StringValue(GetChromeCounterTextFromResult(result.get()))); | 338 base::StringValue(GetChromeCounterTextFromResult(result.get()))); |
339 } | 339 } |
340 | 340 |
341 } // namespace settings | 341 } // namespace settings |
OLD | NEW |