| 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/cryptohome_web_ui_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chromeos/dbus/cryptohome_client.h" | 9 #include "chromeos/dbus/cryptohome_client.h" |
| 10 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 FROM_HERE, | 45 FROM_HERE, |
| 46 base::Bind(&crypto::IsTPMTokenReady, base::Closure()), | 46 base::Bind(&crypto::IsTPMTokenReady, base::Closure()), |
| 47 base::Bind(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread, | 47 base::Bind(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread, |
| 48 weak_ptr_factory_.GetWeakPtr())); | 48 weak_ptr_factory_.GetWeakPtr())); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread( | 51 void CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread( |
| 52 bool is_tpm_token_ready) { | 52 bool is_tpm_token_ready) { |
| 53 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 53 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 54 | 54 |
| 55 base::FundamentalValue is_tpm_token_ready_value(is_tpm_token_ready); | 55 base::Value is_tpm_token_ready_value(is_tpm_token_ready); |
| 56 SetCryptohomeProperty("is-tpm-token-ready", is_tpm_token_ready_value); | 56 SetCryptohomeProperty("is-tpm-token-ready", is_tpm_token_ready_value); |
| 57 } | 57 } |
| 58 | 58 |
| 59 BoolDBusMethodCallback CryptohomeWebUIHandler::GetCryptohomeBoolCallback( | 59 BoolDBusMethodCallback CryptohomeWebUIHandler::GetCryptohomeBoolCallback( |
| 60 const std::string& destination_id) { | 60 const std::string& destination_id) { |
| 61 return base::Bind(&CryptohomeWebUIHandler::OnCryptohomeBoolProperty, | 61 return base::Bind(&CryptohomeWebUIHandler::OnCryptohomeBoolProperty, |
| 62 weak_ptr_factory_.GetWeakPtr(), | 62 weak_ptr_factory_.GetWeakPtr(), |
| 63 destination_id); | 63 destination_id); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void CryptohomeWebUIHandler::OnCryptohomeBoolProperty( | 66 void CryptohomeWebUIHandler::OnCryptohomeBoolProperty( |
| 67 const std::string& destination_id, | 67 const std::string& destination_id, |
| 68 DBusMethodCallStatus call_status, | 68 DBusMethodCallStatus call_status, |
| 69 bool value) { | 69 bool value) { |
| 70 if (call_status != DBUS_METHOD_CALL_SUCCESS) | 70 if (call_status != DBUS_METHOD_CALL_SUCCESS) |
| 71 value = false; | 71 value = false; |
| 72 base::FundamentalValue fundamental_value(value); | 72 base::Value fundamental_value(value); |
| 73 SetCryptohomeProperty(destination_id, fundamental_value); | 73 SetCryptohomeProperty(destination_id, fundamental_value); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void CryptohomeWebUIHandler::SetCryptohomeProperty( | 76 void CryptohomeWebUIHandler::SetCryptohomeProperty( |
| 77 const std::string& destination_id, | 77 const std::string& destination_id, |
| 78 const base::Value& value) { | 78 const base::Value& value) { |
| 79 base::StringValue destination_id_value(destination_id); | 79 base::StringValue destination_id_value(destination_id); |
| 80 web_ui()->CallJavascriptFunctionUnsafe("SetCryptohomeProperty", | 80 web_ui()->CallJavascriptFunctionUnsafe("SetCryptohomeProperty", |
| 81 destination_id_value, value); | 81 destination_id_value, value); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace chromeos | 84 } // namespace chromeos |
| OLD | NEW |