| 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" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 g_browser_client = this; | 131 g_browser_client = this; |
| 132 } | 132 } |
| 133 | 133 |
| 134 ShellContentBrowserClient::~ShellContentBrowserClient() { | 134 ShellContentBrowserClient::~ShellContentBrowserClient() { |
| 135 g_browser_client = NULL; | 135 g_browser_client = NULL; |
| 136 } | 136 } |
| 137 | 137 |
| 138 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( | 138 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( |
| 139 const MainFunctionParams& parameters) { | 139 const MainFunctionParams& parameters) { |
| 140 shell_browser_main_parts_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 140 shell_browser_main_parts_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 141 switches::kDumpRenderTree) | 141 switches::kRunLayoutTest) |
| 142 ? new LayoutTestBrowserMainParts(parameters) | 142 ? new LayoutTestBrowserMainParts(parameters) |
| 143 : new ShellBrowserMainParts(parameters); | 143 : new ShellBrowserMainParts(parameters); |
| 144 return shell_browser_main_parts_; | 144 return shell_browser_main_parts_; |
| 145 } | 145 } |
| 146 | 146 |
| 147 void ShellContentBrowserClient::RenderProcessWillLaunch( | 147 void ShellContentBrowserClient::RenderProcessWillLaunch( |
| 148 RenderProcessHost* host) { | 148 RenderProcessHost* host) { |
| 149 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 149 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 150 switches::kExposeIpcEcho)) | 150 switches::kExposeIpcEcho)) |
| 151 host->AddFilter(new IPCEchoMessageFilter()); | 151 host->AddFilter(new IPCEchoMessageFilter()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 if (url.scheme() == kProtocolList[i]) | 195 if (url.scheme() == kProtocolList[i]) |
| 196 return true; | 196 return true; |
| 197 } | 197 } |
| 198 return false; | 198 return false; |
| 199 } | 199 } |
| 200 | 200 |
| 201 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( | 201 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( |
| 202 base::CommandLine* command_line, | 202 base::CommandLine* command_line, |
| 203 int child_process_id) { | 203 int child_process_id) { |
| 204 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 204 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 205 switches::kDumpRenderTree)) | 205 switches::kRunLayoutTest)) |
| 206 command_line->AppendSwitch(switches::kDumpRenderTree); | 206 command_line->AppendSwitch(switches::kRunLayoutTest); |
| 207 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 207 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 208 switches::kEnableFontAntialiasing)) | 208 switches::kEnableFontAntialiasing)) |
| 209 command_line->AppendSwitch(switches::kEnableFontAntialiasing); | 209 command_line->AppendSwitch(switches::kEnableFontAntialiasing); |
| 210 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 210 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 211 switches::kExposeInternalsForTesting)) | 211 switches::kExposeInternalsForTesting)) |
| 212 command_line->AppendSwitch(switches::kExposeInternalsForTesting); | 212 command_line->AppendSwitch(switches::kExposeInternalsForTesting); |
| 213 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 213 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 214 switches::kExposeIpcEcho)) | 214 switches::kExposeIpcEcho)) |
| 215 command_line->AppendSwitch(switches::kExposeIpcEcho); | 215 command_line->AppendSwitch(switches::kExposeIpcEcho); |
| 216 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 216 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 241 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 241 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 242 switches::kRegisterFontFiles)); | 242 switches::kRegisterFontFiles)); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 void ShellContentBrowserClient::OverrideWebkitPrefs( | 246 void ShellContentBrowserClient::OverrideWebkitPrefs( |
| 247 RenderViewHost* render_view_host, | 247 RenderViewHost* render_view_host, |
| 248 const GURL& url, | 248 const GURL& url, |
| 249 WebPreferences* prefs) { | 249 WebPreferences* prefs) { |
| 250 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 250 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 251 switches::kDumpRenderTree)) | 251 switches::kRunLayoutTest)) |
| 252 return; | 252 return; |
| 253 WebKitTestController::Get()->OverrideWebkitPrefs(prefs); | 253 WebKitTestController::Get()->OverrideWebkitPrefs(prefs); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void ShellContentBrowserClient::ResourceDispatcherHostCreated() { | 256 void ShellContentBrowserClient::ResourceDispatcherHostCreated() { |
| 257 resource_dispatcher_host_delegate_.reset( | 257 resource_dispatcher_host_delegate_.reset( |
| 258 base::CommandLine::ForCurrentProcess()->HasSwitch( | 258 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 259 switches::kDumpRenderTree) | 259 switches::kRunLayoutTest) |
| 260 ? new LayoutTestResourceDispatcherHostDelegate | 260 ? new LayoutTestResourceDispatcherHostDelegate |
| 261 : new ShellResourceDispatcherHostDelegate); | 261 : new ShellResourceDispatcherHostDelegate); |
| 262 ResourceDispatcherHost::Get()->SetDelegate( | 262 ResourceDispatcherHost::Get()->SetDelegate( |
| 263 resource_dispatcher_host_delegate_.get()); | 263 resource_dispatcher_host_delegate_.get()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 std::string ShellContentBrowserClient::GetDefaultDownloadName() { | 266 std::string ShellContentBrowserClient::GetDefaultDownloadName() { |
| 267 return "download"; | 267 return "download"; |
| 268 } | 268 } |
| 269 | 269 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 ShellBrowserContext* | 375 ShellBrowserContext* |
| 376 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 376 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
| 377 BrowserContext* content_browser_context) { | 377 BrowserContext* content_browser_context) { |
| 378 if (content_browser_context == browser_context()) | 378 if (content_browser_context == browser_context()) |
| 379 return browser_context(); | 379 return browser_context(); |
| 380 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 380 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
| 381 return off_the_record_browser_context(); | 381 return off_the_record_browser_context(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 } // namespace content | 384 } // namespace content |
| OLD | NEW |