Vectorize sad tab image.
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / automatic_settings_reset_handler.cc
blob22a81c328b65ff581d74c21c457442e7992faf83
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.
5 #include "chrome/browser/ui/webui/options/automatic_settings_reset_handler.h"
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/time/time.h"
10 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/url_constants.h"
13 #include "chrome/grit/generated_resources.h"
14 #include "content/public/browser/web_ui.h"
15 #include "grit/components_strings.h"
17 namespace {
19 void OnDismissedAutomaticSettingsResetBanner(Profile* profile,
20 const base::ListValue* value) {
21 chrome_prefs::ClearResetTime(profile);
24 } // namespace
26 namespace options {
28 AutomaticSettingsResetHandler::AutomaticSettingsResetHandler() {}
29 AutomaticSettingsResetHandler::~AutomaticSettingsResetHandler() {}
31 void AutomaticSettingsResetHandler::InitializePage() {
32 static const int kBannerShowTimeInDays = 5;
34 const base::Time then =
35 chrome_prefs::GetResetTime(Profile::FromWebUI(web_ui()));
36 if (!then.is_null()) {
37 const base::Time now = base::Time::Now();
38 if ((now - then).InDays() < kBannerShowTimeInDays)
39 web_ui()->CallJavascriptFunction("AutomaticSettingsResetBanner.show");
43 void AutomaticSettingsResetHandler::GetLocalizedValues(
44 base::DictionaryValue* localized_strings) {
45 DCHECK(localized_strings);
47 static const OptionsStringResource resources[] = {
48 { "automaticSettingsResetBannerResetButtonText",
49 IDS_AUTOMATIC_SETTINGS_RESET_BANNER_RESET_BUTTON_TEXT },
50 { "automaticSettingsResetBannerText",
51 IDS_AUTOMATIC_SETTINGS_RESET_BANNER_TEXT },
52 { "automaticSettingsResetLearnMoreUrl",
53 IDS_LEARN_MORE },
56 RegisterStrings(localized_strings, resources, arraysize(resources));
57 localized_strings->SetString(
58 "automaticSettingsResetLearnMoreUrl",
59 chrome::kAutomaticSettingsResetLearnMoreURL);
62 void AutomaticSettingsResetHandler::RegisterMessages() {
63 web_ui()->RegisterMessageCallback(
64 "onDismissedAutomaticSettingsResetBanner",
65 base::Bind(&OnDismissedAutomaticSettingsResetBanner,
66 Profile::FromWebUI(web_ui())));
69 } // namespace options