Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3232)

Unified Diff: chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc

Issue 2098633002: Migrate the one-time notice into the MD settings CBD dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_counters
Patch Set: Initialize to false. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
diff --git a/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc b/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
index 645157c3ea5d0966cbeff76730f685ed1abd0b64..32b23b13c3ff88582c3e1bf439643620c42ce925 100644
--- a/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
@@ -21,11 +21,18 @@
#include "chrome/browser/browsing_data/passwords_counter.h"
#include "chrome/browser/history/web_history_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/common/channel_info.h"
#include "chrome/common/pref_names.h"
#include "components/browsing_data_ui/history_notice_utils.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui.h"
+namespace {
+
+const int kMaxTimesHistoryNoticeShown = 1;
+
+}
+
namespace settings {
ClearBrowsingDataHandler::ClearBrowsingDataHandler(content::WebUI* webui)
@@ -33,7 +40,8 @@ ClearBrowsingDataHandler::ClearBrowsingDataHandler(content::WebUI* webui)
sync_service_(ProfileSyncServiceFactory::GetForProfile(profile_)),
sync_service_observer_(this),
remover_(nullptr),
- should_show_history_footer_(false),
+ show_history_footer_(false),
+ show_history_deletion_dialog_(false),
weak_ptr_factory_(this) {}
ClearBrowsingDataHandler::~ClearBrowsingDataHandler() {
@@ -166,9 +174,33 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData(
void ClearBrowsingDataHandler::OnBrowsingDataRemoverDone() {
remover_->RemoveObserver(this);
remover_ = nullptr;
+
+ PrefService* prefs = profile_->GetPrefs();
+ int notice_shown_times =
+ prefs->GetInteger(prefs::kClearBrowsingDataHistoryNoticeShownTimes);
+
+ // When the deletion is complete, we might show an additional dialog with
+ // a notice about other forms of browsing history. This is the case if
+ const bool show_notice =
+ // 1. The dialog is relevant for the user.
+ show_history_deletion_dialog_ &&
+ // 2. The notice has been shown less than |kMaxTimesHistoryNoticeShown|.
+ notice_shown_times < kMaxTimesHistoryNoticeShown &&
+ // 3. The selected data types contained browsing history.
+ prefs->GetBoolean(prefs::kDeleteBrowsingHistory);
+
+ if (show_notice) {
+ // Increment the preference.
+ prefs->SetInteger(prefs::kClearBrowsingDataHistoryNoticeShownTimes,
+ notice_shown_times + 1);
+ }
+
+ UMA_HISTOGRAM_BOOLEAN(
+ "History.ClearBrowsingData.ShownHistoryNoticeAfterClearing", show_notice);
+
ResolveJavascriptCallback(
base::StringValue(webui_callback_id_),
- *base::Value::CreateNullValue());
+ base::FundamentalValue(show_notice));
webui_callback_id_.clear();
}
@@ -201,7 +233,7 @@ void ClearBrowsingDataHandler::OnStateChanged() {
"cr.webUIListenerCallback",
base::StringValue("update-footer"),
base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()),
- base::FundamentalValue(should_show_history_footer_));
+ base::FundamentalValue(show_history_footer_));
}
void ClearBrowsingDataHandler::RefreshHistoryNotice() {
@@ -210,15 +242,35 @@ void ClearBrowsingDataHandler::RefreshHistoryNotice() {
WebHistoryServiceFactory::GetForProfile(profile_),
base::Bind(&ClearBrowsingDataHandler::UpdateHistoryNotice,
weak_ptr_factory_.GetWeakPtr()));
+
+ // If the dialog with history notice has been shown less than
+ // |kMaxTimesHistoryNoticeShown| times, we might have to show it when the
+ // user deletes history. Find out if the conditions are met.
+ int notice_shown_times = profile_->GetPrefs()->
+ GetInteger(prefs::kClearBrowsingDataHistoryNoticeShownTimes);
+
+ if (notice_shown_times < kMaxTimesHistoryNoticeShown) {
+ browsing_data_ui::ShouldPopupDialogAboutOtherFormsOfBrowsingHistory(
+ sync_service_,
+ WebHistoryServiceFactory::GetForProfile(profile_),
+ chrome::GetChannel(),
+ base::Bind(&ClearBrowsingDataHandler::UpdateHistoryDeletionDialog,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
}
void ClearBrowsingDataHandler::UpdateHistoryNotice(bool show) {
- should_show_history_footer_ = show;
+ show_history_footer_ = show;
OnStateChanged();
UMA_HISTOGRAM_BOOLEAN(
"History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated",
- should_show_history_footer_);
+ show_history_footer_);
+}
+
+void ClearBrowsingDataHandler::UpdateHistoryDeletionDialog(bool show) {
+ // This is used by OnBrowsingDataRemoverDone (when the deletion finishes).
+ show_history_deletion_dialog_ = show;
}
void ClearBrowsingDataHandler::AddCounter(

Powered by Google App Engine
This is Rietveld 408576698