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

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

Issue 12092089: Display an info banner on the clear browsing data dialog if the browsing data was cleared within th… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments round 2 from James. Created 7 years, 11 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/common/pref_names.h » ('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 86f658b1bfdd10760705751fd19bcd583841e82b..eb793c7ccbcff7476c759696692f04014b12b02c 100644
--- a/chrome/browser/ui/webui/options/clear_browser_data_handler.cc
+++ b/chrome/browser/ui/webui/options/clear_browser_data_handler.cc
@@ -21,6 +21,7 @@
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
+#include "ui/base/accelerators/accelerator.h"
#include "ui/base/l10n/l10n_util.h"
namespace {
@@ -46,6 +47,25 @@ void ClearBrowserDataHandler::InitializeHandler() {
Profile::FromWebUI(web_ui())->GetPrefs());
}
+void ClearBrowserDataHandler::InitializePage() {
+ UpdateInfoBannerVisibility();
+}
+
+void ClearBrowserDataHandler::UpdateInfoBannerVisibility() {
+ Profile* profile = Profile::FromWebUI(web_ui());
+ base::Time lastClearBrowsingDataTime = base::Time::FromInternalValue(
+ profile->GetPrefs()->GetInt64(prefs::kLastClearBrowsingDataTime));
+
+ const int64 kHoursPerDay = 24;
+ bool visible = (base::Time::Now() - lastClearBrowsingDataTime) <=
+ base::TimeDelta::FromHours(kHoursPerDay);
+
+ ListValue args;
+ args.Append(Value::CreateBooleanValue(visible));
+ web_ui()->CallJavascriptFunction(
+ "ClearBrowserDataOverlay.setBannerVisibility", args);
+}
+
void ClearBrowserDataHandler::GetLocalizedValues(
DictionaryValue* localized_strings) {
DCHECK(localized_strings);
@@ -74,6 +94,13 @@ void ClearBrowserDataHandler::GetLocalizedValues(
google_util::StringAppendGoogleLocaleParam(
kClearBrowsingDataLearnMoreUrl));
+ ui::Accelerator acc(ui::VKEY_N, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN);
+ localized_strings->SetString(
+ "clearBrowserDataInfoBar",
+ l10n_util::GetStringFUTF16(
+ IDS_CLEAR_BROWSING_DATA_INFO_BAR_TEXT,
+ acc.GetShortcutText()));
+
ListValue* time_list = new ListValue;
for (int i = 0; i < 5; i++) {
string16 label_string;
@@ -152,6 +179,12 @@ void ClearBrowserDataHandler::HandleClearBrowserData(const ListValue* value) {
static_cast<BrowsingDataRemover::TimePeriod>(period_selected));
remover_->AddObserver(this);
remover_->Remove(remove_mask, origin_mask);
+
+ // Store the clear browsing data time. Next time the clear browsing data
+ // dialog is open, this time is used to decide whether to display an info
+ // banner or not.
+ prefs->SetInt64(prefs::kLastClearBrowsingDataTime,
+ base::Time::Now().ToInternalValue());
}
void ClearBrowserDataHandler::OnBrowsingDataRemoverDone() {
« no previous file with comments | « chrome/browser/ui/webui/options/clear_browser_data_handler.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698