| OLD | NEW |
| 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/renderer/shell_render_process_observer.h" | 5 #include "content/shell/renderer/shell_render_process_observer.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/public/common/content_client.h" | 8 #include "content/public/common/content_client.h" |
| 9 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
| 10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
| 11 #include "content/public/test/layouttest_support.h" | 11 #include "content/public/test/layouttest_support.h" |
| 12 #include "content/shell/common/shell_messages.h" | 12 #include "content/shell/common/shell_messages.h" |
| 13 #include "content/shell/common/shell_switches.h" | 13 #include "content/shell/common/shell_switches.h" |
| 14 #include "content/shell/renderer/shell_content_renderer_client.h" | 14 #include "content/shell/renderer/shell_content_renderer_client.h" |
| 15 #include "content/shell/renderer/test_runner/WebTestInterfaces.h" | 15 #include "content/shell/renderer/test_runner/web_test_interfaces.h" |
| 16 #include "content/shell/renderer/webkit_test_runner.h" | 16 #include "content/shell/renderer/webkit_test_runner.h" |
| 17 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 17 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 18 #include "third_party/WebKit/public/web/WebView.h" | 18 #include "third_party/WebKit/public/web/WebView.h" |
| 19 #include "v8/include/v8.h" | 19 #include "v8/include/v8.h" |
| 20 | 20 |
| 21 using blink::WebFrame; | 21 using blink::WebFrame; |
| 22 using blink::WebRuntimeFeatures; | 22 using blink::WebRuntimeFeatures; |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 42 return; | 42 return; |
| 43 EnableRendererLayoutTestMode(); | 43 EnableRendererLayoutTestMode(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 ShellRenderProcessObserver::~ShellRenderProcessObserver() { | 46 ShellRenderProcessObserver::~ShellRenderProcessObserver() { |
| 47 CHECK(g_instance == this); | 47 CHECK(g_instance == this); |
| 48 g_instance = NULL; | 48 g_instance = NULL; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void ShellRenderProcessObserver::SetTestDelegate(WebTestDelegate* delegate) { | 51 void ShellRenderProcessObserver::SetTestDelegate(WebTestDelegate* delegate) { |
| 52 test_interfaces_->setDelegate(delegate); | 52 test_interfaces_->SetDelegate(delegate); |
| 53 test_delegate_ = delegate; | 53 test_delegate_ = delegate; |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ShellRenderProcessObserver::SetMainWindow(RenderView* view) { | 56 void ShellRenderProcessObserver::SetMainWindow(RenderView* view) { |
| 57 WebKitTestRunner* test_runner = WebKitTestRunner::Get(view); | 57 WebKitTestRunner* test_runner = WebKitTestRunner::Get(view); |
| 58 test_interfaces_->setWebView(view->GetWebView(), test_runner->proxy()); | 58 test_interfaces_->SetWebView(view->GetWebView(), test_runner->proxy()); |
| 59 main_test_runner_ = test_runner; | 59 main_test_runner_ = test_runner; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ShellRenderProcessObserver::WebKitInitialized() { | 62 void ShellRenderProcessObserver::WebKitInitialized() { |
| 63 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 63 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
| 64 return; | 64 return; |
| 65 | 65 |
| 66 // We always expose GC to layout tests. | 66 // We always expose GC to layout tests. |
| 67 std::string flags("--expose-gc"); | 67 std::string flags("--expose-gc"); |
| 68 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); | 68 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); |
| 69 | 69 |
| 70 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 70 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 71 switches::kStableReleaseMode)) { | 71 switches::kStableReleaseMode)) { |
| 72 WebRuntimeFeatures::enableTestOnlyFeatures(true); | 72 WebRuntimeFeatures::enableTestOnlyFeatures(true); |
| 73 } | 73 } |
| 74 | 74 |
| 75 test_interfaces_.reset(new WebTestInterfaces); | 75 test_interfaces_.reset(new WebTestInterfaces); |
| 76 test_interfaces_->resetAll(); | 76 test_interfaces_->ResetAll(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void ShellRenderProcessObserver::OnRenderProcessShutdown() { | 79 void ShellRenderProcessObserver::OnRenderProcessShutdown() { |
| 80 test_interfaces_.reset(); | 80 test_interfaces_.reset(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool ShellRenderProcessObserver::OnControlMessageReceived( | 83 bool ShellRenderProcessObserver::OnControlMessageReceived( |
| 84 const IPC::Message& message) { | 84 const IPC::Message& message) { |
| 85 bool handled = true; | 85 bool handled = true; |
| 86 IPC_BEGIN_MESSAGE_MAP(ShellRenderProcessObserver, message) | 86 IPC_BEGIN_MESSAGE_MAP(ShellRenderProcessObserver, message) |
| 87 IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir) | 87 IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir) |
| 88 IPC_MESSAGE_UNHANDLED(handled = false) | 88 IPC_MESSAGE_UNHANDLED(handled = false) |
| 89 IPC_END_MESSAGE_MAP() | 89 IPC_END_MESSAGE_MAP() |
| 90 | 90 |
| 91 return handled; | 91 return handled; |
| 92 } | 92 } |
| 93 | 93 |
| 94 void ShellRenderProcessObserver::OnSetWebKitSourceDir( | 94 void ShellRenderProcessObserver::OnSetWebKitSourceDir( |
| 95 const base::FilePath& webkit_source_dir) { | 95 const base::FilePath& webkit_source_dir) { |
| 96 webkit_source_dir_ = webkit_source_dir; | 96 webkit_source_dir_ = webkit_source_dir; |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace content | 99 } // namespace content |
| OLD | NEW |