| 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 <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/crypto/crypto_module_blocking_password_delegate.h" | |
| 11 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/task.h" | 11 #include "base/task.h" |
| 13 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "crypto/crypto_module_blocking_password_delegate.h" |
| 14 #include "chrome/browser/ui/gtk/gtk_util.h" | 14 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 15 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.h" |
| 16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "ui/base/gtk/gtk_signal.h" | 18 #include "ui/base/gtk/gtk_signal.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class CryptoModuleBlockingDialogDelegate | 23 class CryptoModuleBlockingDialogDelegate |
| 24 : public base::CryptoModuleBlockingPasswordDelegate { | 24 : public crypto::CryptoModuleBlockingPasswordDelegate { |
| 25 public: | 25 public: |
| 26 CryptoModuleBlockingDialogDelegate(browser::CryptoModulePasswordReason reason, | 26 CryptoModuleBlockingDialogDelegate(browser::CryptoModulePasswordReason reason, |
| 27 const std::string& server) | 27 const std::string& server) |
| 28 : event_(false, false), | 28 : event_(false, false), |
| 29 reason_(reason), | 29 reason_(reason), |
| 30 server_(server), | 30 server_(server), |
| 31 password_(), | 31 password_(), |
| 32 cancelled_(false) { | 32 cancelled_(false) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 ~CryptoModuleBlockingDialogDelegate() { | 35 ~CryptoModuleBlockingDialogDelegate() { |
| 36 password_.replace(0, password_.size(), password_.size(), 0); | 36 password_.replace(0, password_.size(), password_.size(), 0); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // base::CryptoModuleBlockingDialogDelegate implementation. | 39 // crypto::CryptoModuleBlockingDialogDelegate implementation. |
| 40 virtual std::string RequestPassword(const std::string& slot_name, bool retry, | 40 virtual std::string RequestPassword(const std::string& slot_name, bool retry, |
| 41 bool* cancelled) { | 41 bool* cancelled) { |
| 42 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 42 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 43 DCHECK(!event_.IsSignaled()); | 43 DCHECK(!event_.IsSignaled()); |
| 44 event_.Reset(); | 44 event_.Reset(); |
| 45 if (BrowserThread::PostTask( | 45 if (BrowserThread::PostTask( |
| 46 BrowserThread::UI, FROM_HERE, | 46 BrowserThread::UI, FROM_HERE, |
| 47 NewRunnableMethod(this, | 47 NewRunnableMethod(this, |
| 48 &CryptoModuleBlockingDialogDelegate::ShowDialog, | 48 &CryptoModuleBlockingDialogDelegate::ShowDialog, |
| 49 slot_name, | 49 slot_name, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 void ShowCryptoModulePasswordDialog(const std::string& slot_name, | 214 void ShowCryptoModulePasswordDialog(const std::string& slot_name, |
| 215 bool retry, | 215 bool retry, |
| 216 CryptoModulePasswordReason reason, | 216 CryptoModulePasswordReason reason, |
| 217 const std::string& server, | 217 const std::string& server, |
| 218 CryptoModulePasswordCallback* callback) { | 218 CryptoModulePasswordCallback* callback) { |
| 219 (new CryptoModulePasswordDialog(slot_name, retry, reason, server, | 219 (new CryptoModulePasswordDialog(slot_name, retry, reason, server, |
| 220 callback))->Show(); | 220 callback))->Show(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 base::CryptoModuleBlockingPasswordDelegate* | 223 crypto::CryptoModuleBlockingPasswordDelegate* |
| 224 NewCryptoModuleBlockingDialogDelegate( | 224 NewCryptoModuleBlockingDialogDelegate( |
| 225 CryptoModulePasswordReason reason, | 225 CryptoModulePasswordReason reason, |
| 226 const std::string& server) { | 226 const std::string& server) { |
| 227 return new CryptoModuleBlockingDialogDelegate(reason, server); | 227 return new CryptoModuleBlockingDialogDelegate(reason, server); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace browser | 230 } // namespace browser |
| OLD | NEW |