OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" |
10 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/pref_names.h" |
11 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
| 17 #include "chromeos/dbus/power_manager_client.h" |
12 #include "chromeos/dbus/session_manager_client.h" | 18 #include "chromeos/dbus/session_manager_client.h" |
13 #include "grit/browser_resources.h" | 19 #include "grit/browser_resources.h" |
14 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
15 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
16 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
17 | 23 |
18 namespace { | 24 namespace { |
19 | 25 |
20 // Reset screen id. | 26 // Reset screen id. |
21 const char kResetScreen[] = "reset"; | 27 const char kResetScreen[] = "reset"; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void ResetScreenHandler::GetLocalizedStrings( | 62 void ResetScreenHandler::GetLocalizedStrings( |
57 base::DictionaryValue* localized_strings) { | 63 base::DictionaryValue* localized_strings) { |
58 localized_strings->SetString( | 64 localized_strings->SetString( |
59 "resetScreenTitle", l10n_util::GetStringUTF16(IDS_RESET_SCREEN_TITLE)); | 65 "resetScreenTitle", l10n_util::GetStringUTF16(IDS_RESET_SCREEN_TITLE)); |
60 localized_strings->SetString( | 66 localized_strings->SetString( |
61 "resetWarningText", | 67 "resetWarningText", |
62 l10n_util::GetStringFUTF16( | 68 l10n_util::GetStringFUTF16( |
63 IDS_RESET_SCREEN_WARNING_MSG, | 69 IDS_RESET_SCREEN_WARNING_MSG, |
64 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 70 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
65 localized_strings->SetString( | 71 localized_strings->SetString( |
66 "resetWarningDetails", | |
67 l10n_util::GetStringUTF16(IDS_RESET_SCREEN_WARNING_DETAILS)); | |
68 localized_strings->SetString( | |
69 "cancelButton", l10n_util::GetStringUTF16(IDS_CANCEL)); | 72 "cancelButton", l10n_util::GetStringUTF16(IDS_CANCEL)); |
70 localized_strings->SetString( | 73 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kFirstBoot)) { |
71 "resetButton", l10n_util::GetStringUTF16(IDS_RESET_SCREEN_RESET)); | 74 localized_strings->SetString( |
| 75 "resetWarningDetails", |
| 76 l10n_util::GetStringUTF16(IDS_RESET_SCREEN_WARNING_DETAILS)); |
| 77 localized_strings->SetString( |
| 78 "resetButton", l10n_util::GetStringUTF16(IDS_RESET_SCREEN_RESET)); |
| 79 } else { |
| 80 localized_strings->SetString( |
| 81 "resetWarningDetails", |
| 82 l10n_util::GetStringFUTF16( |
| 83 IDS_OPTIONS_FACTORY_RESET_WARNING, |
| 84 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 85 localized_strings->SetString( |
| 86 "resetButton", l10n_util::GetStringUTF16(IDS_RELAUNCH_BUTTON)); |
| 87 } |
72 } | 88 } |
73 | 89 |
74 void ResetScreenHandler::Initialize() { | 90 void ResetScreenHandler::Initialize() { |
75 if (!page_is_ready() || !delegate_) | 91 if (!page_is_ready() || !delegate_) |
76 return; | 92 return; |
77 | 93 |
78 if (show_on_init_) { | 94 if (show_on_init_) { |
79 Show(); | 95 Show(); |
80 show_on_init_ = false; | 96 show_on_init_ = false; |
81 } | 97 } |
82 } | 98 } |
83 | 99 |
84 void ResetScreenHandler::RegisterMessages() { | 100 void ResetScreenHandler::RegisterMessages() { |
85 web_ui()->RegisterMessageCallback("resetOnCancel", | 101 web_ui()->RegisterMessageCallback("resetOnCancel", |
86 base::Bind(&ResetScreenHandler::HandleOnCancel, base::Unretained(this))); | 102 base::Bind(&ResetScreenHandler::HandleOnCancel, base::Unretained(this))); |
87 web_ui()->RegisterMessageCallback("resetOnReset", | 103 web_ui()->RegisterMessageCallback("resetOnReset", |
88 base::Bind(&ResetScreenHandler::HandleOnReset, base::Unretained(this))); | 104 base::Bind(&ResetScreenHandler::HandleOnReset, base::Unretained(this))); |
89 } | 105 } |
90 | 106 |
91 void ResetScreenHandler::HandleOnCancel(const base::ListValue* args) { | 107 void ResetScreenHandler::HandleOnCancel(const base::ListValue* args) { |
92 if (delegate_) | 108 if (delegate_) |
93 delegate_->OnExit(); | 109 delegate_->OnExit(); |
94 } | 110 } |
95 | 111 |
96 void ResetScreenHandler::HandleOnReset(const base::ListValue* args) { | 112 void ResetScreenHandler::HandleOnReset(const base::ListValue* args) { |
97 chromeos::SessionManagerClient* session_manager = | 113 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kFirstBoot)) { |
98 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); | 114 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
99 session_manager->StartDeviceWipe(); | 115 StartDeviceWipe(); |
| 116 } else { |
| 117 PrefService* prefs = g_browser_process->local_state(); |
| 118 prefs->SetBoolean(prefs::kFactoryResetRequested, true); |
| 119 prefs->CommitPendingWrite(); |
| 120 |
| 121 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 122 RequestRestart(); |
| 123 } |
100 } | 124 } |
101 | 125 |
102 } // namespace chromeos | 126 } // namespace chromeos |
OLD | NEW |