diff options
-rw-r--r-- | content/content_shell.gypi | 8 | ||||
-rw-r--r-- | content/shell/layout_test_controller.js | 3 | ||||
-rw-r--r-- | content/shell/layout_test_controller_bindings.cc | 14 | ||||
-rw-r--r-- | content/shell/layout_test_controller_host.h | 59 | ||||
-rw-r--r-- | content/shell/shell_content_browser_client.cc | 6 | ||||
-rw-r--r-- | content/shell/shell_content_renderer_client.cc | 9 | ||||
-rw-r--r-- | content/shell/shell_javascript_dialog_creator.cc | 9 | ||||
-rw-r--r-- | content/shell/shell_messages.h | 3 | ||||
-rw-r--r-- | content/shell/shell_render_view_host_observer.cc (renamed from content/shell/layout_test_controller_host.cc) | 52 | ||||
-rw-r--r-- | content/shell/shell_render_view_host_observer.h | 47 | ||||
-rw-r--r-- | content/shell/shell_render_view_observer.cc (renamed from content/shell/layout_test_controller.cc) | 19 | ||||
-rw-r--r-- | content/shell/shell_render_view_observer.h (renamed from content/shell/layout_test_controller.h) | 17 |
12 files changed, 88 insertions, 158 deletions
diff --git a/content/content_shell.gypi b/content/content_shell.gypi index c8fc373..588723e 100644 --- a/content/content_shell.gypi +++ b/content/content_shell.gypi @@ -46,12 +46,8 @@ '..', ], 'sources': [ - 'shell/layout_test_controller.cc', - 'shell/layout_test_controller.h', 'shell/layout_test_controller_bindings.cc', 'shell/layout_test_controller_bindings.h', - 'shell/layout_test_controller_host.cc', - 'shell/layout_test_controller_host.h', 'shell/paths_mac.h', 'shell/paths_mac.mm', 'shell/shell.cc', @@ -96,6 +92,10 @@ 'shell/shell_network_delegate.h', 'shell/shell_render_process_observer.cc', 'shell/shell_render_process_observer.h', + 'shell/shell_render_view_host_observer.cc', + 'shell/shell_render_view_host_observer.h', + 'shell/shell_render_view_observer.cc', + 'shell/shell_render_view_observer.h', 'shell/shell_resource_context.cc', 'shell/shell_resource_context.h', 'shell/shell_resource_dispatcher_host_delegate.cc', diff --git a/content/shell/layout_test_controller.js b/content/shell/layout_test_controller.js index 5cab912..14d0332 100644 --- a/content/shell/layout_test_controller.js +++ b/content/shell/layout_test_controller.js @@ -9,7 +9,6 @@ var layoutTestController = layoutTestController || {}; native function SetDumpAsText(); native function SetDumpChildFramesAsText(); native function SetPrinting(); - native function SetShouldStayOnPageAfterHandlingBeforeUnload(); native function SetWaitUntilDone(); layoutTestController = new function() { @@ -17,8 +16,6 @@ var layoutTestController = layoutTestController || {}; this.dumpAsText = SetDumpAsText; this.dumpChildFramesAsText = SetDumpChildFramesAsText; this.setPrinting = SetPrinting; - this.setShouldStayOnPageAfterHandlingBeforeUnload = - SetShouldStayOnPageAfterHandlingBeforeUnload; this.waitUntilDone = SetWaitUntilDone; }(); })(); diff --git a/content/shell/layout_test_controller_bindings.cc b/content/shell/layout_test_controller_bindings.cc index 59fecec..0d5d4ed 100644 --- a/content/shell/layout_test_controller_bindings.cc +++ b/content/shell/layout_test_controller_bindings.cc @@ -76,20 +76,6 @@ v8::Handle<v8::Value> SetPrinting(const v8::Arguments& args) { return v8::Undefined(); } -v8::Handle<v8::Value> SetShouldStayOnPageAfterHandlingBeforeUnload( - const v8::Arguments& args) { - RenderView* view = GetCurrentRenderView(); - if (!view) - return v8::Undefined(); - - if (args.Length() != 1 || args[0]->IsBoolean()) - return v8::Undefined(); - - view->Send(new ShellViewHostMsg_SetShouldStayOnPageAfterHandlingBeforeUnload( - view->GetRoutingID(), args[0]->BooleanValue())); - return v8::Undefined(); -} - v8::Handle<v8::Value> SetWaitUntilDone(const v8::Arguments& args) { RenderView* view = GetCurrentRenderView(); if (!view) diff --git a/content/shell/layout_test_controller_host.h b/content/shell/layout_test_controller_host.h deleted file mode 100644 index 733dfc9..0000000 --- a/content/shell/layout_test_controller_host.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2012 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_LAYOUT_TEST_CONTROLLER_HOST_H_ -#define CONTENT_SHELL_LAYOUT_TEST_CONTROLLER_HOST_H_ -#pragma once - -#include <map> -#include <string> - -#include "content/public/browser/render_view_host_observer.h" - -namespace content { - -class LayoutTestControllerHost : public RenderViewHostObserver { - public: - static LayoutTestControllerHost* FromRenderViewHost( - RenderViewHost* render_view_host); - - explicit LayoutTestControllerHost(RenderViewHost* render_view_host); - virtual ~LayoutTestControllerHost(); - - bool should_stay_on_page_after_handling_before_unload() const { - return should_stay_on_page_after_handling_before_unload_; - } - - // RenderViewHostObserver implementation. - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - - private: - void CaptureDump(); - - // Message handlers. - void OnDidFinishLoad(); - void OnTextDump(const std::string& dump); - - // layoutTestController handlers. - void OnNotifyDone(); - void OnDumpAsText(); - void OnDumpChildFramesAsText(); - void OnSetPrinting(); - void OnSetShouldStayOnPageAfterHandlingBeforeUnload(bool should_stay_on_page); - void OnWaitUntilDone(); - - static std::map<RenderViewHost*, LayoutTestControllerHost*> controllers_; - - bool dump_as_text_; - bool dump_child_frames_; - bool is_printing_; - bool should_stay_on_page_after_handling_before_unload_; - bool wait_until_done_; - - DISALLOW_COPY_AND_ASSIGN(LayoutTestControllerHost); -}; - -} // namespace content - -#endif // CONTENT_SHELL_LAYOUT_TEST_CONTROLLER_HOST_H_ diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc index d00b033..dca4df0 100644 --- a/content/shell/shell_content_browser_client.cc +++ b/content/shell/shell_content_browser_client.cc @@ -7,10 +7,10 @@ #include "base/command_line.h" #include "base/file_path.h" #include "content/public/browser/resource_dispatcher_host.h" -#include "content/shell/layout_test_controller_host.h" #include "content/shell/shell.h" #include "content/shell/shell_browser_main_parts.h" #include "content/shell/shell_devtools_delegate.h" +#include "content/shell/shell_render_view_host_observer.h" #include "content/shell/shell_resource_dispatcher_host_delegate.h" #include "content/shell/shell_switches.h" #include "googleurl/src/gurl.h" @@ -32,9 +32,7 @@ BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( void ShellContentBrowserClient::RenderViewHostCreated( RenderViewHost* render_view_host) { - if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) - return; - new LayoutTestControllerHost(render_view_host); + new ShellRenderViewHostObserver(render_view_host); } void ShellContentBrowserClient::AppendExtraCommandLineSwitches( diff --git a/content/shell/shell_content_renderer_client.cc b/content/shell/shell_content_renderer_client.cc index a120158..0619e67c 100644 --- a/content/shell/shell_content_renderer_client.cc +++ b/content/shell/shell_content_renderer_client.cc @@ -4,10 +4,8 @@ #include "content/shell/shell_content_renderer_client.h" -#include "base/command_line.h" -#include "content/shell/layout_test_controller.h" #include "content/shell/shell_render_process_observer.h" -#include "content/shell/shell_switches.h" +#include "content/shell/shell_render_view_observer.h" #include "v8/include/v8.h" namespace content { @@ -23,10 +21,7 @@ void ShellContentRendererClient::RenderThreadStarted() { } void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) { - if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) - return; - - new content::LayoutTestController(render_view); + new content::ShellRenderViewObserver(render_view); } } // namespace content diff --git a/content/shell/shell_javascript_dialog_creator.cc b/content/shell/shell_javascript_dialog_creator.cc index 37518acf..9441b49 100644 --- a/content/shell/shell_javascript_dialog_creator.cc +++ b/content/shell/shell_javascript_dialog_creator.cc @@ -9,8 +9,6 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/utf_string_conversions.h" -#include "content/public/browser/web_contents.h" -#include "content/shell/layout_test_controller_host.h" #include "content/shell/shell_javascript_dialog.h" #include "content/shell/shell_switches.h" #include "net/base/net_util.h" @@ -78,12 +76,7 @@ void ShellJavaScriptDialogCreator::RunBeforeUnloadDialog( const DialogClosedCallback& callback) { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { std::cout << "CONFIRM NAVIGATION: " << UTF16ToUTF8(message_text) << "\n"; - LayoutTestControllerHost* controller = - LayoutTestControllerHost::FromRenderViewHost( - web_contents->GetRenderViewHost()); - callback.Run( - !controller->should_stay_on_page_after_handling_before_unload(), - string16()); + callback.Run(true, string16()); return; } diff --git a/content/shell/shell_messages.h b/content/shell/shell_messages.h index 50ce122..eccc863 100644 --- a/content/shell/shell_messages.h +++ b/content/shell/shell_messages.h @@ -28,7 +28,4 @@ IPC_MESSAGE_ROUTED0(ShellViewHostMsg_NotifyDone) IPC_MESSAGE_ROUTED0(ShellViewHostMsg_DumpAsText) IPC_MESSAGE_ROUTED0(ShellViewHostMsg_DumpChildFramesAsText) IPC_MESSAGE_ROUTED0(ShellViewHostMsg_SetPrinting) -IPC_MESSAGE_ROUTED1( - ShellViewHostMsg_SetShouldStayOnPageAfterHandlingBeforeUnload, - bool /* should_stay_on_page */) IPC_MESSAGE_ROUTED0(ShellViewHostMsg_WaitUntilDone) diff --git a/content/shell/layout_test_controller_host.cc b/content/shell/shell_render_view_host_observer.cc index 94b534c..b191126 100644 --- a/content/shell/layout_test_controller_host.cc +++ b/content/shell/shell_render_view_host_observer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/shell/layout_test_controller_host.h" +#include "content/shell/shell_render_view_host_observer.h" #include <iostream> @@ -12,35 +12,19 @@ namespace content { -std::map<RenderViewHost*, LayoutTestControllerHost*> - LayoutTestControllerHost::controllers_; - -// static -LayoutTestControllerHost* LayoutTestControllerHost::FromRenderViewHost( - RenderViewHost* render_view_host) { - const std::map<RenderViewHost*, LayoutTestControllerHost*>::iterator it = - controllers_.find(render_view_host); - if (it == controllers_.end()) - return NULL; - return it->second; -} - -LayoutTestControllerHost::LayoutTestControllerHost( +ShellRenderViewHostObserver::ShellRenderViewHostObserver( RenderViewHost* render_view_host) : RenderViewHostObserver(render_view_host), dump_as_text_(false), - dump_child_frames_(false), is_printing_(false), - should_stay_on_page_after_handling_before_unload_(false), + dump_child_frames_(false), wait_until_done_(false) { - controllers_[render_view_host] = this; } -LayoutTestControllerHost::~LayoutTestControllerHost() { - controllers_.erase(render_view_host()); +ShellRenderViewHostObserver::~ShellRenderViewHostObserver() { } -void LayoutTestControllerHost::CaptureDump() { +void ShellRenderViewHostObserver::CaptureDump() { render_view_host()->Send( new ShellViewMsg_CaptureTextDump(render_view_host()->GetRoutingID(), dump_as_text_, @@ -48,10 +32,10 @@ void LayoutTestControllerHost::CaptureDump() { dump_child_frames_)); } -bool LayoutTestControllerHost::OnMessageReceived( +bool ShellRenderViewHostObserver::OnMessageReceived( const IPC::Message& message) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP(LayoutTestControllerHost, message) + IPC_BEGIN_MESSAGE_MAP(ShellRenderViewHostObserver, message) IPC_MESSAGE_HANDLER(ShellViewHostMsg_DidFinishLoad, OnDidFinishLoad) IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump) IPC_MESSAGE_HANDLER(ShellViewHostMsg_NotifyDone, OnNotifyDone) @@ -59,9 +43,6 @@ bool LayoutTestControllerHost::OnMessageReceived( IPC_MESSAGE_HANDLER(ShellViewHostMsg_DumpChildFramesAsText, OnDumpChildFramesAsText) IPC_MESSAGE_HANDLER(ShellViewHostMsg_SetPrinting, OnSetPrinting) - IPC_MESSAGE_HANDLER( - ShellViewHostMsg_SetShouldStayOnPageAfterHandlingBeforeUnload, - OnSetShouldStayOnPageAfterHandlingBeforeUnload) IPC_MESSAGE_HANDLER(ShellViewHostMsg_WaitUntilDone, OnWaitUntilDone) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -69,14 +50,14 @@ bool LayoutTestControllerHost::OnMessageReceived( return handled; } -void LayoutTestControllerHost::OnDidFinishLoad() { +void ShellRenderViewHostObserver::OnDidFinishLoad() { if (wait_until_done_) return; CaptureDump(); } -void LayoutTestControllerHost::OnTextDump(const std::string& dump) { +void ShellRenderViewHostObserver::OnTextDump(const std::string& dump) { std::cout << dump; std::cout << "#EOF\n"; std::cerr << "#EOF\n"; @@ -84,28 +65,23 @@ void LayoutTestControllerHost::OnTextDump(const std::string& dump) { MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); } -void LayoutTestControllerHost::OnNotifyDone() { +void ShellRenderViewHostObserver::OnNotifyDone() { CaptureDump(); } -void LayoutTestControllerHost::OnDumpAsText() { +void ShellRenderViewHostObserver::OnDumpAsText() { dump_as_text_ = true; } -void LayoutTestControllerHost::OnSetPrinting() { +void ShellRenderViewHostObserver::OnSetPrinting() { is_printing_ = true; } -void LayoutTestControllerHost::OnSetShouldStayOnPageAfterHandlingBeforeUnload( - bool should_stay_on_page) { - should_stay_on_page_after_handling_before_unload_ = should_stay_on_page; -} - -void LayoutTestControllerHost::OnDumpChildFramesAsText() { +void ShellRenderViewHostObserver::OnDumpChildFramesAsText() { dump_child_frames_ = true; } -void LayoutTestControllerHost::OnWaitUntilDone() { +void ShellRenderViewHostObserver::OnWaitUntilDone() { wait_until_done_ = true; } diff --git a/content/shell/shell_render_view_host_observer.h b/content/shell/shell_render_view_host_observer.h new file mode 100644 index 0000000..165c802 --- /dev/null +++ b/content/shell/shell_render_view_host_observer.h @@ -0,0 +1,47 @@ +// Copyright (c) 2012 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_SHELL_RENDER_VIEW_HOST_OBSERVER_H_ +#define CONTENT_SHELL_SHELL_RENDER_VIEW_HOST_OBSERVER_H_ +#pragma once + +#include <string> + +#include "content/public/browser/render_view_host_observer.h" + +namespace content { + +class ShellRenderViewHostObserver : public RenderViewHostObserver { + public: + explicit ShellRenderViewHostObserver(RenderViewHost* render_view_host); + virtual ~ShellRenderViewHostObserver(); + + // RenderViewHostObserver implementation. + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + + private: + void CaptureDump(); + + // Message handlers. + void OnDidFinishLoad(); + void OnTextDump(const std::string& dump); + + // layoutTestController handlers. + void OnNotifyDone(); + void OnDumpAsText(); + void OnDumpChildFramesAsText(); + void OnSetPrinting(); + void OnWaitUntilDone(); + + bool dump_as_text_; + bool is_printing_; + bool dump_child_frames_; + bool wait_until_done_; + + DISALLOW_COPY_AND_ASSIGN(ShellRenderViewHostObserver); +}; + +} // namespace content + +#endif // CONTENT_SHELL_SHELL_RENDER_VIEW_HOST_OBSERVER_H_ diff --git a/content/shell/layout_test_controller.cc b/content/shell/shell_render_view_observer.cc index faef0cd..0179ea2 100644 --- a/content/shell/layout_test_controller.cc +++ b/content/shell/shell_render_view_observer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/shell/layout_test_controller.h" +#include "content/shell/shell_render_view_observer.h" #include "base/stringprintf.h" #include "content/public/renderer/render_view.h" @@ -85,22 +85,21 @@ std::string DumpFrameScrollPosition(WebFrame* frame, bool recursive) { } } // namespace - -LayoutTestController::LayoutTestController(RenderView* render_view) +ShellRenderViewObserver::ShellRenderViewObserver(RenderView* render_view) : RenderViewObserver(render_view) { } -LayoutTestController::~LayoutTestController() { +ShellRenderViewObserver::~ShellRenderViewObserver() { } -void LayoutTestController::DidFinishLoad(WebFrame* frame) { +void ShellRenderViewObserver::DidFinishLoad(WebFrame* frame) { if (!frame->parent()) Send(new ShellViewHostMsg_DidFinishLoad(routing_id())); } -bool LayoutTestController::OnMessageReceived(const IPC::Message& message) { +bool ShellRenderViewObserver::OnMessageReceived(const IPC::Message& message) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP(LayoutTestController, message) + IPC_BEGIN_MESSAGE_MAP(ShellRenderViewObserver, message) IPC_MESSAGE_HANDLER(ShellViewMsg_CaptureTextDump, OnCaptureTextDump) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -108,9 +107,9 @@ bool LayoutTestController::OnMessageReceived(const IPC::Message& message) { return handled; } -void LayoutTestController::OnCaptureTextDump(bool as_text, - bool printing, - bool recursive) { +void ShellRenderViewObserver::OnCaptureTextDump(bool as_text, + bool printing, + bool recursive) { WebFrame* frame = render_view()->GetWebView()->mainFrame(); std::string dump; if (as_text) { diff --git a/content/shell/layout_test_controller.h b/content/shell/shell_render_view_observer.h index b8e06b5..5ea7d60 100644 --- a/content/shell/layout_test_controller.h +++ b/content/shell/shell_render_view_observer.h @@ -2,19 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_SHELL_LAYOUT_TEST_CONTROLLER_H_ -#define CONTENT_SHELL_LAYOUT_TEST_CONTROLLER_H_ +#ifndef CONTENT_SHELL_SHELL_RENDER_VIEW_OBSERVER_H_ +#define CONTENT_SHELL_SHELL_RENDER_VIEW_OBSERVER_H_ #pragma once #include "content/public/renderer/render_view_observer.h" namespace content { -// This is the renderer side of the layout test controller. -class LayoutTestController : public RenderViewObserver { +// This class holds the content_shell specific parts of RenderView, and has the +// same lifetime. +class ShellRenderViewObserver : public RenderViewObserver { public: - explicit LayoutTestController(RenderView* render_view); - virtual ~LayoutTestController(); + explicit ShellRenderViewObserver(RenderView* render_view); + virtual ~ShellRenderViewObserver(); // RenderViewObserver implementation. virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; @@ -24,9 +25,9 @@ class LayoutTestController : public RenderViewObserver { // Message handlers. void OnCaptureTextDump(bool as_text, bool printing, bool recursive); - DISALLOW_COPY_AND_ASSIGN(LayoutTestController); + DISALLOW_COPY_AND_ASSIGN(ShellRenderViewObserver); }; } // namespace content -#endif // CONTENT_SHELL_LAYOUT_TEST_CONTROLLER_H_ +#endif // CONTENT_SHELL_SHELL_RENDER_VIEW_OBSERVER_H_ |