blob: 8ccf74e1d2a9bd51237b259401b006d4dc25e5cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// 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.
#include "content/shell/shell_content_renderer_client.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/layouttest_support.h"
#include "content/shell/shell_render_process_observer.h"
#include "content/shell/shell_switches.h"
#include "content/shell/webkit_test_runner.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h"
#include "v8/include/v8.h"
using WebTestRunner::WebTestProxyBase;
namespace content {
ShellContentRendererClient::ShellContentRendererClient()
: latest_test_runner_(NULL) {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
EnableWebTestProxyCreation(
base::Bind(&ShellContentRendererClient::WebTestProxyCreated,
base::Unretained(this)));
}
}
ShellContentRendererClient::~ShellContentRendererClient() {
}
void ShellContentRendererClient::RenderThreadStarted() {
shell_observer_.reset(new ShellRenderProcessObserver());
}
void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) {
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
return;
CHECK(!latest_test_runner_);
latest_test_runner_ = new WebKitTestRunner(render_view);
}
bool ShellContentRendererClient::OverrideCreatePlugin(
RenderView* render_view,
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params,
WebKit::WebPlugin** plugin) {
std::string mime_type = params.mimeType.utf8();
if (mime_type == content::kBrowserPluginMimeType) {
// Allow browser plugin in content_shell only if it is forced by flag.
// Returning true here disables the plugin.
return !CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserPluginForAllViewTypes);
}
return false;
}
void ShellContentRendererClient::WebTestProxyCreated(WebTestProxyBase* proxy) {
CHECK(latest_test_runner_);
proxy->setDelegate(latest_test_runner_);
latest_test_runner_->set_proxy(proxy);
latest_test_runner_ = NULL;
proxy->setInterfaces(
ShellRenderProcessObserver::GetInstance()->test_interfaces());
}
} // namespace content
|