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

Side by Side Diff: chrome/browser/ui/webui/options/automatic_settings_reset_handler.cc

Issue 151003004: Add an automatic settings reset banner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on top of transaction patch. Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/options/automatic_settings_reset_handler.h"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/prefs/pref_service.h"
10 #include "base/time/time.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/common/pref_names.h"
13 #include "chrome/common/url_constants.h"
14 #include "content/public/browser/web_ui.h"
15 #include "grit/generated_resources.h"
16
17 namespace {
18
19 const int kBannerShowTimeInDays = 5;
20
21 // Called when the user dismisses the automatic settings reset banner.
22 void OnDismissedAutomaticSettingsResetBanner(const base::ListValue* value) {
23 PrefService* local_state = g_browser_process->local_state();
24 local_state->ClearPref(prefs::kProfilePreferenceResetTime);
25 }
26
27 } // namespace
28
29 namespace options {
30
31 AutomaticSettingsResetHandler::AutomaticSettingsResetHandler() {}
32 AutomaticSettingsResetHandler::~AutomaticSettingsResetHandler() {}
33
34 void AutomaticSettingsResetHandler::InitializePage() {
35 const int64 reset_time =
36 g_browser_process->local_state()->GetInt64(
37 prefs::kProfilePreferenceResetTime);
38 if (reset_time != 0) {
39 const base::Time now = base::Time::Now();
40 const base::Time then = base::Time::FromInternalValue(reset_time);
41 if ((now - then).InDays() < kBannerShowTimeInDays)
42 web_ui()->CallJavascriptFunction("AutomaticSettingsResetBanner.show");
43 }
44 }
45
46 void AutomaticSettingsResetHandler::GetLocalizedValues(
47 base::DictionaryValue* localized_strings) {
48 DCHECK(localized_strings);
49
50 static const OptionsStringResource resources[] = {
51 { "automaticSettingsResetBannerText",
52 IDS_AUTOMATIC_SETTINGS_RESET_BANNER_TEXT },
53 { "automaticSettingsResetLearnMoreUrl",
54 IDS_LEARN_MORE },
55 };
56
57 RegisterStrings(localized_strings, resources, arraysize(resources));
58 localized_strings->SetString(
59 "automaticSettingsResetLearnMoreUrl",
60 chrome::kAutomaticSettingsResetLearnMoreURL);
61 }
62
63 void AutomaticSettingsResetHandler::RegisterMessages() {
64 web_ui()->RegisterMessageCallback("onDismissedAutomaticSettingsResetBanner",
65 base::Bind(&OnDismissedAutomaticSettingsResetBanner));
66 }
67
68 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/automatic_settings_reset_handler.h ('k') | chrome/browser/ui/webui/options/options_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698