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/callback.h" | 8 #include "base/callback.h" |
9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 UMA_HISTOGRAM_BOOLEAN("JSDialogs.IsForemost.Alert", foremost); | 126 UMA_HISTOGRAM_BOOLEAN("JSDialogs.IsForemost.Alert", foremost); |
127 break; | 127 break; |
128 case content::JAVASCRIPT_DIALOG_TYPE_CONFIRM: | 128 case content::JAVASCRIPT_DIALOG_TYPE_CONFIRM: |
129 UMA_HISTOGRAM_BOOLEAN("JSDialogs.IsForemost.Confirm", foremost); | 129 UMA_HISTOGRAM_BOOLEAN("JSDialogs.IsForemost.Confirm", foremost); |
130 break; | 130 break; |
131 case content::JAVASCRIPT_DIALOG_TYPE_PROMPT: | 131 case content::JAVASCRIPT_DIALOG_TYPE_PROMPT: |
132 UMA_HISTOGRAM_BOOLEAN("JSDialogs.IsForemost.Prompt", foremost); | 132 UMA_HISTOGRAM_BOOLEAN("JSDialogs.IsForemost.Prompt", foremost); |
133 break; | 133 break; |
134 } | 134 } |
135 | 135 |
136 // For security reasons, when a page requests a JavaScript dialog it forfeits | |
137 // fullscreen. http://crbug.com/670135 | |
138 parent_web_contents->GetDelegate()->ExitFullscreenModeForTab( | |
139 parent_web_contents); | |
meacer
2017/06/01 22:26:01
Drive by: Does this exit window-fullscreen (as opp
Avi (use Gerrit)
2017/06/01 22:49:33
No, this is only exiting html5 fullscreen, which i
| |
140 | |
136 if (IsEnabled()) { | 141 if (IsEnabled()) { |
137 if (!IsWebContentsForemost(parent_web_contents) && | 142 if (!IsWebContentsForemost(parent_web_contents) && |
138 dialog_type == content::JAVASCRIPT_DIALOG_TYPE_PROMPT) { | 143 dialog_type == content::JAVASCRIPT_DIALOG_TYPE_PROMPT) { |
139 // Don't allow "prompt" dialogs to steal the user's focus. TODO(avi): | 144 // Don't allow "prompt" dialogs to steal the user's focus. TODO(avi): |
140 // Eventually, for subsequent phases of http://bit.ly/project-oldspice, | 145 // Eventually, for subsequent phases of http://bit.ly/project-oldspice, |
141 // turn off focus stealing for other dialog types. | 146 // turn off focus stealing for other dialog types. |
142 *did_suppress_message = true; | 147 *did_suppress_message = true; |
143 alerting_web_contents->GetMainFrame()->AddMessageToConsole( | 148 alerting_web_contents->GetMainFrame()->AddMessageToConsole( |
144 content::CONSOLE_MESSAGE_LEVEL_WARNING, | 149 content::CONSOLE_MESSAGE_LEVEL_WARNING, |
145 "A window.prompt() dialog generated by this page was suppressed " | 150 "A window.prompt() dialog generated by this page was suppressed " |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 // - they are critical to the user not losing data | 238 // - they are critical to the user not losing data |
234 // - they can be requested for tabs that are not foremost | 239 // - they can be requested for tabs that are not foremost |
235 // - they can be requested for many tabs at the same time | 240 // - they can be requested for many tabs at the same time |
236 // and therefore auto-dismissal is inappropriate for them. | 241 // and therefore auto-dismissal is inappropriate for them. |
237 | 242 |
238 SiteEngagementService* site_engagement_service = SiteEngagementService::Get( | 243 SiteEngagementService* site_engagement_service = SiteEngagementService::Get( |
239 Profile::FromBrowserContext(web_contents->GetBrowserContext())); | 244 Profile::FromBrowserContext(web_contents->GetBrowserContext())); |
240 double engagement_score = | 245 double engagement_score = |
241 site_engagement_service->GetScore(web_contents->GetLastCommittedURL()); | 246 site_engagement_service->GetScore(web_contents->GetLastCommittedURL()); |
242 | 247 |
248 // For security reasons, when a page requests a JavaScript dialog it forfeits | |
249 // fullscreen. http://crbug.com/670135 | |
250 web_contents->GetDelegate()->ExitFullscreenModeForTab(web_contents); | |
251 | |
243 return AppModalDialogManager()->RunBeforeUnloadDialog( | 252 return AppModalDialogManager()->RunBeforeUnloadDialog( |
244 web_contents, is_reload, | 253 web_contents, is_reload, |
245 base::Bind(&SaveUnloadUmaStats, engagement_score, callback)); | 254 base::Bind(&SaveUnloadUmaStats, engagement_score, callback)); |
246 } | 255 } |
247 | 256 |
248 bool JavaScriptDialogTabHelper::HandleJavaScriptDialog( | 257 bool JavaScriptDialogTabHelper::HandleJavaScriptDialog( |
249 content::WebContents* web_contents, | 258 content::WebContents* web_contents, |
250 bool accept, | 259 bool accept, |
251 const base::string16* prompt_override) { | 260 const base::string16* prompt_override) { |
252 if (dialog_) { | 261 if (dialog_) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 dialog_callback_.Run(success, user_input); | 358 dialog_callback_.Run(success, user_input); |
350 | 359 |
351 ClearDialogInfo(); | 360 ClearDialogInfo(); |
352 } | 361 } |
353 | 362 |
354 void JavaScriptDialogTabHelper::ClearDialogInfo() { | 363 void JavaScriptDialogTabHelper::ClearDialogInfo() { |
355 dialog_.reset(); | 364 dialog_.reset(); |
356 dialog_callback_.Reset(); | 365 dialog_callback_.Reset(); |
357 BrowserList::RemoveObserver(this); | 366 BrowserList::RemoveObserver(this); |
358 } | 367 } |
OLD | NEW |