Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc

Issue 83833003: Remove crypto::GetTPMTokenInfo which is no longer necessary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove missed member Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h ('k') | chromeos/cert_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/web_ui.h" 12 #include "content/public/browser/web_ui.h"
13 #include "crypto/nss_util.h" 13 #include "crypto/nss_util.h"
14 14
15 using content::BrowserThread; 15 using content::BrowserThread;
16 16
17 namespace {
18 void GetNSSUtilInfoOnIOThread(const base::Callback<
19 void(bool, const std::string&, const std::string&)>& ui_callback) {
20 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
21
22 bool is_tpm_ready = crypto::IsTPMTokenReady();
23 std::string token_name;
24 std::string user_pin;
25 if (is_tpm_ready)
26 crypto::GetTPMTokenInfo(&token_name, &user_pin);
27
28 BrowserThread::PostTask(
29 BrowserThread::UI,
30 FROM_HERE,
31 base::Bind(ui_callback, is_tpm_ready, token_name, user_pin));
32 }
33 } // namespace
34
35 namespace chromeos { 17 namespace chromeos {
36 18
37 CryptohomeWebUIHandler::CryptohomeWebUIHandler() : weak_ptr_factory_(this) {} 19 CryptohomeWebUIHandler::CryptohomeWebUIHandler() : weak_ptr_factory_(this) {}
38 20
39 CryptohomeWebUIHandler::~CryptohomeWebUIHandler() {} 21 CryptohomeWebUIHandler::~CryptohomeWebUIHandler() {}
40 22
41 void CryptohomeWebUIHandler::RegisterMessages() { 23 void CryptohomeWebUIHandler::RegisterMessages() {
42 web_ui()->RegisterMessageCallback( 24 web_ui()->RegisterMessageCallback(
43 "pageLoaded", 25 "pageLoaded",
44 base::Bind(&CryptohomeWebUIHandler::OnPageLoaded, 26 base::Bind(&CryptohomeWebUIHandler::OnPageLoaded,
45 weak_ptr_factory_.GetWeakPtr())); 27 weak_ptr_factory_.GetWeakPtr()));
46 } 28 }
47 29
48 void CryptohomeWebUIHandler::OnPageLoaded(const base::ListValue* args) { 30 void CryptohomeWebUIHandler::OnPageLoaded(const base::ListValue* args) {
49 CryptohomeClient* cryptohome_client = 31 CryptohomeClient* cryptohome_client =
50 DBusThreadManager::Get()->GetCryptohomeClient(); 32 DBusThreadManager::Get()->GetCryptohomeClient();
51 33
52 cryptohome_client->IsMounted(GetCryptohomeBoolCallback("is-mounted")); 34 cryptohome_client->IsMounted(GetCryptohomeBoolCallback("is-mounted"));
53 cryptohome_client->TpmIsReady(GetCryptohomeBoolCallback("tpm-is-ready")); 35 cryptohome_client->TpmIsReady(GetCryptohomeBoolCallback("tpm-is-ready"));
54 cryptohome_client->TpmIsEnabled(GetCryptohomeBoolCallback("tpm-is-enabled")); 36 cryptohome_client->TpmIsEnabled(GetCryptohomeBoolCallback("tpm-is-enabled"));
55 cryptohome_client->TpmIsOwned(GetCryptohomeBoolCallback("tpm-is-owned")); 37 cryptohome_client->TpmIsOwned(GetCryptohomeBoolCallback("tpm-is-owned"));
56 cryptohome_client->TpmIsBeingOwned( 38 cryptohome_client->TpmIsBeingOwned(
57 GetCryptohomeBoolCallback("tpm-is-being-owned")); 39 GetCryptohomeBoolCallback("tpm-is-being-owned"));
58 cryptohome_client->Pkcs11IsTpmTokenReady( 40 cryptohome_client->Pkcs11IsTpmTokenReady(
59 GetCryptohomeBoolCallback("pkcs11-is-tpm-token-ready")); 41 GetCryptohomeBoolCallback("pkcs11-is-tpm-token-ready"));
60 42
61 BrowserThread::PostTask( 43 BrowserThread::PostTaskAndReplyWithResult(
62 BrowserThread::IO, 44 BrowserThread::IO,
63 FROM_HERE, 45 FROM_HERE,
64 base::Bind( 46 base::Bind(&crypto::IsTPMTokenReady),
65 &GetNSSUtilInfoOnIOThread, 47 base::Bind(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread,
66 base::Bind(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread, 48 weak_ptr_factory_.GetWeakPtr()));
67 weak_ptr_factory_.GetWeakPtr())));
68 } 49 }
69 50
70 void CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread( 51 void CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread(
71 bool is_tpm_token_ready, 52 bool is_tpm_token_ready) {
72 const std::string& token_name,
73 const std::string& user_pin) {
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
75 54
76 base::FundamentalValue is_tpm_token_ready_value(is_tpm_token_ready); 55 base::FundamentalValue is_tpm_token_ready_value(is_tpm_token_ready);
77 SetCryptohomeProperty("is-tpm-token-ready", is_tpm_token_ready_value); 56 SetCryptohomeProperty("is-tpm-token-ready", is_tpm_token_ready_value);
78
79 if (is_tpm_token_ready) {
80 base::StringValue token_name_value(token_name);
81 SetCryptohomeProperty("token-name", token_name_value);
82 // Hide user_pin.
83 base::StringValue user_pin_value(std::string(user_pin.length(), '*'));
84 SetCryptohomeProperty("user-pin", user_pin_value);
85 }
86 } 57 }
87 58
88 BoolDBusMethodCallback CryptohomeWebUIHandler::GetCryptohomeBoolCallback( 59 BoolDBusMethodCallback CryptohomeWebUIHandler::GetCryptohomeBoolCallback(
89 const std::string& destination_id) { 60 const std::string& destination_id) {
90 return base::Bind(&CryptohomeWebUIHandler::OnCryptohomeBoolProperty, 61 return base::Bind(&CryptohomeWebUIHandler::OnCryptohomeBoolProperty,
91 weak_ptr_factory_.GetWeakPtr(), 62 weak_ptr_factory_.GetWeakPtr(),
92 destination_id); 63 destination_id);
93 } 64 }
94 65
95 void CryptohomeWebUIHandler::OnCryptohomeBoolProperty( 66 void CryptohomeWebUIHandler::OnCryptohomeBoolProperty(
96 const std::string& destination_id, 67 const std::string& destination_id,
97 DBusMethodCallStatus call_status, 68 DBusMethodCallStatus call_status,
98 bool value) { 69 bool value) {
99 if (call_status != DBUS_METHOD_CALL_SUCCESS) 70 if (call_status != DBUS_METHOD_CALL_SUCCESS)
100 value = false; 71 value = false;
101 base::FundamentalValue fundamental_value(value); 72 base::FundamentalValue fundamental_value(value);
102 SetCryptohomeProperty(destination_id, fundamental_value); 73 SetCryptohomeProperty(destination_id, fundamental_value);
103 } 74 }
104 75
105 void CryptohomeWebUIHandler::SetCryptohomeProperty( 76 void CryptohomeWebUIHandler::SetCryptohomeProperty(
106 const std::string& destination_id, 77 const std::string& destination_id,
107 const base::Value& value) { 78 const base::Value& value) {
108 base::StringValue destination_id_value(destination_id); 79 base::StringValue destination_id_value(destination_id);
109 web_ui()->CallJavascriptFunction( 80 web_ui()->CallJavascriptFunction(
110 "SetCryptohomeProperty", destination_id_value, value); 81 "SetCryptohomeProperty", destination_id_value, value);
111 } 82 }
112 83
113 } // namespace chromeos 84 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h ('k') | chromeos/cert_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698