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

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: Moved reset logic to chrome_pref_service_factory 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 const int kBannerShowTimeInDays = 5;
19 }
20
21 namespace options {
22
23 AutomaticSettingsResetHandler::AutomaticSettingsResetHandler() {}
24 AutomaticSettingsResetHandler::~AutomaticSettingsResetHandler() {}
25
26 void AutomaticSettingsResetHandler::InitializePage() {
27 const int64 reset_time =
28 g_browser_process->local_state()->GetInt64(
29 prefs::kProfilePreferenceResetTime);
30 if (reset_time != 0) {
31 const base::Time now = base::Time::Now();
32 const base::Time then = base::Time::FromInternalValue(reset_time);
33 if ((now - then).InDays() < kBannerShowTimeInDays)
34 web_ui()->CallJavascriptFunction("AutomaticSettingsResetBanner.show");
35 }
36 }
37
38 void AutomaticSettingsResetHandler::GetLocalizedValues(
39 base::DictionaryValue* localized_strings) {
40 DCHECK(localized_strings);
41
42 static const OptionsStringResource resources[] = {
43 { "automaticSettingsResetBannerText",
44 IDS_AUTOMATIC_SETTINGS_RESET_BANNER_TEXT },
45 { "automaticSettingsResetLearnMoreUrl",
46 IDS_LEARN_MORE },
47 };
48
49 RegisterStrings(localized_strings, resources, arraysize(resources));
50 localized_strings->SetString(
51 "automaticSettingsResetLearnMoreUrl",
52 chrome::kAutomaticSettingsResetLearnMoreURL);
53 }
54
55 void AutomaticSettingsResetHandler::RegisterMessages() {
56 web_ui()->RegisterMessageCallback("onDismissedAutomaticSettingsResetBanner",
57 base::Bind(&AutomaticSettingsResetHandler::
58 OnDismissedAutomaticSettingsResetBanner));
59 }
60
61 // static
gab 2014/02/07 19:38:31 Still prefer anonymous method (i.e. unnamed namesp
robertshield 2014/02/07 21:21:34 Already done in current patchset. Apologies for co
62 void AutomaticSettingsResetHandler::OnDismissedAutomaticSettingsResetBanner(
63 const base::ListValue* value) {
64 PrefService* local_state = g_browser_process->local_state();
65 local_state->ClearPref(prefs::kProfilePreferenceResetTime);
66 }
67
68 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698