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

Unified Diff: chrome/browser/ui/webui/options/clear_browser_data_handler.cc

Issue 1813023002: Add a notice about other forms of history to the CBD dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_component
Patch Set: Update strings. Created 4 years, 8 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
« no previous file with comments | « chrome/browser/ui/webui/options/clear_browser_data_handler.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/clear_browser_data_handler.cc
diff --git a/chrome/browser/ui/webui/options/clear_browser_data_handler.cc b/chrome/browser/ui/webui/options/clear_browser_data_handler.cc
index 892ad95efc56c7ee6f846416fbb446120e34eaa0..54e5ffe771c7ca38d6720b4e5220efd65c6cd908 100644
--- a/chrome/browser/ui/webui/options/clear_browser_data_handler.cc
+++ b/chrome/browser/ui/webui/options/clear_browser_data_handler.cc
@@ -14,6 +14,7 @@
#include "base/metrics/sparse_histogram.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
@@ -26,6 +27,7 @@
#include "chrome/browser/browsing_data/cache_counter.h"
#include "chrome/browser/browsing_data/history_counter.h"
#include "chrome/browser/browsing_data/passwords_counter.h"
+#include "chrome/browser/history/web_history_service_factory.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
@@ -33,6 +35,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/locale_settings.h"
+#include "components/browsing_data_ui/history_notice_utils.h"
#include "components/google/core/browser/google_util.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/notification_details.h"
@@ -46,13 +49,24 @@ namespace {
const char kClearBrowsingDataLearnMoreUrl[] =
"https://support.google.com/chrome/?p=settings_clear_browsing_data";
+const char kMyActivityUrlInFooter[] =
+ "https://history.google.com/history/?utm_source=chrome_cbd";
+
+const char kMyActivityUrlInDialog[] =
+ "https://history.google.com/history/?utm_source=chrome_n";
+
+const int kMaxTimesHistoryNoticeShown = 1;
+
} // namespace
namespace options {
ClearBrowserDataHandler::ClearBrowserDataHandler()
: remover_(nullptr),
- sync_service_(nullptr) {
+ sync_service_(nullptr),
+ should_show_history_notice_(false),
+ should_show_history_deletion_dialog_(false),
+ weak_ptr_factory_(this) {
}
ClearBrowserDataHandler::~ClearBrowserDataHandler() {
@@ -90,7 +104,9 @@ void ClearBrowserDataHandler::InitializePage() {
web_ui()->CallJavascriptFunction(
"ClearBrowserDataOverlay.createFooter",
base::FundamentalValue(AreCountersEnabled()),
- base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()));
+ base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()),
+ base::FundamentalValue(should_show_history_notice_));
+ RefreshHistoryNotice();
UpdateInfoBannerVisibility();
OnBrowsingHistoryPrefChanged();
bool removal_in_progress = !!remover_;
@@ -141,6 +157,8 @@ void ClearBrowserDataHandler::GetLocalizedValues(
{ "clearBrowserDataSupportString", AreCountersEnabled()
? IDS_CLEAR_BROWSING_DATA_SOME_STUFF_REMAINS_SIMPLE
: IDS_CLEAR_BROWSING_DATA_SOME_STUFF_REMAINS },
+ { "clearBrowserDataHistoryNoticeTitle",
+ IDS_CLEAR_BROWSING_DATA_HISTORY_NOTICE_TITLE },
{ "deleteBrowsingHistoryCheckbox", IDS_DEL_BROWSING_HISTORY_CHKBOX },
{ "deleteDownloadHistoryCheckbox", IDS_DEL_DOWNLOAD_HISTORY_CHKBOX },
{ "deleteCacheCheckbox", IDS_DEL_CACHE_CHKBOX },
@@ -150,7 +168,7 @@ void ClearBrowserDataHandler::GetLocalizedValues(
{ "deleteFormDataCheckbox", IDS_DEL_FORM_DATA_CHKBOX },
{ "deleteHostedAppsDataCheckbox", IDS_DEL_HOSTED_APPS_DATA_CHKBOX },
{ "deauthorizeContentLicensesCheckbox",
- IDS_DEAUTHORIZE_CONTENT_LICENSES_CHKBOX },
+ IDS_DEAUTHORIZE_CONTENT_LICENSES_CHKBOX },
{ "clearBrowserDataCommit", IDS_CLEAR_BROWSING_DATA_COMMIT },
{ "flashStorageUrl", IDS_FLASH_STORAGE_URL },
};
@@ -160,6 +178,16 @@ void ClearBrowserDataHandler::GetLocalizedValues(
IDS_CLEAR_BROWSING_DATA_TITLE);
localized_strings->SetString("clearBrowsingDataLearnMoreUrl",
kClearBrowsingDataLearnMoreUrl);
+ localized_strings->SetString(
+ "clearBrowserDataHistoryFooter",
+ l10n_util::GetStringFUTF16(
+ IDS_CLEAR_BROWSING_DATA_HISTORY_FOOTER,
+ base::ASCIIToUTF16(kMyActivityUrlInFooter)));
+ localized_strings->SetString(
+ "clearBrowserDataHistoryNotice",
+ l10n_util::GetStringFUTF16(
+ IDS_CLEAR_BROWSING_DATA_HISTORY_NOTICE,
+ base::ASCIIToUTF16(kMyActivityUrlInDialog)));
base::ListValue* time_list = new base::ListValue;
for (int i = 0; i < 5; i++) {
@@ -297,7 +325,30 @@ void ClearBrowserDataHandler::HandleClearBrowserData(
void ClearBrowserDataHandler::OnBrowsingDataRemoverDone() {
remover_->RemoveObserver(this);
remover_ = nullptr;
- web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.doneClearing");
+
+ PrefService* prefs = Profile::FromWebUI(web_ui())->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;
+
+ if (show_notice) {
+ // Increment the preference.
+ prefs->SetInteger(prefs::kClearBrowsingDataHistoryNoticeShownTimes,
+ notice_shown_times + 1);
+ }
+
+ web_ui()->CallJavascriptFunction(
+ "ClearBrowserDataOverlay.doneClearing",
+ base::FundamentalValue(show_notice));
}
void ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged() {
@@ -328,8 +379,41 @@ void ClearBrowserDataHandler::UpdateCounterText(
void ClearBrowserDataHandler::OnStateChanged() {
web_ui()->CallJavascriptFunction(
- "ClearBrowserDataOverlay.updateSyncWarning",
- base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()));
+ "ClearBrowserDataOverlay.updateSyncWarningAndHistoryFooter",
+ base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()),
+ base::FundamentalValue(should_show_history_notice_));
+}
+
+void ClearBrowserDataHandler::RefreshHistoryNotice() {
+ browsing_data_ui::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory(
+ sync_service_,
+ WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())),
+ base::Bind(&ClearBrowserDataHandler::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::FromWebUI(web_ui())->GetPrefs()->
+ GetInteger(prefs::kClearBrowsingDataHistoryNoticeShownTimes);
+
+ if (notice_shown_times < kMaxTimesHistoryNoticeShown) {
+ browsing_data_ui::ShouldPopupDialogAboutOtherFormsOfBrowsingHistory(
+ sync_service_,
+ WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())),
+ base::Bind(&ClearBrowserDataHandler::UpdateHistoryDeletionDialog,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
+}
+
+void ClearBrowserDataHandler::UpdateHistoryNotice(bool show) {
+ should_show_history_notice_ = show;
+ OnStateChanged();
+}
+
+void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) {
+ // This is used by OnBrowsingDataRemoverDone (when the deletion finishes).
+ should_show_history_deletion_dialog_ = show;
}
} // namespace options
« no previous file with comments | « chrome/browser/ui/webui/options/clear_browser_data_handler.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698