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> |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 sync_service_ = ProfileSyncServiceFactory::GetForProfile(profile); | 105 sync_service_ = ProfileSyncServiceFactory::GetForProfile(profile); |
106 if (sync_service_) | 106 if (sync_service_) |
107 sync_service_->AddObserver(this); | 107 sync_service_->AddObserver(this); |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 void ClearBrowserDataHandler::InitializePage() { | 111 void ClearBrowserDataHandler::InitializePage() { |
112 web_ui()->CallJavascriptFunctionUnsafe( | 112 web_ui()->CallJavascriptFunctionUnsafe( |
113 "ClearBrowserDataOverlay.createFooter", | 113 "ClearBrowserDataOverlay.createFooter", |
114 base::FundamentalValue(AreCountersEnabled()), | 114 base::Value(AreCountersEnabled()), |
115 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), | 115 base::Value(sync_service_ && sync_service_->IsSyncActive()), |
116 base::FundamentalValue(should_show_history_notice_)); | 116 base::Value(should_show_history_notice_)); |
117 RefreshHistoryNotice(); | 117 RefreshHistoryNotice(); |
118 UpdateInfoBannerVisibility(); | 118 UpdateInfoBannerVisibility(); |
119 OnBrowsingHistoryPrefChanged(); | 119 OnBrowsingHistoryPrefChanged(); |
120 bool removal_in_progress = !!remover_; | 120 bool removal_in_progress = !!remover_; |
121 web_ui()->CallJavascriptFunctionUnsafe( | 121 web_ui()->CallJavascriptFunctionUnsafe( |
122 "ClearBrowserDataOverlay.setClearing", | 122 "ClearBrowserDataOverlay.setClearing", |
123 base::FundamentalValue(removal_in_progress)); | 123 base::Value(removal_in_progress)); |
124 | 124 |
125 web_ui()->CallJavascriptFunctionUnsafe( | 125 web_ui()->CallJavascriptFunctionUnsafe( |
126 "ClearBrowserDataOverlay.markInitializationComplete"); | 126 "ClearBrowserDataOverlay.markInitializationComplete"); |
127 } | 127 } |
128 | 128 |
129 void ClearBrowserDataHandler::UpdateInfoBannerVisibility() { | 129 void ClearBrowserDataHandler::UpdateInfoBannerVisibility() { |
130 base::string16 text; | 130 base::string16 text; |
131 | 131 |
132 Profile* profile = Profile::FromWebUI(web_ui()); | 132 Profile* profile = Profile::FromWebUI(web_ui()); |
133 auto availability = IncognitoModePrefs::GetAvailability(profile->GetPrefs()); | 133 auto availability = IncognitoModePrefs::GetAvailability(profile->GetPrefs()); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // Increment the preference. | 353 // Increment the preference. |
354 prefs->SetInteger( | 354 prefs->SetInteger( |
355 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes, | 355 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes, |
356 notice_shown_times + 1); | 356 notice_shown_times + 1); |
357 } | 357 } |
358 | 358 |
359 UMA_HISTOGRAM_BOOLEAN( | 359 UMA_HISTOGRAM_BOOLEAN( |
360 "History.ClearBrowsingData.ShownHistoryNoticeAfterClearing", show_notice); | 360 "History.ClearBrowsingData.ShownHistoryNoticeAfterClearing", show_notice); |
361 | 361 |
362 web_ui()->CallJavascriptFunctionUnsafe("ClearBrowserDataOverlay.doneClearing", | 362 web_ui()->CallJavascriptFunctionUnsafe("ClearBrowserDataOverlay.doneClearing", |
363 base::FundamentalValue(show_notice)); | 363 base::Value(show_notice)); |
364 } | 364 } |
365 | 365 |
366 void ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged() { | 366 void ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged() { |
367 web_ui()->CallJavascriptFunctionUnsafe( | 367 web_ui()->CallJavascriptFunctionUnsafe( |
368 "ClearBrowserDataOverlay.setAllowDeletingHistory", | 368 "ClearBrowserDataOverlay.setAllowDeletingHistory", |
369 base::FundamentalValue(*allow_deleting_browser_history_)); | 369 base::Value(*allow_deleting_browser_history_)); |
370 } | 370 } |
371 | 371 |
372 void ClearBrowserDataHandler::AddCounter( | 372 void ClearBrowserDataHandler::AddCounter( |
373 std::unique_ptr<browsing_data::BrowsingDataCounter> counter) { | 373 std::unique_ptr<browsing_data::BrowsingDataCounter> counter) { |
374 DCHECK(AreCountersEnabled()); | 374 DCHECK(AreCountersEnabled()); |
375 | 375 |
376 counter->Init(Profile::FromWebUI(web_ui())->GetPrefs(), | 376 counter->Init(Profile::FromWebUI(web_ui())->GetPrefs(), |
377 base::Bind(&ClearBrowserDataHandler::UpdateCounterText, | 377 base::Bind(&ClearBrowserDataHandler::UpdateCounterText, |
378 base::Unretained(this))); | 378 base::Unretained(this))); |
379 counters_.push_back(std::move(counter)); | 379 counters_.push_back(std::move(counter)); |
380 } | 380 } |
381 | 381 |
382 void ClearBrowserDataHandler::UpdateCounterText( | 382 void ClearBrowserDataHandler::UpdateCounterText( |
383 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { | 383 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { |
384 DCHECK(AreCountersEnabled()); | 384 DCHECK(AreCountersEnabled()); |
385 web_ui()->CallJavascriptFunctionUnsafe( | 385 web_ui()->CallJavascriptFunctionUnsafe( |
386 "ClearBrowserDataOverlay.updateCounter", | 386 "ClearBrowserDataOverlay.updateCounter", |
387 base::StringValue(result->source()->GetPrefName()), | 387 base::StringValue(result->source()->GetPrefName()), |
388 base::StringValue(GetChromeCounterTextFromResult(result.get()))); | 388 base::StringValue(GetChromeCounterTextFromResult(result.get()))); |
389 } | 389 } |
390 | 390 |
391 void ClearBrowserDataHandler::OnStateChanged() { | 391 void ClearBrowserDataHandler::OnStateChanged() { |
392 web_ui()->CallJavascriptFunctionUnsafe( | 392 web_ui()->CallJavascriptFunctionUnsafe( |
393 "ClearBrowserDataOverlay.updateSyncWarningAndHistoryFooter", | 393 "ClearBrowserDataOverlay.updateSyncWarningAndHistoryFooter", |
394 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), | 394 base::Value(sync_service_ && sync_service_->IsSyncActive()), |
395 base::FundamentalValue(should_show_history_notice_)); | 395 base::Value(should_show_history_notice_)); |
396 } | 396 } |
397 | 397 |
398 void ClearBrowserDataHandler::RefreshHistoryNotice() { | 398 void ClearBrowserDataHandler::RefreshHistoryNotice() { |
399 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( | 399 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( |
400 sync_service_, | 400 sync_service_, |
401 WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())), | 401 WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())), |
402 base::Bind(&ClearBrowserDataHandler::UpdateHistoryNotice, | 402 base::Bind(&ClearBrowserDataHandler::UpdateHistoryNotice, |
403 weak_ptr_factory_.GetWeakPtr())); | 403 weak_ptr_factory_.GetWeakPtr())); |
404 | 404 |
405 // If the dialog with history notice has been shown less than | 405 // If the dialog with history notice has been shown less than |
(...skipping 20 matching lines...) Expand all Loading... |
426 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", | 426 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", |
427 should_show_history_notice_); | 427 should_show_history_notice_); |
428 } | 428 } |
429 | 429 |
430 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) { | 430 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) { |
431 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes). | 431 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes). |
432 should_show_history_deletion_dialog_ = show; | 432 should_show_history_deletion_dialog_ = show; |
433 } | 433 } |
434 | 434 |
435 } // namespace options | 435 } // namespace options |
OLD | NEW |