blob: 227478d11c65cb4fbcc2f237f5edf8536bea13d1 (
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// 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_content_browser_client.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigator_connect_context.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/shell/browser/layout_test/blink_test_controller.h"
#include "content/shell/browser/layout_test/layout_test_browser_context.h"
#include "content/shell/browser/layout_test/layout_test_browser_main_parts.h"
#include "content/shell/browser/layout_test/layout_test_message_filter.h"
#include "content/shell/browser/layout_test/layout_test_navigator_connect_service_factory.h"
#include "content/shell/browser/layout_test/layout_test_notification_manager.h"
#include "content/shell/browser/layout_test/layout_test_resource_dispatcher_host_delegate.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/common/shell_messages.h"
#include "content/shell/common/shell_switches.h"
#include "content/shell/renderer/layout_test/blink_test_helpers.h"
namespace content {
namespace {
LayoutTestContentBrowserClient* g_layout_test_browser_client;
} // namespace
LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() {
DCHECK(!g_layout_test_browser_client);
layout_test_notification_manager_.reset(new LayoutTestNotificationManager());
g_layout_test_browser_client = this;
}
LayoutTestContentBrowserClient::~LayoutTestContentBrowserClient() {
g_layout_test_browser_client = nullptr;
}
LayoutTestContentBrowserClient* LayoutTestContentBrowserClient::Get() {
return g_layout_test_browser_client;
}
LayoutTestBrowserContext*
LayoutTestContentBrowserClient::GetLayoutTestBrowserContext() {
return static_cast<LayoutTestBrowserContext*>(browser_context());
}
LayoutTestNotificationManager*
LayoutTestContentBrowserClient::GetLayoutTestNotificationManager() {
return layout_test_notification_manager_.get();
}
void LayoutTestContentBrowserClient::RenderProcessWillLaunch(
RenderProcessHost* host) {
ShellContentBrowserClient::RenderProcessWillLaunch(host);
StoragePartition* partition =
BrowserContext::GetDefaultStoragePartition(browser_context());
host->AddFilter(new LayoutTestMessageFilter(
host->GetID(),
partition->GetDatabaseTracker(),
partition->GetQuotaManager(),
partition->GetURLRequestContext()));
host->Send(new ShellViewMsg_SetWebKitSourceDir(GetWebKitRootDirFilePath()));
}
void LayoutTestContentBrowserClient::OverrideWebkitPrefs(
RenderViewHost* render_view_host,
WebPreferences* prefs) {
BlinkTestController::Get()->OverrideWebkitPrefs(prefs);
}
void LayoutTestContentBrowserClient::ResourceDispatcherHostCreated() {
set_resource_dispatcher_host_delegate(
make_scoped_ptr(new LayoutTestResourceDispatcherHostDelegate));
ResourceDispatcherHost::Get()->SetDelegate(
resource_dispatcher_host_delegate());
}
void LayoutTestContentBrowserClient::AppendExtraCommandLineSwitches(
base::CommandLine* command_line,
int child_process_id) {
command_line->AppendSwitch(switches::kRunLayoutTest);
ShellContentBrowserClient::AppendExtraCommandLineSwitches(command_line,
child_process_id);
}
BrowserMainParts* LayoutTestContentBrowserClient::CreateBrowserMainParts(
const MainFunctionParams& parameters) {
set_browser_main_parts(new LayoutTestBrowserMainParts(parameters));
return shell_browser_main_parts();
}
PlatformNotificationService*
LayoutTestContentBrowserClient::GetPlatformNotificationService() {
return layout_test_notification_manager_.get();
}
void LayoutTestContentBrowserClient::GetAdditionalNavigatorConnectServices(
const scoped_refptr<NavigatorConnectContext>& context) {
context->AddFactory(
make_scoped_ptr(new LayoutTestNavigatorConnectServiceFactory));
}
} // namespace content
|