| 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 <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/ui/gtk/gtk_util.h" | 11 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 12 #include "crypto/crypto_module_blocking_password_delegate.h" | |
| 13 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
| 14 #include "ui/base/gtk/gtk_hig_constants.h" | 13 #include "ui/base/gtk/gtk_hig_constants.h" |
| 15 #include "ui/base/gtk/gtk_signal.h" | 14 #include "ui/base/gtk/gtk_signal.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 // TODO(mattm): change into a constrained dialog. | 20 // TODO(mattm): change into a constrained dialog. |
| 22 class CryptoModulePasswordDialog { | 21 class CryptoModulePasswordDialog { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 129 |
| 131 void CryptoModulePasswordDialog::Show() { | 130 void CryptoModulePasswordDialog::Show() { |
| 132 gtk_util::ShowDialog(dialog_); | 131 gtk_util::ShowDialog(dialog_); |
| 133 } | 132 } |
| 134 | 133 |
| 135 void CryptoModulePasswordDialog::OnResponse(GtkWidget* dialog, | 134 void CryptoModulePasswordDialog::OnResponse(GtkWidget* dialog, |
| 136 int response_id) { | 135 int response_id) { |
| 137 if (response_id == GTK_RESPONSE_ACCEPT) | 136 if (response_id == GTK_RESPONSE_ACCEPT) |
| 138 callback_.Run(gtk_entry_get_text(GTK_ENTRY(password_entry_))); | 137 callback_.Run(gtk_entry_get_text(GTK_ENTRY(password_entry_))); |
| 139 else | 138 else |
| 140 callback_.Run(static_cast<const char*>(NULL)); | 139 callback_.Run(std::string()); |
| 141 | 140 |
| 142 // This will cause gtk to zero out the buffer. (see | 141 // This will cause gtk to zero out the buffer. (see |
| 143 // gtk_entry_buffer_normal_delete_text: | 142 // gtk_entry_buffer_normal_delete_text: |
| 144 // http://git.gnome.org/browse/gtk+/tree/gtk/gtkentrybuffer.c#n187) | 143 // http://git.gnome.org/browse/gtk+/tree/gtk/gtkentrybuffer.c#n187) |
| 145 gtk_editable_delete_text(GTK_EDITABLE(password_entry_), 0, -1); | 144 gtk_editable_delete_text(GTK_EDITABLE(password_entry_), 0, -1); |
| 146 gtk_widget_destroy(dialog_); | 145 gtk_widget_destroy(dialog_); |
| 147 } | 146 } |
| 148 | 147 |
| 149 void CryptoModulePasswordDialog::OnWindowDestroy(GtkWidget* widget) { | 148 void CryptoModulePasswordDialog::OnWindowDestroy(GtkWidget* widget) { |
| 150 delete this; | 149 delete this; |
| 151 } | 150 } |
| 152 | 151 |
| 153 } // namespace | 152 } // namespace |
| 154 | 153 |
| 155 namespace chrome { | 154 namespace chrome { |
| 156 | 155 |
| 157 void ShowCryptoModulePasswordDialog( | 156 void ShowCryptoModulePasswordDialog( |
| 158 const std::string& slot_name, | 157 const std::string& slot_name, |
| 159 bool retry, | 158 bool retry, |
| 160 CryptoModulePasswordReason reason, | 159 CryptoModulePasswordReason reason, |
| 161 const std::string& server, | 160 const std::string& server, |
| 162 gfx::NativeWindow parent, | 161 gfx::NativeWindow parent, |
| 163 const CryptoModulePasswordCallback& callback) { | 162 const CryptoModulePasswordCallback& callback) { |
| 164 (new CryptoModulePasswordDialog( | 163 (new CryptoModulePasswordDialog( |
| 165 slot_name, retry, reason, server, parent, callback))->Show(); | 164 slot_name, retry, reason, server, parent, callback))->Show(); |
| 166 } | 165 } |
| 167 | 166 |
| 168 } // namespace chrome | 167 } // namespace chrome |
| OLD | NEW |