diff options
author | mkwst <mkwst@chromium.org> | 2014-10-08 08:09:01 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-08 15:09:24 +0000 |
commit | 6efe7f2e63509864dc9378a7af86721aecd8e15e (patch) | |
tree | 8d4b93e1c05f465dee14e2605aadf96dfb096a62 | |
parent | 4856559a13b5bc030d09c7ff385014528823d1f8 (diff) | |
download | chromium_src-6efe7f2e63509864dc9378a7af86721aecd8e15e.zip chromium_src-6efe7f2e63509864dc9378a7af86721aecd8e15e.tar.gz chromium_src-6efe7f2e63509864dc9378a7af86721aecd8e15e.tar.bz2 |
Content Shell: LayoutTestJavaScriptDialogManager
This moves the DRT-specific parts of ShellJavaScriptDialogManager to a
new, layout-test-only class.
BUG=420994
R=jochen@chromium.org
Review URL: https://codereview.chromium.org/639743002
Cr-Commit-Position: refs/heads/master@{#298709}
-rw-r--r-- | content/content_shell.gypi | 2 | ||||
-rw-r--r-- | content/shell/BUILD.gn | 2 | ||||
-rw-r--r-- | content/shell/browser/layout_test/layout_test_javascript_dialog_manager.cc | 46 | ||||
-rw-r--r-- | content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h | 43 | ||||
-rw-r--r-- | content/shell/browser/shell.cc | 9 | ||||
-rw-r--r-- | content/shell/browser/shell_javascript_dialog_manager.cc | 10 |
6 files changed, 100 insertions, 12 deletions
diff --git a/content/content_shell.gypi b/content/content_shell.gypi index 674da16..db80972 100644 --- a/content/content_shell.gypi +++ b/content/content_shell.gypi @@ -92,6 +92,8 @@ 'shell/app/webkit_test_platform_support_win.cc', 'shell/browser/ipc_echo_message_filter.cc', 'shell/browser/ipc_echo_message_filter.h', + 'shell/browser/layout_test/layout_test_javascript_dialog_manager.cc', + 'shell/browser/layout_test/layout_test_javascript_dialog_manager.h', 'shell/browser/notify_done_forwarder.cc', 'shell/browser/notify_done_forwarder.h', 'shell/browser/shell_android.cc', diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn index fc48c41..8118491 100644 --- a/content/shell/BUILD.gn +++ b/content/shell/BUILD.gn @@ -41,6 +41,8 @@ static_library("content_shell_lib") { "app/webkit_test_platform_support_win.cc", "browser/ipc_echo_message_filter.cc", "browser/ipc_echo_message_filter.h", + "browser/layout_test/layout_test_javascript_dialog_manager.cc", + "browser/layout_test/layout_test_javascript_dialog_manager.h", "browser/notify_done_forwarder.cc", "browser/notify_done_forwarder.h", "browser/shell_android.cc", diff --git a/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.cc b/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.cc new file mode 100644 index 0000000..b311a59 --- /dev/null +++ b/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.cc @@ -0,0 +1,46 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h" + +#include "base/command_line.h" +#include "base/logging.h" +#include "base/strings/utf_string_conversions.h" +#include "content/public/browser/web_contents.h" +#include "content/shell/browser/shell_javascript_dialog.h" +#include "content/shell/browser/webkit_test_controller.h" +#include "content/shell/common/shell_switches.h" +#include "net/base/net_util.h" + +namespace content { + +LayoutTestJavaScriptDialogManager::LayoutTestJavaScriptDialogManager() { +} + +LayoutTestJavaScriptDialogManager::~LayoutTestJavaScriptDialogManager() { +} + +void LayoutTestJavaScriptDialogManager::RunJavaScriptDialog( + WebContents* web_contents, + const GURL& origin_url, + const std::string& accept_lang, + JavaScriptMessageType javascript_message_type, + const base::string16& message_text, + const base::string16& default_prompt_text, + const DialogClosedCallback& callback, + bool* did_suppress_message) { + callback.Run(true, base::string16()); + return; +} + +void LayoutTestJavaScriptDialogManager::RunBeforeUnloadDialog( + WebContents* web_contents, + const base::string16& message_text, + bool is_reload, + const DialogClosedCallback& callback) { + callback.Run(true, base::string16()); + return; +} + +} // namespace content diff --git a/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h b/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h new file mode 100644 index 0000000..84ebace --- /dev/null +++ b/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h @@ -0,0 +1,43 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_JAVASCRIPT_DIALOG_MANAGER_H_ +#define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_JAVASCRIPT_DIALOG_MANAGER_H_ + +#include "base/callback_forward.h" +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "content/shell/browser/shell_javascript_dialog_manager.h" + +namespace content { + +class LayoutTestJavaScriptDialogManager : public ShellJavaScriptDialogManager { + public: + LayoutTestJavaScriptDialogManager(); + virtual ~LayoutTestJavaScriptDialogManager(); + + // JavaScriptDialogManager: + virtual void RunJavaScriptDialog( + WebContents* web_contents, + const GURL& origin_url, + const std::string& accept_lang, + JavaScriptMessageType javascript_message_type, + const base::string16& message_text, + const base::string16& default_prompt_text, + const DialogClosedCallback& callback, + bool* did_suppress_message) override; + + virtual void RunBeforeUnloadDialog( + WebContents* web_contents, + const base::string16& message_text, + bool is_reload, + const DialogClosedCallback& callback) override; + + private: + DISALLOW_COPY_AND_ASSIGN(LayoutTestJavaScriptDialogManager); +}; + +} // namespace content + +#endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_JAVASCRIPT_DIALOG_MANAGER_H_ diff --git a/content/shell/browser/shell.cc b/content/shell/browser/shell.cc index 641988a..431c215 100644 --- a/content/shell/browser/shell.cc +++ b/content/shell/browser/shell.cc @@ -19,6 +19,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/common/renderer_preferences.h" +#include "content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h" #include "content/shell/browser/notify_done_forwarder.h" #include "content/shell/browser/shell_browser_main_parts.h" #include "content/shell/browser/shell_content_browser_client.h" @@ -329,8 +330,12 @@ void Shell::DidNavigateMainFramePostCommit(WebContents* web_contents) { } JavaScriptDialogManager* Shell::GetJavaScriptDialogManager() { - if (!dialog_manager_) - dialog_manager_.reset(new ShellJavaScriptDialogManager()); + if (!dialog_manager_) { + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + dialog_manager_.reset(command_line.HasSwitch(switches::kDumpRenderTree) + ? new LayoutTestJavaScriptDialogManager + : new ShellJavaScriptDialogManager); + } return dialog_manager_.get(); } diff --git a/content/shell/browser/shell_javascript_dialog_manager.cc b/content/shell/browser/shell_javascript_dialog_manager.cc index ae08633..2f8f5cc 100644 --- a/content/shell/browser/shell_javascript_dialog_manager.cc +++ b/content/shell/browser/shell_javascript_dialog_manager.cc @@ -30,11 +30,6 @@ void ShellJavaScriptDialogManager::RunJavaScriptDialog( const base::string16& default_prompt_text, const DialogClosedCallback& callback, bool* did_suppress_message) { - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { - callback.Run(true, base::string16()); - return; - } - if (!dialog_request_callback_.is_null()) { dialog_request_callback_.Run(); callback.Run(true, base::string16()); @@ -74,11 +69,6 @@ void ShellJavaScriptDialogManager::RunBeforeUnloadDialog( const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) { - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { - callback.Run(true, base::string16()); - return; - } - if (!dialog_request_callback_.is_null()) { dialog_request_callback_.Run(); callback.Run(true, base::string16()); |