OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell_javascript_dialog.h" | 5 #include "content/shell/browser/shell_javascript_dialog.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "content/shell/app/resource.h" | 8 #include "content/shell/app/resource.h" |
9 #include "content/shell/browser/shell.h" | 9 #include "content/shell/browser/shell.h" |
10 #include "content/shell/browser/shell_javascript_dialog_manager.h" | 10 #include "content/shell/browser/shell_javascript_dialog_manager.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 return 0; | 75 return 0; |
76 } | 76 } |
77 | 77 |
78 ShellJavaScriptDialog::ShellJavaScriptDialog( | 78 ShellJavaScriptDialog::ShellJavaScriptDialog( |
79 ShellJavaScriptDialogManager* manager, | 79 ShellJavaScriptDialogManager* manager, |
80 gfx::NativeWindow parent_window, | 80 gfx::NativeWindow parent_window, |
81 JavaScriptMessageType message_type, | 81 JavaScriptMessageType message_type, |
82 const base::string16& message_text, | 82 const base::string16& message_text, |
83 const base::string16& default_prompt_text, | 83 const base::string16& default_prompt_text, |
84 const JavaScriptDialogManager::DialogClosedCallback& callback) | 84 const JavaScriptDialogManager::DialogClosedCallback& callback) |
85 : manager_(manager), | 85 : callback_(callback), |
86 callback_(callback), | 86 manager_(manager), |
87 message_type_(message_type), | 87 message_type_(message_type), |
88 message_text_(message_text), | 88 message_text_(message_text), |
89 default_prompt_text_(default_prompt_text) { | 89 default_prompt_text_(default_prompt_text) { |
90 int dialog_type; | 90 int dialog_type; |
91 if (message_type == JAVASCRIPT_MESSAGE_TYPE_ALERT) | 91 if (message_type == JAVASCRIPT_MESSAGE_TYPE_ALERT) |
92 dialog_type = IDD_ALERT; | 92 dialog_type = IDD_ALERT; |
93 else if (message_type == JAVASCRIPT_MESSAGE_TYPE_CONFIRM) | 93 else if (message_type == JAVASCRIPT_MESSAGE_TYPE_CONFIRM) |
94 dialog_type = IDD_CONFIRM; | 94 dialog_type = IDD_CONFIRM; |
95 else // JAVASCRIPT_MESSAGE_TYPE_PROMPT | 95 else // JAVASCRIPT_MESSAGE_TYPE_PROMPT |
96 dialog_type = IDD_PROMPT; | 96 dialog_type = IDD_PROMPT; |
97 | 97 |
98 dialog_win_ = CreateDialogParam(GetModuleHandle(0), | 98 dialog_win_ = CreateDialogParam(GetModuleHandle(0), |
99 MAKEINTRESOURCE(dialog_type), 0, DialogProc, | 99 MAKEINTRESOURCE(dialog_type), 0, DialogProc, |
100 reinterpret_cast<LPARAM>(this)); | 100 reinterpret_cast<LPARAM>(this)); |
101 ShowWindow(dialog_win_, SW_SHOWNORMAL); | 101 ShowWindow(dialog_win_, SW_SHOWNORMAL); |
102 } | 102 } |
103 | 103 |
104 ShellJavaScriptDialog::~ShellJavaScriptDialog() { | 104 ShellJavaScriptDialog::~ShellJavaScriptDialog() { |
105 Cancel(); | 105 Cancel(); |
106 } | 106 } |
107 | 107 |
108 void ShellJavaScriptDialog::Cancel() { | 108 void ShellJavaScriptDialog::Cancel() { |
109 if (dialog_win_) | 109 if (dialog_win_) |
110 DestroyWindow(dialog_win_); | 110 DestroyWindow(dialog_win_); |
111 } | 111 } |
112 | 112 |
113 } // namespace content | 113 } // namespace content |
OLD | NEW |