Commit 91c43ef9 authored by Yi Chou's avatar Yi Chou Committed by Commit Bot

Show has-reset-lock-permissions in chrome://cryptohome

BUG=b:155063317
TEST=Build ok.
TEST=open chrome://cryptohome and check the permission

Cq-Depend: chromium:2460975
Change-Id: I81aa0ba7a899d63a62528a7d0592132d9e2d8908
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2461977Reviewed-by: default avatarSatoru Takabayashi <satorux@chromium.org>
Commit-Queue: joe Chou <yich@google.com>
Cr-Commit-Position: refs/heads/master@{#818414}
parent 7eb17ca1
...@@ -36,7 +36,11 @@ ...@@ -36,7 +36,11 @@
<tr> <tr>
<td>Pkcs11IsTpmTokenReady</td> <td>Pkcs11IsTpmTokenReady</td>
<td id="pkcs11-is-tpm-token-ready"></td> <td id="pkcs11-is-tpm-token-ready"></td>
</tr> </tr>
<tr>
<td>HasResetLockPermissions</td>
<td id="has-reset-lock-permissions"></td>
</tr>
</table> </table>
<h3>crypto:</h3> <h3>crypto:</h3>
<table> <table>
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/values.h" #include "base/values.h"
#include "chromeos/dbus/cryptohome/cryptohome_client.h" #include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/cryptohome/rpc.pb.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
...@@ -39,6 +40,11 @@ void CryptohomeWebUIHandler::OnPageLoaded(const base::ListValue* args) { ...@@ -39,6 +40,11 @@ void CryptohomeWebUIHandler::OnPageLoaded(const base::ListValue* args) {
cryptohome_client->Pkcs11IsTpmTokenReady( cryptohome_client->Pkcs11IsTpmTokenReady(
GetCryptohomeBoolCallback("pkcs11-is-tpm-token-ready")); GetCryptohomeBoolCallback("pkcs11-is-tpm-token-ready"));
cryptohome_client->GetTpmStatus(
cryptohome::GetTpmStatusRequest(),
base::BindOnce(&CryptohomeWebUIHandler::OnCryptohomeTpmStatus,
weak_ptr_factory_.GetWeakPtr()));
content::GetIOThreadTaskRunner({})->PostTaskAndReplyWithResult( content::GetIOThreadTaskRunner({})->PostTaskAndReplyWithResult(
FROM_HERE, base::BindOnce(&crypto::IsTPMTokenReady, base::Closure()), FROM_HERE, base::BindOnce(&crypto::IsTPMTokenReady, base::Closure()),
base::BindOnce(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread, base::BindOnce(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread,
...@@ -59,6 +65,21 @@ DBusMethodCallback<bool> CryptohomeWebUIHandler::GetCryptohomeBoolCallback( ...@@ -59,6 +65,21 @@ DBusMethodCallback<bool> CryptohomeWebUIHandler::GetCryptohomeBoolCallback(
weak_ptr_factory_.GetWeakPtr(), destination_id); weak_ptr_factory_.GetWeakPtr(), destination_id);
} }
void CryptohomeWebUIHandler::OnCryptohomeTpmStatus(
base::Optional<cryptohome::BaseReply> reply) {
if (!reply.has_value() || reply->has_error() ||
!reply->HasExtension(cryptohome::GetTpmStatusReply::reply)) {
LOG(ERROR) << "TPM status request failed, error: "
<< (reply.has_value() && reply->has_error() ? reply->error()
: 0);
return;
}
auto reply_proto = reply->GetExtension(cryptohome::GetTpmStatusReply::reply);
SetCryptohomeProperty("has-reset-lock-permissions",
base::Value(reply_proto.has_reset_lock_permissions()));
}
void CryptohomeWebUIHandler::OnCryptohomeBoolProperty( void CryptohomeWebUIHandler::OnCryptohomeBoolProperty(
const std::string& destination_id, const std::string& destination_id,
base::Optional<bool> result) { base::Optional<bool> result) {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h" #include "base/optional.h"
#include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/dbus_method_call_status.h" #include "chromeos/dbus/dbus_method_call_status.h"
#include "content/public/browser/web_ui_message_handler.h" #include "content/public/browser/web_ui_message_handler.h"
...@@ -45,6 +46,9 @@ class CryptohomeWebUIHandler : public content::WebUIMessageHandler { ...@@ -45,6 +46,9 @@ class CryptohomeWebUIHandler : public content::WebUIMessageHandler {
void OnCryptohomeBoolProperty(const std::string& destination_id, void OnCryptohomeBoolProperty(const std::string& destination_id,
base::Optional<bool> result); base::Optional<bool> result);
// This method is called when Cryptohome D-Bus TpmStatus call complete.
void OnCryptohomeTpmStatus(base::Optional<cryptohome::BaseReply> reply);
// Sets textcontent of the element whose id is |destination_id| to |value|. // Sets textcontent of the element whose id is |destination_id| to |value|.
void SetCryptohomeProperty(const std::string& destination_id, void SetCryptohomeProperty(const std::string& destination_id,
const base::Value& value); const base::Value& value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment