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

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: 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 b3da547c0127cbce1c742528a22b03c8b3d96a01..b0431637b9685c9830576a1bdfd5893af144e33e 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)
@@ -166,9 +173,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.
+ should_show_history_deletion_dialog_ &&
+ // 2. The selected data types contained browsing history.
+ prefs->GetBoolean(prefs::kDeleteBrowsingHistory) &&
+ // 3. The notice has been shown less than |kMaxTimesHistoryNoticeShown|.
+ notice_shown_times < kMaxTimesHistoryNoticeShown;
dschuyler 2016/06/25 01:34:54 nit: not a big deal, but if #2 and #3 were swapped
msramek 2016/06/27 15:24:59 Done.
+
+ if (show_notice) {
+ // Increment the preference.
+ prefs->SetInteger(prefs::kClearBrowsingDataHistoryNoticeShownTimes,
+ notice_shown_times + 1);
dschuyler 2016/06/25 01:34:54 trivia: it looks like there is a potential race co
msramek 2016/06/27 15:24:59 Acknowledged. Thanks for pointing it out.
+ }
+
+ 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();
}
@@ -210,6 +241,21 @@ 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) {
@@ -221,6 +267,11 @@ void ClearBrowsingDataHandler::UpdateHistoryNotice(bool show) {
should_show_history_footer_);
}
+void ClearBrowsingDataHandler::UpdateHistoryDeletionDialog(bool show) {
+ // This is used by OnBrowsingDataRemoverDone (when the deletion finishes).
+ should_show_history_deletion_dialog_ = show;
+}
+
void ClearBrowsingDataHandler::AddCounter(
std::unique_ptr<BrowsingDataCounter> counter) {
counter->Init(

Powered by Google App Engine
This is Rietveld 408576698