OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/javascript_dialogs/javascript_dialog_views.h" | 5 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_views.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "components/constrained_window/constrained_window_views.h" | 8 #include "components/constrained_window/constrained_window_views.h" |
9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
10 #include "ui/views/controls/message_box_view.h" | 10 #include "ui/views/controls/message_box_view.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 title, dialog_type, message_text, | 27 title, dialog_type, message_text, |
28 default_prompt_text, dialog_callback)) | 28 default_prompt_text, dialog_callback)) |
29 ->weak_factory_.GetWeakPtr(); | 29 ->weak_factory_.GetWeakPtr(); |
30 } | 30 } |
31 | 31 |
32 void JavaScriptDialogViews::CloseDialogWithoutCallback() { | 32 void JavaScriptDialogViews::CloseDialogWithoutCallback() { |
33 dialog_callback_.Reset(); | 33 dialog_callback_.Reset(); |
34 GetWidget()->Close(); | 34 GetWidget()->Close(); |
35 } | 35 } |
36 | 36 |
| 37 base::string16 JavaScriptDialogViews::GetUserInput() { |
| 38 return message_box_view_->GetInputText(); |
| 39 } |
| 40 |
37 int JavaScriptDialogViews::GetDefaultDialogButton() const { | 41 int JavaScriptDialogViews::GetDefaultDialogButton() const { |
38 return ui::DIALOG_BUTTON_OK; | 42 return ui::DIALOG_BUTTON_OK; |
39 } | 43 } |
40 | 44 |
41 int JavaScriptDialogViews::GetDialogButtons() const { | 45 int JavaScriptDialogViews::GetDialogButtons() const { |
42 const bool is_alert = dialog_type_ == content::JAVASCRIPT_DIALOG_TYPE_ALERT; | 46 const bool is_alert = dialog_type_ == content::JAVASCRIPT_DIALOG_TYPE_ALERT; |
43 return ui::DIALOG_BUTTON_OK | (is_alert ? 0 : ui::DIALOG_BUTTON_CANCEL); | 47 return ui::DIALOG_BUTTON_OK | (is_alert ? 0 : ui::DIALOG_BUTTON_CANCEL); |
44 } | 48 } |
45 | 49 |
46 base::string16 JavaScriptDialogViews::GetWindowTitle() const { | 50 base::string16 JavaScriptDialogViews::GetWindowTitle() const { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 options |= views::MessageBoxView::HAS_PROMPT_FIELD; | 115 options |= views::MessageBoxView::HAS_PROMPT_FIELD; |
112 | 116 |
113 views::MessageBoxView::InitParams params(message_text); | 117 views::MessageBoxView::InitParams params(message_text); |
114 params.options = options; | 118 params.options = options; |
115 params.default_prompt = default_prompt_text; | 119 params.default_prompt = default_prompt_text; |
116 message_box_view_ = new views::MessageBoxView(params); | 120 message_box_view_ = new views::MessageBoxView(params); |
117 DCHECK(message_box_view_); | 121 DCHECK(message_box_view_); |
118 | 122 |
119 constrained_window::ShowWebModalDialogViews(this, parent_web_contents); | 123 constrained_window::ShowWebModalDialogViews(this, parent_web_contents); |
120 } | 124 } |
OLD | NEW |