Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: content/shell/shell_render_process_observer.cc

Issue 11245004: [content shell] link against the TestRunner library (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/shell/shell_render_process_observer.h ('k') | content/shell/webkit_test_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/shell/shell_render_process_observer.h" 5 #include "content/shell/shell_render_process_observer.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/public/renderer/render_view.h"
8 #include "content/public/renderer/render_thread.h" 9 #include "content/public/renderer/render_thread.h"
10 #include "content/shell/shell_messages.h"
9 #include "content/shell/shell_switches.h" 11 #include "content/shell/shell_switches.h"
10 #include "content/shell/webkit_test_runner_bindings.h" 12 #include "content/shell/webkit_test_runner_bindings.h"
11 #include "webkit/glue/webkit_glue.h" 13 #include "webkit/glue/webkit_glue.h"
12 #include "webkit/support/gc_extension.h" 14 #include "webkit/support/gc_extension.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h"
16 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestInterfaces.h"
17
18 using WebKit::WebFrame;
19 using WebKit::WebTestingSupport;
20 using WebTestRunner::WebTestDelegate;
21 using WebTestRunner::WebTestInterfaces;
13 22
14 namespace content { 23 namespace content {
15 24
16 ShellRenderProcessObserver::ShellRenderProcessObserver() { 25 namespace {
26 ShellRenderProcessObserver* g_instance = NULL;
27 }
28
29 // static
30 ShellRenderProcessObserver* ShellRenderProcessObserver::GetInstance() {
31 return g_instance;
32 }
33
34 ShellRenderProcessObserver::ShellRenderProcessObserver()
35 : test_delegate_(NULL) {
36 CHECK(!g_instance);
37 g_instance = this;
17 RenderThread::Get()->AddObserver(this); 38 RenderThread::Get()->AddObserver(this);
18 } 39 }
19 40
20 ShellRenderProcessObserver::~ShellRenderProcessObserver() { 41 ShellRenderProcessObserver::~ShellRenderProcessObserver() {
42 CHECK(g_instance == this);
43 g_instance = NULL;
44 }
45
46 void ShellRenderProcessObserver::SetMainWindow(
47 RenderView* view,
48 WebTestDelegate* delegate) {
49 if (view == NULL) {
50 if (delegate == test_delegate_) {
51 test_interfaces_->setDelegate(NULL);
52 test_interfaces_->setWebView(NULL);
53 test_delegate_ = NULL;
54 }
55 } else {
56 test_interfaces_->setDelegate(delegate);
57 test_interfaces_->setWebView(view->GetWebView());
58 test_delegate_ = delegate;
59 }
60 }
61
62 void ShellRenderProcessObserver::BindTestRunnersToWindow(WebFrame* frame) {
63 WebTestingSupport::injectInternalsObject(frame);
64 test_interfaces_->bindTo(frame);
21 } 65 }
22 66
23 void ShellRenderProcessObserver::WebKitInitialized() { 67 void ShellRenderProcessObserver::WebKitInitialized() {
24 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) 68 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
25 return; 69 return;
26 70
27 // To implement a catch-all for not yet implemented controller properties. 71 // To implement a catch-all for not yet implemented controller properties.
28 webkit_glue::SetJavaScriptFlags(" --harmony_proxies"); 72 webkit_glue::SetJavaScriptFlags(" --harmony_proxies");
29 RenderThread::Get()->RegisterExtension(new WebKitTestRunnerBindings()); 73 RenderThread::Get()->RegisterExtension(new WebKitTestRunnerBindings());
30 74
31 // We always expose GC to layout tests. 75 // We always expose GC to layout tests.
32 webkit_glue::SetJavaScriptFlags(" --expose-gc"); 76 webkit_glue::SetJavaScriptFlags(" --expose-gc");
33 RenderThread::Get()->RegisterExtension(extensions_v8::GCExtension::Get()); 77 RenderThread::Get()->RegisterExtension(extensions_v8::GCExtension::Get());
78
79 test_interfaces_.reset(new WebTestInterfaces);
80 }
81
82 bool ShellRenderProcessObserver::OnControlMessageReceived(
83 const IPC::Message& message) {
84 bool handled = true;
85 IPC_BEGIN_MESSAGE_MAP(ShellRenderProcessObserver, message)
86 IPC_MESSAGE_HANDLER(ShellViewMsg_ResetAll, OnResetAll)
87 IPC_MESSAGE_UNHANDLED(handled = false)
88 IPC_END_MESSAGE_MAP()
89
90 return handled;
91 }
92
93 void ShellRenderProcessObserver::OnResetAll() {
94 test_interfaces_->resetAll();
95 // We don't reset the WebTestingSupport objects, as we don't reuse WebViews.
34 } 96 }
35 97
36 } // namespace content 98 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/shell_render_process_observer.h ('k') | content/shell/webkit_test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698