| 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" |
| 11 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 12 #include "chrome/browser/ui/webui/input_window_dialog_webui.h" |
| 11 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 13 #include "views/controls/label.h" | 15 #include "views/controls/label.h" |
| 14 #include "views/controls/textfield/textfield.h" | 16 #include "views/controls/textfield/textfield.h" |
| 15 #include "views/controls/textfield/textfield_controller.h" | 17 #include "views/controls/textfield/textfield_controller.h" |
| 16 #include "views/layout/grid_layout.h" | 18 #include "views/layout/grid_layout.h" |
| 17 #include "views/layout/layout_constants.h" | 19 #include "views/layout/layout_constants.h" |
| 18 #include "views/widget/widget.h" | 20 #include "views/widget/widget.h" |
| 19 #include "views/window/dialog_delegate.h" | 21 #include "views/window/dialog_delegate.h" |
| 20 | 22 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 string16 ContentView::GetDialogButtonLabel(ui::DialogButton button) const { | 128 string16 ContentView::GetDialogButtonLabel(ui::DialogButton button) const { |
| 127 if (button == ui::DIALOG_BUTTON_OK) { | 129 if (button == ui::DIALOG_BUTTON_OK) { |
| 128 return l10n_util::GetStringUTF16( | 130 return l10n_util::GetStringUTF16( |
| 129 delegate_->type() == InputWindowDialog::BUTTON_TYPE_ADD ? IDS_ADD | 131 delegate_->type() == InputWindowDialog::BUTTON_TYPE_ADD ? IDS_ADD |
| 130 : IDS_SAVE); | 132 : IDS_SAVE); |
| 131 } | 133 } |
| 132 return string16(); | 134 return string16(); |
| 133 } | 135 } |
| 134 | 136 |
| 135 bool ContentView::IsDialogButtonEnabled(ui::DialogButton button) const { | 137 bool ContentView::IsDialogButtonEnabled(ui::DialogButton button) const { |
| 136 if (button == ui::DIALOG_BUTTON_OK && | 138 if (button == ui::DIALOG_BUTTON_OK) { |
| 137 !delegate_->delegate()->IsValid(text_field_->text())) { | 139 InputWindowDialog::InputTexts texts; |
| 138 return false; | 140 texts.push_back(text_field_->text()); |
| 141 if (!delegate_->delegate()->IsValid(texts)) { |
| 142 return false; |
| 143 } |
| 139 } | 144 } |
| 140 return true; | 145 return true; |
| 141 } | 146 } |
| 142 | 147 |
| 143 bool ContentView::Accept() { | 148 bool ContentView::Accept() { |
| 144 delegate_->delegate()->InputAccepted(text_field_->text()); | 149 InputWindowDialog::InputTexts texts; |
| 150 texts.push_back(text_field_->text()); |
| 151 delegate_->delegate()->InputAccepted(texts); |
| 145 return true; | 152 return true; |
| 146 } | 153 } |
| 147 | 154 |
| 148 bool ContentView::Cancel() { | 155 bool ContentView::Cancel() { |
| 149 delegate_->delegate()->InputCanceled(); | 156 delegate_->delegate()->InputCanceled(); |
| 150 return true; | 157 return true; |
| 151 } | 158 } |
| 152 | 159 |
| 153 void ContentView::DeleteDelegate() { | 160 void ContentView::DeleteDelegate() { |
| 154 delete delegate_; | 161 delete delegate_; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 251 |
| 245 void InputWindowDialogWin::Show() { | 252 void InputWindowDialogWin::Show() { |
| 246 window_->Show(); | 253 window_->Show(); |
| 247 } | 254 } |
| 248 | 255 |
| 249 void InputWindowDialogWin::Close() { | 256 void InputWindowDialogWin::Close() { |
| 250 window_->Close(); | 257 window_->Close(); |
| 251 } | 258 } |
| 252 | 259 |
| 253 // static | 260 // static |
| 254 InputWindowDialog* InputWindowDialog::Create(gfx::NativeWindow parent, | 261 InputWindowDialog* InputWindowDialog::Create( |
| 255 const string16& window_title, | 262 gfx::NativeWindow parent, |
| 256 const string16& label, | 263 const string16& window_title, |
| 257 const string16& contents, | 264 const LabelContentsPairs& label_contents_pairs, |
| 258 Delegate* delegate, | 265 Delegate* delegate, |
| 259 ButtonType type) { | 266 ButtonType type) { |
| 260 return new InputWindowDialogWin(parent, window_title, label, contents, | 267 if (ChromeWebUI::IsMoreWebUI()) { |
| 261 delegate, type); | 268 return new InputWindowDialogWebUI(window_title, |
| 269 label_contents_pairs, |
| 270 delegate, |
| 271 type); |
| 272 } else { |
| 273 DCHECK_EQ(1U, label_contents_pairs.size()); |
| 274 return new InputWindowDialogWin(parent, |
| 275 window_title, |
| 276 label_contents_pairs[0].first, |
| 277 label_contents_pairs[0].second, |
| 278 delegate, |
| 279 type); |
| 280 } |
| 262 } | 281 } |
| OLD | NEW |