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.h" | 5 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog.h" |
6 | 6 |
| 7 #include "chrome/browser/ui/blocked_content/app_modal_dialog_helper.h" |
7 #include "chrome/browser/ui/browser_dialogs.h" | 8 #include "chrome/browser/ui/browser_dialogs.h" |
8 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_cocoa.h" | 9 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_cocoa.h" |
9 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_views.h" | 10 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_views.h" |
| 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/browser/web_contents_delegate.h" |
| 13 |
| 14 JavaScriptDialog::JavaScriptDialog(content::WebContents* parent_web_contents) { |
| 15 dialog_helper_.reset(new AppModalDialogHelper(parent_web_contents)); |
| 16 parent_web_contents->GetDelegate()->ActivateContents(parent_web_contents); |
| 17 } |
10 | 18 |
11 JavaScriptDialog::~JavaScriptDialog() = default; | 19 JavaScriptDialog::~JavaScriptDialog() = default; |
12 | 20 |
13 base::WeakPtr<JavaScriptDialog> JavaScriptDialog::Create( | 21 base::WeakPtr<JavaScriptDialog> JavaScriptDialog::Create( |
14 content::WebContents* parent_web_contents, | 22 content::WebContents* parent_web_contents, |
15 content::WebContents* alerting_web_contents, | 23 content::WebContents* alerting_web_contents, |
16 const base::string16& title, | 24 const base::string16& title, |
17 content::JavaScriptMessageType message_type, | 25 content::JavaScriptMessageType message_type, |
18 const base::string16& message_text, | 26 const base::string16& message_text, |
19 const base::string16& default_prompt_text, | 27 const base::string16& default_prompt_text, |
20 const content::JavaScriptDialogManager::DialogClosedCallback& | 28 const content::JavaScriptDialogManager::DialogClosedCallback& |
21 dialog_callback) { | 29 dialog_callback) { |
22 if (chrome::ToolkitViewsWebUIDialogsEnabled()) { | 30 if (chrome::ToolkitViewsWebUIDialogsEnabled()) { |
23 return JavaScriptDialogViews::Create( | 31 return JavaScriptDialogViews::Create( |
24 parent_web_contents, alerting_web_contents, title, message_type, | 32 parent_web_contents, alerting_web_contents, title, message_type, |
25 message_text, default_prompt_text, dialog_callback); | 33 message_text, default_prompt_text, dialog_callback); |
26 } else { | 34 } else { |
27 return JavaScriptDialogCocoa::Create( | 35 return JavaScriptDialogCocoa::Create( |
28 parent_web_contents, alerting_web_contents, title, message_type, | 36 parent_web_contents, alerting_web_contents, title, message_type, |
29 message_text, default_prompt_text, dialog_callback); | 37 message_text, default_prompt_text, dialog_callback); |
30 } | 38 } |
31 } | 39 } |
OLD | NEW |