| 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..e862dca69152c616306aa9b63d6a9bbba69a8f17 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,6 +49,10 @@ namespace {
|
| const char kClearBrowsingDataLearnMoreUrl[] =
|
| "https://support.google.com/chrome/?p=settings_clear_browsing_data";
|
|
|
| +const char kMyActivityUrl[] = "https://history.google.com";
|
| +
|
| +const int kMaxTimesHistoryNoticeShown = 1;
|
| +
|
| } // namespace
|
|
|
| namespace options {
|
| @@ -90,7 +97,8 @@ 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(ShouldShowHistoryFooter()));
|
| UpdateInfoBannerVisibility();
|
| OnBrowsingHistoryPrefChanged();
|
| bool removal_in_progress = !!remover_;
|
| @@ -141,6 +149,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 +160,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 +170,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(kMyActivityUrl)));
|
| + localized_strings->SetString(
|
| + "clearBrowserDataHistoryNotice",
|
| + l10n_util::GetStringFUTF16(
|
| + IDS_CLEAR_BROWSING_DATA_HISTORY_NOTICE,
|
| + base::ASCIIToUTF16(kMyActivityUrl)));
|
|
|
| base::ListValue* time_list = new base::ListValue;
|
| for (int i = 0; i < 5; i++) {
|
| @@ -297,7 +317,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
|
| + bool show_notice =
|
| + // 1. The selected data types contained browsing history.
|
| + prefs->GetBoolean(prefs::kDeleteBrowsingHistory) &&
|
| + // 2. The footer about other forms of browsing history is also shown.
|
| + ShouldShowHistoryFooter() &&
|
| + // 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 +371,15 @@ 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(ShouldShowHistoryFooter()));
|
| +}
|
| +
|
| +bool ClearBrowserDataHandler::ShouldShowHistoryFooter() {
|
| + return browsing_data_ui::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory(
|
| + sync_service_,
|
| + WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())));
|
| }
|
|
|
| } // namespace options
|
|
|