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_tab_helper.h" | 5 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "chrome/browser/engagement/site_engagement_service.h" | 10 #include "chrome/browser/engagement/site_engagement_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_views.h" | |
15 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 14 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
17 #include "components/app_modal/javascript_dialog_manager.h" | 16 #include "components/app_modal/javascript_dialog_manager.h" |
18 #include "content/public/browser/web_contents_delegate.h" | 17 #include "content/public/browser/web_contents_delegate.h" |
19 | 18 |
20 DEFINE_WEB_CONTENTS_USER_DATA_KEY(JavaScriptDialogTabHelper); | 19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(JavaScriptDialogTabHelper); |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 const base::Feature kAutoDismissingDialogsFeature{ | 23 const base::Feature kAutoDismissingDialogsFeature{ |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // There's already a dialog up; clear it out. | 91 // There's already a dialog up; clear it out. |
93 CloseDialog(false, false, base::string16()); | 92 CloseDialog(false, false, base::string16()); |
94 } | 93 } |
95 | 94 |
96 parent_web_contents->GetDelegate()->ActivateContents(parent_web_contents); | 95 parent_web_contents->GetDelegate()->ActivateContents(parent_web_contents); |
97 | 96 |
98 base::string16 title = | 97 base::string16 title = |
99 AppModalDialogManager()->GetTitle(alerting_web_contents, origin_url); | 98 AppModalDialogManager()->GetTitle(alerting_web_contents, origin_url); |
100 dialog_callback_ = callback; | 99 dialog_callback_ = callback; |
101 BrowserList::AddObserver(this); | 100 BrowserList::AddObserver(this); |
102 // TODO(avi): abstract out so that we have a Mac version too... | 101 dialog_ = JavaScriptDialog::Create( |
103 dialog_ = JavaScriptDialogViews::Create( | |
104 parent_web_contents, alerting_web_contents, title, message_type, | 102 parent_web_contents, alerting_web_contents, title, message_type, |
105 message_text, default_prompt_text, callback); | 103 message_text, default_prompt_text, callback); |
106 | 104 |
107 // Message suppression is something that we don't give the user a checkbox | 105 // Message suppression is something that we don't give the user a checkbox |
108 // for any more. It was useful back in the day when dialogs were app-modal | 106 // for any more. It was useful back in the day when dialogs were app-modal |
109 // and clicking the checkbox was the only way to escape a loop that the page | 107 // and clicking the checkbox was the only way to escape a loop that the page |
110 // was doing, but now the user can just close the page. | 108 // was doing, but now the user can just close the page. |
111 *did_suppress_message = false; | 109 *did_suppress_message = false; |
112 } else { | 110 } else { |
113 AppModalDialogManager()->RunJavaScriptDialog( | 111 AppModalDialogManager()->RunJavaScriptDialog( |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 DCHECK(dialog_); | 202 DCHECK(dialog_); |
205 | 203 |
206 dialog_->CloseDialogWithoutCallback(); | 204 dialog_->CloseDialogWithoutCallback(); |
207 if (!suppress_callback) | 205 if (!suppress_callback) |
208 dialog_callback_.Run(success, user_input); | 206 dialog_callback_.Run(success, user_input); |
209 | 207 |
210 dialog_.reset(); | 208 dialog_.reset(); |
211 dialog_callback_.Reset(); | 209 dialog_callback_.Reset(); |
212 BrowserList::RemoveObserver(this); | 210 BrowserList::RemoveObserver(this); |
213 } | 211 } |
OLD | NEW |