| Index: chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
|
| diff --git a/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc b/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
|
| index 3c129ddf63df97801ae902bdb359207226d48ff3..299623b1fe9be6c4ade868ed6db2f72460474f78 100644
|
| --- a/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
|
| +++ b/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
|
| @@ -14,7 +14,6 @@
|
| #include "chrome/browser/ui/browser_list.h"
|
| #include "chrome/browser/ui/tab_modal_confirm_dialog.h"
|
| #include "chrome/browser/ui/tabs/tab_strip_model.h"
|
| -#include "chrome/common/chrome_features.h"
|
| #include "components/app_modal/javascript_dialog_manager.h"
|
| #include "content/public/browser/navigation_handle.h"
|
| #include "content/public/browser/render_frame_host.h"
|
| @@ -24,10 +23,6 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(JavaScriptDialogTabHelper);
|
|
|
| namespace {
|
|
|
| -bool IsEnabled() {
|
| - return base::FeatureList::IsEnabled(features::kAutoDismissingDialogs);
|
| -}
|
| -
|
| app_modal::JavaScriptDialogManager* AppModalDialogManager() {
|
| return app_modal::JavaScriptDialogManager::GetInstance();
|
| }
|
| @@ -133,70 +128,64 @@ void JavaScriptDialogTabHelper::RunJavaScriptDialog(
|
| break;
|
| }
|
|
|
| - if (IsEnabled()) {
|
| - if (!IsWebContentsForemost(parent_web_contents) &&
|
| - dialog_type == content::JAVASCRIPT_DIALOG_TYPE_PROMPT) {
|
| - // Don't allow "prompt" dialogs to steal the user's focus. TODO(avi):
|
| - // Eventually, for subsequent phases of http://bit.ly/project-oldspice,
|
| - // turn off focus stealing for other dialog types.
|
| - *did_suppress_message = true;
|
| - alerting_web_contents->GetMainFrame()->AddMessageToConsole(
|
| - content::CONSOLE_MESSAGE_LEVEL_WARNING,
|
| - "A window.prompt() dialog generated by this page was suppressed "
|
| - "because this page is not the active tab of the front window. "
|
| - "Please make sure your dialogs are triggered by user interactions "
|
| - "to avoid this situation. "
|
| - "https://www.chromestatus.com/feature/5637107137642496");
|
| - return;
|
| - }
|
| -
|
| - if (dialog_) {
|
| - // There's already a dialog up; clear it out.
|
| - CloseDialog(false, base::string16(),
|
| - DismissalCause::SUBSEQUENT_DIALOG_SHOWN);
|
| - }
|
| -
|
| - // Enforce sane sizes. ElideRectangleString breaks horizontally, which isn't
|
| - // strictly needed, but it restricts the vertical size, which is crucial.
|
| - // This gives about 2000 characters, which is about the same as the
|
| - // AppModalDialogManager provides, but allows no more than 24 lines.
|
| - const int kMessageTextMaxRows = 24;
|
| - const int kMessageTextMaxCols = 80;
|
| - const size_t kDefaultPromptMaxSize = 2000;
|
| - base::string16 truncated_message_text;
|
| - gfx::ElideRectangleString(message_text, kMessageTextMaxRows,
|
| - kMessageTextMaxCols, false,
|
| - &truncated_message_text);
|
| - base::string16 truncated_default_prompt_text;
|
| - gfx::ElideString(default_prompt_text, kDefaultPromptMaxSize,
|
| - &truncated_default_prompt_text);
|
| -
|
| - base::string16 title =
|
| - AppModalDialogManager()->GetTitle(alerting_web_contents, origin_url);
|
| - dialog_callback_ = callback;
|
| - dialog_type_ = dialog_type;
|
| - dialog_ = JavaScriptDialog::Create(
|
| - parent_web_contents, alerting_web_contents, title, dialog_type,
|
| - truncated_message_text, truncated_default_prompt_text,
|
| - base::Bind(&JavaScriptDialogTabHelper::OnDialogClosed,
|
| - base::Unretained(this), callback));
|
| -
|
| - BrowserList::AddObserver(this);
|
| -
|
| - // Message suppression is something that we don't give the user a checkbox
|
| - // for any more. It was useful back in the day when dialogs were app-modal
|
| - // and clicking the checkbox was the only way to escape a loop that the page
|
| - // was doing, but now the user can just close the page.
|
| - *did_suppress_message = false;
|
| -
|
| - if (!dialog_shown_.is_null()) {
|
| - dialog_shown_.Run();
|
| - dialog_shown_.Reset();
|
| - }
|
| - } else {
|
| - AppModalDialogManager()->RunJavaScriptDialog(
|
| - alerting_web_contents, origin_url, dialog_type, message_text,
|
| - default_prompt_text, callback, did_suppress_message);
|
| + if (!IsWebContentsForemost(parent_web_contents) &&
|
| + dialog_type == content::JAVASCRIPT_DIALOG_TYPE_PROMPT) {
|
| + // Don't allow "prompt" dialogs to steal the user's focus. TODO(avi):
|
| + // Eventually, for subsequent phases of http://bit.ly/project-oldspice,
|
| + // turn off focus stealing for other dialog types.
|
| + *did_suppress_message = true;
|
| + alerting_web_contents->GetMainFrame()->AddMessageToConsole(
|
| + content::CONSOLE_MESSAGE_LEVEL_WARNING,
|
| + "A window.prompt() dialog generated by this page was suppressed "
|
| + "because this page is not the active tab of the front window. "
|
| + "Please make sure your dialogs are triggered by user interactions "
|
| + "to avoid this situation. "
|
| + "https://www.chromestatus.com/feature/5637107137642496");
|
| + return;
|
| + }
|
| +
|
| + if (dialog_) {
|
| + // There's already a dialog up; clear it out.
|
| + CloseDialog(false, base::string16(),
|
| + DismissalCause::SUBSEQUENT_DIALOG_SHOWN);
|
| + }
|
| +
|
| + // Enforce sane sizes. ElideRectangleString breaks horizontally, which isn't
|
| + // strictly needed, but it restricts the vertical size, which is crucial.
|
| + // This gives about 2000 characters, which is about the same as the
|
| + // AppModalDialogManager provides, but allows no more than 24 lines.
|
| + const int kMessageTextMaxRows = 24;
|
| + const int kMessageTextMaxCols = 80;
|
| + const size_t kDefaultPromptMaxSize = 2000;
|
| + base::string16 truncated_message_text;
|
| + gfx::ElideRectangleString(message_text, kMessageTextMaxRows,
|
| + kMessageTextMaxCols, false,
|
| + &truncated_message_text);
|
| + base::string16 truncated_default_prompt_text;
|
| + gfx::ElideString(default_prompt_text, kDefaultPromptMaxSize,
|
| + &truncated_default_prompt_text);
|
| +
|
| + base::string16 title =
|
| + AppModalDialogManager()->GetTitle(alerting_web_contents, origin_url);
|
| + dialog_callback_ = callback;
|
| + dialog_type_ = dialog_type;
|
| + dialog_ = JavaScriptDialog::Create(
|
| + parent_web_contents, alerting_web_contents, title, dialog_type,
|
| + truncated_message_text, truncated_default_prompt_text,
|
| + base::Bind(&JavaScriptDialogTabHelper::OnDialogClosed,
|
| + base::Unretained(this), callback));
|
| +
|
| + BrowserList::AddObserver(this);
|
| +
|
| + // Message suppression is something that we don't give the user a checkbox
|
| + // for any more. It was useful back in the day when dialogs were app-modal
|
| + // and clicking the checkbox was the only way to escape a loop that the page
|
| + // was doing, but now the user can just close the page.
|
| + *did_suppress_message = false;
|
| +
|
| + if (!dialog_shown_.is_null()) {
|
| + dialog_shown_.Run();
|
| + dialog_shown_.Reset();
|
| }
|
|
|
| if (did_suppress_message) {
|
|
|