Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors |
[email protected] | 7fc8382 | 2012-03-30 19:53:29 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | de7d61ff | 2013-08-20 11:30:41 | [diff] [blame] | 5 | #include "content/shell/browser/shell_javascript_dialog.h" |
[email protected] | 7fc8382 | 2012-03-30 19:53:29 | [diff] [blame] | 6 | |
Avi Drissman | e04d399 | 2017-10-05 15:11:36 | [diff] [blame] | 7 | #include <utility> |
| 8 | |
[email protected] | 21aa9968 | 2013-06-11 07:17:01 | [diff] [blame] | 9 | #include "base/strings/string_util.h" |
Jan Wilken Dörrie | 8606989 | 2021-02-23 17:09:13 | [diff] [blame] | 10 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 993951d | 2013-05-08 21:37:02 | [diff] [blame] | 11 | #include "content/shell/app/resource.h" |
[email protected] | de7d61ff | 2013-08-20 11:30:41 | [diff] [blame] | 12 | #include "content/shell/browser/shell.h" |
| 13 | #include "content/shell/browser/shell_javascript_dialog_manager.h" |
[email protected] | 7fc8382 | 2012-03-30 19:53:29 | [diff] [blame] | 14 | |
Bruce Dawson | bdea9d66 | 2021-06-23 17:34:15 | [diff] [blame] | 15 | #include <windows.h> |
| 16 | |
[email protected] | 7fc8382 | 2012-03-30 19:53:29 | [diff] [blame] | 17 | namespace content { |
| 18 | |
| 19 | class ShellJavaScriptDialog; |
| 20 | |
[email protected] | be2510c0 | 2012-05-28 14:52:14 | [diff] [blame] | 21 | INT_PTR CALLBACK ShellJavaScriptDialog::DialogProc(HWND dialog, |
| 22 | UINT message, |
[email protected] | 7fc8382 | 2012-03-30 19:53:29 | [diff] [blame] | 23 | WPARAM wparam, |
| 24 | LPARAM lparam) { |
| 25 | switch (message) { |
| 26 | case WM_INITDIALOG: { |
[email protected] | 3bed530 | 2013-02-15 19:31:41 | [diff] [blame] | 27 | SetWindowLongPtr(dialog, DWLP_USER, static_cast<LONG_PTR>(lparam)); |
[email protected] | 7fc8382 | 2012-03-30 19:53:29 | [diff] [blame] | 28 | ShellJavaScriptDialog* owner = |
| 29 | reinterpret_cast<ShellJavaScriptDialog*>(lparam); |
| 30 | owner->dialog_win_ = dialog; |
Jan Wilken Dörrie | 8606989 | 2021-02-23 17:09:13 | [diff] [blame] | 31 | SetDlgItemText(dialog, IDC_DIALOGTEXT, |
| 32 | base::as_wcstr(owner->message_text_)); |
avi | 777ff45 | 2017-02-09 19:04:48 | [diff] [blame] | 33 | if (owner->dialog_type_ == JAVASCRIPT_DIALOG_TYPE_PROMPT) |
[email protected] | 7fc8382 | 2012-03-30 19:53:29 | [diff] [blame] | 34 | SetDlgItemText(dialog, IDC_PROMPTEDIT, |
Jan Wilken Dörrie | 8606989 | 2021-02-23 17:09:13 | [diff] [blame] | 35 | base::as_wcstr(owner->default_prompt_text_)); |
[email protected] | 7fc8382 | 2012-03-30 19:53:29 | [diff] [blame] | 36 | break; |
| 37 | } |
| 38 | case WM_DESTROY: { |
| 39 | ShellJavaScriptDialog* owner = reinterpret_cast<ShellJavaScriptDialog*>( |
[email protected] | 3bed530 | 2013-02-15 19:31:41 | [diff] [blame] | 40 | GetWindowLongPtr(dialog, DWLP_USER)); |
[email protected] | 7fc8382 | 2012-03-30 19:53:29 | [diff] [blame] | 41 | if (owner->dialog_win_) { |
| 42 | owner->dialog_win_ = 0; |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 43 | std::move(owner->callback_).Run(false, std::u16string()); |
|