OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/crypto_module_password_dialog.h" | 5 #include "chrome/browser/ui/crypto_module_password_dialog.h" |
6 | 6 |
7 #include <pk11pub.h> | 7 #include <pk11pub.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
11 #include "net/base/crypto_module.h" | 11 #include "net/base/crypto_module.h" |
12 #include "net/base/x509_certificate.h" | 12 #include "net/base/x509_certificate.h" |
13 | 13 |
14 #if defined(OS_CHROMEOS) | 14 #if defined(OS_CHROMEOS) |
15 #include "base/nss_util.h" | 15 #include "crypto/nss_util.h" |
16 #endif | 16 #endif |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 bool ShouldShowDialog(const net::CryptoModule* module) { | 20 bool ShouldShowDialog(const net::CryptoModule* module) { |
21 // The wincx arg is unused since we don't call PK11_SetIsLoggedInFunc. | 21 // The wincx arg is unused since we don't call PK11_SetIsLoggedInFunc. |
22 return (PK11_NeedLogin(module->os_module_handle()) && | 22 return (PK11_NeedLogin(module->os_module_handle()) && |
23 !PK11_IsLoggedIn(module->os_module_handle(), NULL /* wincx */)); | 23 !PK11_IsLoggedIn(module->os_module_handle(), NULL /* wincx */)); |
24 } | 24 } |
25 | 25 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 retry_(PR_FALSE) { | 59 retry_(PR_FALSE) { |
60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
61 } | 61 } |
62 | 62 |
63 void SlotUnlocker::Start() { | 63 void SlotUnlocker::Start() { |
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
65 | 65 |
66 for (; current_ < modules_.size(); ++current_) { | 66 for (; current_ < modules_.size(); ++current_) { |
67 if (ShouldShowDialog(modules_[current_].get())) { | 67 if (ShouldShowDialog(modules_[current_].get())) { |
68 #if defined(OS_CHROMEOS) | 68 #if defined(OS_CHROMEOS) |
69 if (modules_[current_]->GetTokenName() == base::GetTPMTokenName()) { | 69 if (modules_[current_]->GetTokenName() == crypto::GetTPMTokenName()) { |
70 // The user PIN is a well known secret on this machine, and | 70 // The user PIN is a well known secret on this machine, and |
71 // the user didn't set it, so we need to fetch the value and | 71 // the user didn't set it, so we need to fetch the value and |
72 // supply it for them here. | 72 // supply it for them here. |
73 GotPassword(base::GetTPMUserPIN().c_str()); | 73 GotPassword(crypto::GetTPMUserPIN().c_str()); |
74 return; | 74 return; |
75 } | 75 } |
76 #endif | 76 #endif |
77 ShowCryptoModulePasswordDialog( | 77 ShowCryptoModulePasswordDialog( |
78 modules_[current_]->GetTokenName(), | 78 modules_[current_]->GetTokenName(), |
79 retry_, | 79 retry_, |
80 reason_, | 80 reason_, |
81 host_, | 81 host_, |
82 NewCallback(this, &SlotUnlocker::GotPassword)); | 82 NewCallback(this, &SlotUnlocker::GotPassword)); |
83 return; | 83 return; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 browser::CryptoModulePasswordReason reason, | 145 browser::CryptoModulePasswordReason reason, |
146 const std::string& host, | 146 const std::string& host, |
147 Callback0::Type* callback) { | 147 Callback0::Type* callback) { |
148 net::CryptoModuleList modules; | 148 net::CryptoModuleList modules; |
149 modules.push_back(net::CryptoModule::CreateFromHandle( | 149 modules.push_back(net::CryptoModule::CreateFromHandle( |
150 cert->os_cert_handle()->slot)); | 150 cert->os_cert_handle()->slot)); |
151 UnlockSlotsIfNecessary(modules, reason, host, callback); | 151 UnlockSlotsIfNecessary(modules, reason, host, callback); |
152 } | 152 } |
153 | 153 |
154 } // namespace browser | 154 } // namespace browser |
OLD | NEW |