OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/settings/chromeos/easy_unlock_settings_handler
.h" | 5 #include "chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_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/command_line.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 base::Unretained(this))); | 80 base::Unretained(this))); |
81 } | 81 } |
82 | 82 |
83 void EasyUnlockSettingsHandler::OnJavascriptDisallowed() { | 83 void EasyUnlockSettingsHandler::OnJavascriptDisallowed() { |
84 EasyUnlockService::Get(profile_)->RemoveObserver(this); | 84 EasyUnlockService::Get(profile_)->RemoveObserver(this); |
85 profile_pref_registrar_.RemoveAll(); | 85 profile_pref_registrar_.RemoveAll(); |
86 } | 86 } |
87 | 87 |
88 void EasyUnlockSettingsHandler::OnTurnOffOperationStatusChanged() { | 88 void EasyUnlockSettingsHandler::OnTurnOffOperationStatusChanged() { |
89 CallJavascriptFunction("cr.webUIListenerCallback", | 89 CallJavascriptFunction("cr.webUIListenerCallback", |
90 base::StringValue("easy-unlock-turn-off-flow-status"), | 90 base::Value("easy-unlock-turn-off-flow-status"), |
91 base::StringValue(GetTurnOffFlowStatus())); | 91 base::Value(GetTurnOffFlowStatus())); |
92 } | 92 } |
93 | 93 |
94 void EasyUnlockSettingsHandler::SendEnabledStatus() { | 94 void EasyUnlockSettingsHandler::SendEnabledStatus() { |
95 CallJavascriptFunction( | 95 CallJavascriptFunction( |
96 "cr.webUIListenerCallback", | 96 "cr.webUIListenerCallback", base::Value("easy-unlock-enabled-status"), |
97 base::StringValue("easy-unlock-enabled-status"), | |
98 base::Value(EasyUnlockService::Get(profile_)->IsEnabled())); | 97 base::Value(EasyUnlockService::Get(profile_)->IsEnabled())); |
99 } | 98 } |
100 | 99 |
101 std::string EasyUnlockSettingsHandler::GetTurnOffFlowStatus() { | 100 std::string EasyUnlockSettingsHandler::GetTurnOffFlowStatus() { |
102 EasyUnlockService::TurnOffFlowStatus status = | 101 EasyUnlockService::TurnOffFlowStatus status = |
103 EasyUnlockService::Get(profile_)->GetTurnOffFlowStatus(); | 102 EasyUnlockService::Get(profile_)->GetTurnOffFlowStatus(); |
104 | 103 |
105 // Translate status into JS UI state string. Note the translated string | 104 // Translate status into JS UI state string. Note the translated string |
106 // should match UIState defined in easy_unlock_turn_off_dialog.js. | 105 // should match UIState defined in easy_unlock_turn_off_dialog.js. |
107 std::string status_string; | 106 std::string status_string; |
(...skipping 30 matching lines...) Expand all Loading... |
138 void EasyUnlockSettingsHandler::HandleStartTurnOnFlow( | 137 void EasyUnlockSettingsHandler::HandleStartTurnOnFlow( |
139 const base::ListValue* args) { | 138 const base::ListValue* args) { |
140 EasyUnlockService::Get(profile_)->LaunchSetup(); | 139 EasyUnlockService::Get(profile_)->LaunchSetup(); |
141 } | 140 } |
142 | 141 |
143 void EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus( | 142 void EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus( |
144 const base::ListValue* args) { | 143 const base::ListValue* args) { |
145 CHECK_EQ(1U, args->GetSize()); | 144 CHECK_EQ(1U, args->GetSize()); |
146 const base::Value* callback_id; | 145 const base::Value* callback_id; |
147 CHECK(args->Get(0, &callback_id)); | 146 CHECK(args->Get(0, &callback_id)); |
148 ResolveJavascriptCallback(*callback_id, | 147 ResolveJavascriptCallback(*callback_id, base::Value(GetTurnOffFlowStatus())); |
149 base::StringValue(GetTurnOffFlowStatus())); | |
150 } | 148 } |
151 | 149 |
152 void EasyUnlockSettingsHandler::HandleStartTurnOffFlow( | 150 void EasyUnlockSettingsHandler::HandleStartTurnOffFlow( |
153 const base::ListValue* args) { | 151 const base::ListValue* args) { |
154 EasyUnlockService::Get(profile_)->RunTurnOffFlow(); | 152 EasyUnlockService::Get(profile_)->RunTurnOffFlow(); |
155 } | 153 } |
156 | 154 |
157 void EasyUnlockSettingsHandler::HandleCancelTurnOffFlow( | 155 void EasyUnlockSettingsHandler::HandleCancelTurnOffFlow( |
158 const base::ListValue* args) { | 156 const base::ListValue* args) { |
159 EasyUnlockService::Get(profile_)->ResetTurnOffFlow(); | 157 EasyUnlockService::Get(profile_)->ResetTurnOffFlow(); |
160 } | 158 } |
161 | 159 |
162 } // namespace settings | 160 } // namespace settings |
163 } // namespace chromeos | 161 } // namespace chromeos |
OLD | NEW |