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