| 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/input_window_dialog.h" | 5 #include "chrome/browser/ui/input_window_dialog.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 : delegate_(delegate), | 112 : delegate_(delegate), |
| 113 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)) { | 113 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)) { |
| 114 DCHECK(delegate_); | 114 DCHECK(delegate_); |
| 115 } | 115 } |
| 116 | 116 |
| 117 /////////////////////////////////////////////////////////////////////////////// | 117 /////////////////////////////////////////////////////////////////////////////// |
| 118 // ContentView, views::DialogDelegate implementation: | 118 // ContentView, views::DialogDelegate implementation: |
| 119 | 119 |
| 120 bool ContentView::IsDialogButtonEnabled( | 120 bool ContentView::IsDialogButtonEnabled( |
| 121 ui::MessageBoxFlags::DialogButton button) const { | 121 ui::MessageBoxFlags::DialogButton button) const { |
| 122 if (button == ui::MessageBoxFlags::DIALOGBUTTON_OK && | 122 if (button == ui::MessageBoxFlags::DIALOGBUTTON_OK) { |
| 123 !delegate_->delegate()->IsValid(text_field_->text())) { | 123 InputWindowDialog::InputTexts texts; |
| 124 return false; | 124 texts.push_back(text_field_->text()); |
| 125 if (!delegate_->delegate()->IsValid(texts)) { |
| 126 return false; |
| 127 } |
| 125 } | 128 } |
| 126 return true; | 129 return true; |
| 127 } | 130 } |
| 128 | 131 |
| 129 bool ContentView::Accept() { | 132 bool ContentView::Accept() { |
| 130 delegate_->delegate()->InputAccepted(text_field_->text()); | 133 InputWindowDialog::InputTexts texts; |
| 134 texts.push_back(text_field_->text()); |
| 135 delegate_->delegate()->InputAccepted(texts); |
| 131 return true; | 136 return true; |
| 132 } | 137 } |
| 133 | 138 |
| 134 bool ContentView::Cancel() { | 139 bool ContentView::Cancel() { |
| 135 delegate_->delegate()->InputCanceled(); | 140 delegate_->delegate()->InputCanceled(); |
| 136 return true; | 141 return true; |
| 137 } | 142 } |
| 138 | 143 |
| 139 void ContentView::DeleteDelegate() { | 144 void ContentView::DeleteDelegate() { |
| 140 delete delegate_; | 145 delete delegate_; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 233 |
| 229 void InputWindowDialogWin::Show() { | 234 void InputWindowDialogWin::Show() { |
| 230 window_->Show(); | 235 window_->Show(); |
| 231 } | 236 } |
| 232 | 237 |
| 233 void InputWindowDialogWin::Close() { | 238 void InputWindowDialogWin::Close() { |
| 234 window_->Close(); | 239 window_->Close(); |
| 235 } | 240 } |
| 236 | 241 |
| 237 // static | 242 // static |
| 238 InputWindowDialog* InputWindowDialog::Create(gfx::NativeWindow parent, | 243 InputWindowDialog* InputWindowDialog::Create( |
| 239 const string16& window_title, | 244 gfx::NativeWindow parent, |
| 240 const string16& label, | 245 const string16& window_title, |
| 241 const string16& contents, | 246 const LabelContentsPairs& label_contents_pairs, |
| 242 Delegate* delegate, | 247 Delegate* delegate, |
| 243 ButtonType type) { | 248 ButtonType type) { |
| 244 return new InputWindowDialogWin( | 249 DCHECK_EQ(1U, label_contents_pairs.size()); |
| 245 parent, window_title, label, contents, delegate); | 250 return new InputWindowDialogWin(parent, |
| 251 window_title, |
| 252 label_contents_pairs[0].first, |
| 253 label_contents_pairs[0].second, |
| 254 delegate); |
| 246 } | 255 } |
| OLD | NEW |