| 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/crypto_module_password_dialog.h" | 5 #include "chrome/browser/ui/crypto_module_password_dialog.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "crypto/crypto_module_blocking_password_delegate.h" | 11 #include "crypto/crypto_module_blocking_password_delegate.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 | 16 |
| 17 using content::BrowserThread; | 17 using content::BrowserThread; |
| 18 | 18 |
| 19 namespace chrome { |
| 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 class CryptoModuleBlockingDialogDelegate | 23 class CryptoModuleBlockingDialogDelegate |
| 22 : public crypto::CryptoModuleBlockingPasswordDelegate { | 24 : public crypto::CryptoModuleBlockingPasswordDelegate { |
| 23 public: | 25 public: |
| 24 CryptoModuleBlockingDialogDelegate(browser::CryptoModulePasswordReason reason, | 26 CryptoModuleBlockingDialogDelegate(CryptoModulePasswordReason reason, |
| 25 const std::string& server) | 27 const std::string& server) |
| 26 : event_(false, false), | 28 : event_(false, false), |
| 27 reason_(reason), | 29 reason_(reason), |
| 28 server_(server), | 30 server_(server), |
| 29 cancelled_(false) { | 31 cancelled_(false) { |
| 30 } | 32 } |
| 31 | 33 |
| 32 virtual ~CryptoModuleBlockingDialogDelegate() { | 34 virtual ~CryptoModuleBlockingDialogDelegate() { |
| 33 // Make sure we clear the password in memory. | 35 // Make sure we clear the password in memory. |
| 34 password_.replace(0, password_.size(), password_.size(), 0); | 36 password_.replace(0, password_.size(), password_.size(), 0); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 72 |
| 71 void GotPassword(const char* password) { | 73 void GotPassword(const char* password) { |
| 72 if (password) | 74 if (password) |
| 73 password_ = password; | 75 password_ = password; |
| 74 else | 76 else |
| 75 cancelled_ = true; | 77 cancelled_ = true; |
| 76 event_.Signal(); | 78 event_.Signal(); |
| 77 } | 79 } |
| 78 | 80 |
| 79 base::WaitableEvent event_; | 81 base::WaitableEvent event_; |
| 80 browser::CryptoModulePasswordReason reason_; | 82 CryptoModulePasswordReason reason_; |
| 81 std::string server_; | 83 std::string server_; |
| 82 std::string password_; | 84 std::string password_; |
| 83 bool cancelled_; | 85 bool cancelled_; |
| 84 | 86 |
| 85 DISALLOW_COPY_AND_ASSIGN(CryptoModuleBlockingDialogDelegate); | 87 DISALLOW_COPY_AND_ASSIGN(CryptoModuleBlockingDialogDelegate); |
| 86 }; | 88 }; |
| 89 |
| 87 } // namespace | 90 } // namespace |
| 88 | 91 |
| 89 namespace browser { | |
| 90 | |
| 91 crypto::CryptoModuleBlockingPasswordDelegate* | 92 crypto::CryptoModuleBlockingPasswordDelegate* |
| 92 NewCryptoModuleBlockingDialogDelegate( | 93 NewCryptoModuleBlockingDialogDelegate(CryptoModulePasswordReason reason, |
| 93 CryptoModulePasswordReason reason, | 94 const std::string& server) { |
| 94 const std::string& server) { | |
| 95 return new CryptoModuleBlockingDialogDelegate(reason, server); | 95 return new CryptoModuleBlockingDialogDelegate(reason, server); |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace browser | 98 } // namespace chrome |
| OLD | NEW |