blob: 95798e2add3ca8d9fe4ebdad14680b01954daf59 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2013 The Chromium Authors
[email protected]7fc83822012-03-30 19:53:292// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]de7d61ff2013-08-20 11:30:415#include "content/shell/browser/shell_javascript_dialog.h"
[email protected]7fc83822012-03-30 19:53:296
Avi Drissmane04d3992017-10-05 15:11:367#include <utility>
8
[email protected]21aa99682013-06-11 07:17:019#include "base/strings/string_util.h"
Jan Wilken Dörrie86069892021-02-23 17:09:1310#include "base/strings/utf_string_conversions.h"
[email protected]993951d2013-05-08 21:37:0211#include "content/shell/app/resource.h"
[email protected]de7d61ff2013-08-20 11:30:4112#include "content/shell/browser/shell.h"
13#include "content/shell/browser/shell_javascript_dialog_manager.h"
[email protected]7fc83822012-03-30 19:53:2914
Bruce Dawsonbdea9d662021-06-23 17:34:1515#include <windows.h>
16
[email protected]7fc83822012-03-30 19:53:2917namespace content {
18
19class ShellJavaScriptDialog;
20
[email protected]be2510c02012-05-28 14:52:1421INT_PTR CALLBACK ShellJavaScriptDialog::DialogProc(HWND dialog,
22 UINT message,
[email protected]7fc83822012-03-30 19:53:2923 WPARAM wparam,
24 LPARAM lparam) {
25 switch (message) {
26 case WM_INITDIALOG: {
[email protected]3bed5302013-02-15 19:31:4127 SetWindowLongPtr(dialog, DWLP_USER, static_cast<LONG_PTR>(lparam));
[email protected]7fc83822012-03-30 19:53:2928 ShellJavaScriptDialog* owner =
29 reinterpret_cast<ShellJavaScriptDialog*>(lparam);
30 owner->dialog_win_ = dialog;
Jan Wilken Dörrie86069892021-02-23 17:09:1331 SetDlgItemText(dialog, IDC_DIALOGTEXT,
32 base::as_wcstr(owner->message_text_));
avi777ff452017-02-09 19:04:4833 if (owner->dialog_type_ == JAVASCRIPT_DIALOG_TYPE_PROMPT)
[email protected]7fc83822012-03-30 19:53:2934 SetDlgItemText(dialog, IDC_PROMPTEDIT,
Jan Wilken Dörrie86069892021-02-23 17:09:1335 base::as_wcstr(owner->default_prompt_text_));
[email protected]7fc83822012-03-30 19:53:2936 break;
37 }
38 case WM_DESTROY: {
39 ShellJavaScriptDialog* owner = reinterpret_cast<ShellJavaScriptDialog*>(
[email protected]3bed5302013-02-15 19:31:4140 GetWindowLongPtr(dialog, DWLP_USER));
[email protected]7fc83822012-03-30 19:53:2941 if (owner->dialog_win_) {
42 owner->dialog_win_ = 0;
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:5843 std::move(owner->callback_).Run(false, std::u16string());