OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/shell_content_browser_client.h" | 5 #include "content/shell/browser/shell_content_browser_client.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
14 #include "content/public/browser/resource_dispatcher_host.h" | 14 #include "content/public/browser/resource_dispatcher_host.h" |
15 #include "content/public/browser/storage_partition.h" | 15 #include "content/public/browser/storage_partition.h" |
16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
17 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
18 #include "content/public/common/web_preferences.h" | 18 #include "content/public/common/web_preferences.h" |
19 #include "content/shell/browser/ipc_echo_message_filter.h" | 19 #include "content/shell/browser/ipc_echo_message_filter.h" |
20 #include "content/shell/browser/layout_test/layout_test_browser_main_parts.h" | 20 #include "content/shell/browser/layout_test/layout_test_browser_main_parts.h" |
21 #include "content/shell/browser/layout_test/layout_test_resource_dispatcher_host
_delegate.h" | 21 #include "content/shell/browser/layout_test/layout_test_resource_dispatcher_host
_delegate.h" |
22 #include "content/shell/browser/shell.h" | 22 #include "content/shell/browser/shell.h" |
23 #include "content/shell/browser/shell_browser_context.h" | 23 #include "content/shell/browser/shell_browser_context.h" |
24 #include "content/shell/browser/shell_browser_main_parts.h" | 24 #include "content/shell/browser/shell_browser_main_parts.h" |
25 #include "content/shell/browser/shell_devtools_delegate.h" | 25 #include "content/shell/browser/shell_devtools_delegate.h" |
26 #include "content/shell/browser/shell_message_filter.h" | |
27 #include "content/shell/browser/shell_net_log.h" | 26 #include "content/shell/browser/shell_net_log.h" |
28 #include "content/shell/browser/shell_quota_permission_context.h" | 27 #include "content/shell/browser/shell_quota_permission_context.h" |
29 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" | 28 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" |
30 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" | 29 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" |
31 #include "content/shell/browser/webkit_test_controller.h" | 30 #include "content/shell/browser/webkit_test_controller.h" |
32 #include "content/shell/common/shell_messages.h" | 31 #include "content/shell/common/shell_messages.h" |
33 #include "content/shell/common/shell_switches.h" | 32 #include "content/shell/common/shell_switches.h" |
34 #include "content/shell/common/webkit_test_helpers.h" | 33 #include "content/shell/common/webkit_test_helpers.h" |
35 #include "content/shell/geolocation/shell_access_token_store.h" | 34 #include "content/shell/geolocation/shell_access_token_store.h" |
36 #include "net/url_request/url_request_context_getter.h" | 35 #include "net/url_request/url_request_context_getter.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 122 } |
124 | 123 |
125 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) { | 124 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) { |
126 g_swap_processes_for_redirect = swap; | 125 g_swap_processes_for_redirect = swap; |
127 } | 126 } |
128 | 127 |
129 ShellContentBrowserClient::ShellContentBrowserClient() | 128 ShellContentBrowserClient::ShellContentBrowserClient() |
130 : shell_browser_main_parts_(NULL) { | 129 : shell_browser_main_parts_(NULL) { |
131 DCHECK(!g_browser_client); | 130 DCHECK(!g_browser_client); |
132 g_browser_client = this; | 131 g_browser_client = this; |
133 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | |
134 return; | |
135 webkit_source_dir_ = GetWebKitRootDirFilePath(); | |
136 } | 132 } |
137 | 133 |
138 ShellContentBrowserClient::~ShellContentBrowserClient() { | 134 ShellContentBrowserClient::~ShellContentBrowserClient() { |
139 g_browser_client = NULL; | 135 g_browser_client = NULL; |
140 } | 136 } |
141 | 137 |
142 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( | 138 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( |
143 const MainFunctionParams& parameters) { | 139 const MainFunctionParams& parameters) { |
144 shell_browser_main_parts_ = | 140 shell_browser_main_parts_ = |
145 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree) | 141 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree) |
146 ? new LayoutTestBrowserMainParts(parameters) | 142 ? new LayoutTestBrowserMainParts(parameters) |
147 : new ShellBrowserMainParts(parameters); | 143 : new ShellBrowserMainParts(parameters); |
148 return shell_browser_main_parts_; | 144 return shell_browser_main_parts_; |
149 } | 145 } |
150 | 146 |
151 void ShellContentBrowserClient::RenderProcessWillLaunch( | 147 void ShellContentBrowserClient::RenderProcessWillLaunch( |
152 RenderProcessHost* host) { | 148 RenderProcessHost* host) { |
153 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kExposeIpcEcho)) | 149 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kExposeIpcEcho)) |
154 host->AddFilter(new IPCEchoMessageFilter()); | 150 host->AddFilter(new IPCEchoMessageFilter()); |
155 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | |
156 return; | |
157 host->AddFilter(new ShellMessageFilter( | |
158 host->GetID(), | |
159 BrowserContext::GetDefaultStoragePartition(browser_context()) | |
160 ->GetDatabaseTracker(), | |
161 BrowserContext::GetDefaultStoragePartition(browser_context()) | |
162 ->GetQuotaManager(), | |
163 BrowserContext::GetDefaultStoragePartition(browser_context()) | |
164 ->GetURLRequestContext())); | |
165 host->Send(new ShellViewMsg_SetWebKitSourceDir(webkit_source_dir_)); | |
166 } | 151 } |
167 | 152 |
168 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( | 153 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( |
169 BrowserContext* content_browser_context, | 154 BrowserContext* content_browser_context, |
170 ProtocolHandlerMap* protocol_handlers, | 155 ProtocolHandlerMap* protocol_handlers, |
171 URLRequestInterceptorScopedVector request_interceptors) { | 156 URLRequestInterceptorScopedVector request_interceptors) { |
172 ShellBrowserContext* shell_browser_context = | 157 ShellBrowserContext* shell_browser_context = |
173 ShellBrowserContextForBrowserContext(content_browser_context); | 158 ShellBrowserContextForBrowserContext(content_browser_context); |
174 return shell_browser_context->CreateRequestContext( | 159 return shell_browser_context->CreateRequestContext( |
175 protocol_handlers, request_interceptors.Pass()); | 160 protocol_handlers, request_interceptors.Pass()); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 ShellBrowserContext* | 368 ShellBrowserContext* |
384 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 369 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
385 BrowserContext* content_browser_context) { | 370 BrowserContext* content_browser_context) { |
386 if (content_browser_context == browser_context()) | 371 if (content_browser_context == browser_context()) |
387 return browser_context(); | 372 return browser_context(); |
388 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 373 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
389 return off_the_record_browser_context(); | 374 return off_the_record_browser_context(); |
390 } | 375 } |
391 | 376 |
392 } // namespace content | 377 } // namespace content |
OLD | NEW |