| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::StringValue("easy-unlock-turn-off-flow-status"), |
| 91 base::StringValue(GetTurnOffFlowStatus())); | 91 base::StringValue(GetTurnOffFlowStatus())); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void EasyUnlockSettingsHandler::SendEnabledStatus() { | 94 void EasyUnlockSettingsHandler::SendEnabledStatus() { |
| 95 CallJavascriptFunction( | 95 CallJavascriptFunction( |
| 96 "cr.webUIListenerCallback", | 96 "cr.webUIListenerCallback", |
| 97 base::StringValue("easy-unlock-enabled-status"), | 97 base::StringValue("easy-unlock-enabled-status"), |
| 98 base::FundamentalValue(EasyUnlockService::Get(profile_)->IsEnabled())); | 98 base::Value(EasyUnlockService::Get(profile_)->IsEnabled())); |
| 99 } | 99 } |
| 100 | 100 |
| 101 std::string EasyUnlockSettingsHandler::GetTurnOffFlowStatus() { | 101 std::string EasyUnlockSettingsHandler::GetTurnOffFlowStatus() { |
| 102 EasyUnlockService::TurnOffFlowStatus status = | 102 EasyUnlockService::TurnOffFlowStatus status = |
| 103 EasyUnlockService::Get(profile_)->GetTurnOffFlowStatus(); | 103 EasyUnlockService::Get(profile_)->GetTurnOffFlowStatus(); |
| 104 | 104 |
| 105 // Translate status into JS UI state string. Note the translated string | 105 // Translate status into JS UI state string. Note the translated string |
| 106 // should match UIState defined in easy_unlock_turn_off_dialog.js. | 106 // should match UIState defined in easy_unlock_turn_off_dialog.js. |
| 107 std::string status_string; | 107 std::string status_string; |
| 108 switch (status) { | 108 switch (status) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 125 } | 125 } |
| 126 | 126 |
| 127 void EasyUnlockSettingsHandler::HandleGetEnabledStatus( | 127 void EasyUnlockSettingsHandler::HandleGetEnabledStatus( |
| 128 const base::ListValue* args) { | 128 const base::ListValue* args) { |
| 129 AllowJavascript(); | 129 AllowJavascript(); |
| 130 | 130 |
| 131 CHECK_EQ(1U, args->GetSize()); | 131 CHECK_EQ(1U, args->GetSize()); |
| 132 const base::Value* callback_id; | 132 const base::Value* callback_id; |
| 133 CHECK(args->Get(0, &callback_id)); | 133 CHECK(args->Get(0, &callback_id)); |
| 134 ResolveJavascriptCallback( | 134 ResolveJavascriptCallback( |
| 135 *callback_id, | 135 *callback_id, base::Value(EasyUnlockService::Get(profile_)->IsEnabled())); |
| 136 base::FundamentalValue(EasyUnlockService::Get(profile_)->IsEnabled())); | |
| 137 } | 136 } |
| 138 | 137 |
| 139 void EasyUnlockSettingsHandler::HandleStartTurnOnFlow( | 138 void EasyUnlockSettingsHandler::HandleStartTurnOnFlow( |
| 140 const base::ListValue* args) { | 139 const base::ListValue* args) { |
| 141 EasyUnlockService::Get(profile_)->LaunchSetup(); | 140 EasyUnlockService::Get(profile_)->LaunchSetup(); |
| 142 } | 141 } |
| 143 | 142 |
| 144 void EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus( | 143 void EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus( |
| 145 const base::ListValue* args) { | 144 const base::ListValue* args) { |
| 146 CHECK_EQ(1U, args->GetSize()); | 145 CHECK_EQ(1U, args->GetSize()); |
| 147 const base::Value* callback_id; | 146 const base::Value* callback_id; |
| 148 CHECK(args->Get(0, &callback_id)); | 147 CHECK(args->Get(0, &callback_id)); |
| 149 ResolveJavascriptCallback(*callback_id, | 148 ResolveJavascriptCallback(*callback_id, |
| 150 base::StringValue(GetTurnOffFlowStatus())); | 149 base::StringValue(GetTurnOffFlowStatus())); |
| 151 } | 150 } |
| 152 | 151 |
| 153 void EasyUnlockSettingsHandler::HandleStartTurnOffFlow( | 152 void EasyUnlockSettingsHandler::HandleStartTurnOffFlow( |
| 154 const base::ListValue* args) { | 153 const base::ListValue* args) { |
| 155 EasyUnlockService::Get(profile_)->RunTurnOffFlow(); | 154 EasyUnlockService::Get(profile_)->RunTurnOffFlow(); |
| 156 } | 155 } |
| 157 | 156 |
| 158 void EasyUnlockSettingsHandler::HandleCancelTurnOffFlow( | 157 void EasyUnlockSettingsHandler::HandleCancelTurnOffFlow( |
| 159 const base::ListValue* args) { | 158 const base::ListValue* args) { |
| 160 EasyUnlockService::Get(profile_)->ResetTurnOffFlow(); | 159 EasyUnlockService::Get(profile_)->ResetTurnOffFlow(); |
| 161 } | 160 } |
| 162 | 161 |
| 163 } // namespace settings | 162 } // namespace settings |
| 164 } // namespace chromeos | 163 } // namespace chromeos |
| OLD | NEW |