1 // Copyright (c) 2012 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/chromeos/login/reset_screen_handler.h"
9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/pref_names.h"
14 #include "chromeos/chromeos_switches.h"
15 #include "chromeos/dbus/dbus_thread_manager.h"
16 #include "chromeos/dbus/power_manager_client.h"
17 #include "chromeos/dbus/session_manager_client.h"
18 #include "grit/browser_resources.h"
19 #include "grit/chromium_strings.h"
20 #include "grit/generated_resources.h"
24 const char kJsScreenPath
[] = "login.ResetScreen";
27 const char kResetScreen
[] = "reset";
33 ResetScreenHandler::ResetScreenHandler()
34 : BaseScreenHandler(kJsScreenPath
),
36 show_on_init_(false) {
39 ResetScreenHandler::~ResetScreenHandler() {
41 delegate_
->OnActorDestroyed(this);
44 void ResetScreenHandler::PrepareToShow() {
47 void ResetScreenHandler::Show() {
48 if (!page_is_ready()) {
52 ShowScreen(kResetScreen
, NULL
);
55 void ResetScreenHandler::Hide() {
58 void ResetScreenHandler::SetDelegate(Delegate
* delegate
) {
64 void ResetScreenHandler::DeclareLocalizedValues(
65 LocalizedValuesBuilder
* builder
) {
66 builder
->Add("resetScreenTitle", IDS_RESET_SCREEN_TITLE
);
67 builder
->Add("cancelButton", IDS_CANCEL
);
69 builder
->AddF("resetWarningText",
70 IDS_RESET_SCREEN_WARNING_MSG
,
71 IDS_SHORT_PRODUCT_NAME
);
73 if (CommandLine::ForCurrentProcess()->HasSwitch(
74 switches::kFirstExecAfterBoot
)) {
75 builder
->AddF("resetWarningDetails",
76 IDS_RESET_SCREEN_WARNING_DETAILS
,
77 IDS_SHORT_PRODUCT_NAME
);
78 builder
->Add("resetButton", IDS_RESET_SCREEN_RESET
);
80 builder
->AddF("resetWarningDetails",
81 IDS_RESET_SCREEN_WARNING_DETAILS_RESTART
,
82 IDS_SHORT_PRODUCT_NAME
);
83 builder
->Add("resetButton", IDS_RELAUNCH_BUTTON
);
87 void ResetScreenHandler::Initialize() {
88 if (!page_is_ready() || !delegate_
)
93 show_on_init_
= false;
97 void ResetScreenHandler::RegisterMessages() {
98 AddCallback("resetOnCancel", &ResetScreenHandler::HandleOnCancel
);
99 AddCallback("resetOnReset", &ResetScreenHandler::HandleOnReset
);
102 void ResetScreenHandler::HandleOnCancel() {
107 void ResetScreenHandler::HandleOnReset() {
108 if (CommandLine::ForCurrentProcess()->HasSwitch(
109 switches::kFirstExecAfterBoot
)) {
110 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
113 PrefService
* prefs
= g_browser_process
->local_state();
114 prefs
->SetBoolean(prefs::kFactoryResetRequested
, true);
115 prefs
->CommitPendingWrite();
117 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
122 } // namespace chromeos