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/shell_content_browser_client.h" | 5 #include "content/shell/shell_content_browser_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 void ShellContentBrowserClient::RenderProcessHostCreated( | 76 void ShellContentBrowserClient::RenderProcessHostCreated( |
77 RenderProcessHost* host) { | 77 RenderProcessHost* host) { |
78 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 78 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
79 return; | 79 return; |
80 host->GetChannel()->AddFilter(new ShellMessageFilter(host->GetID())); | 80 host->GetChannel()->AddFilter(new ShellMessageFilter(host->GetID())); |
81 host->Send(new ShellViewMsg_SetWebKitSourceDir(webkit_source_dir_)); | 81 host->Send(new ShellViewMsg_SetWebKitSourceDir(webkit_source_dir_)); |
82 } | 82 } |
83 | 83 |
| 84 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( |
| 85 BrowserContext* content_browser_context, |
| 86 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 87 blob_protocol_handler, |
| 88 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 89 file_system_protocol_handler, |
| 90 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 91 developer_protocol_handler, |
| 92 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 93 chrome_protocol_handler, |
| 94 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 95 chrome_devtools_protocol_handler) { |
| 96 ShellBrowserContext* shell_browser_context = |
| 97 ShellBrowserContextForBrowserContext(content_browser_context); |
| 98 return shell_browser_context->CreateRequestContext( |
| 99 blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(), |
| 100 developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(), |
| 101 chrome_devtools_protocol_handler.Pass()); |
| 102 } |
| 103 |
| 104 net::URLRequestContextGetter* |
| 105 ShellContentBrowserClient::CreateRequestContextForStoragePartition( |
| 106 BrowserContext* content_browser_context, |
| 107 const FilePath& partition_path, |
| 108 bool in_memory, |
| 109 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 110 blob_protocol_handler, |
| 111 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 112 file_system_protocol_handler, |
| 113 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 114 developer_protocol_handler, |
| 115 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 116 chrome_protocol_handler, |
| 117 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 118 chrome_devtools_protocol_handler) { |
| 119 ShellBrowserContext* shell_browser_context = |
| 120 ShellBrowserContextForBrowserContext(content_browser_context); |
| 121 return shell_browser_context->CreateRequestContextForStoragePartition( |
| 122 partition_path, in_memory, blob_protocol_handler.Pass(), |
| 123 file_system_protocol_handler.Pass(), |
| 124 developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(), |
| 125 chrome_devtools_protocol_handler.Pass()); |
| 126 } |
| 127 |
84 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( | 128 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( |
85 CommandLine* command_line, int child_process_id) { | 129 CommandLine* command_line, int child_process_id) { |
86 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 130 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
87 command_line->AppendSwitch(switches::kDumpRenderTree); | 131 command_line->AppendSwitch(switches::kDumpRenderTree); |
88 } | 132 } |
89 | 133 |
90 void ShellContentBrowserClient::OverrideWebkitPrefs( | 134 void ShellContentBrowserClient::OverrideWebkitPrefs( |
91 RenderViewHost* render_view_host, | 135 RenderViewHost* render_view_host, |
92 const GURL& url, | 136 const GURL& url, |
93 webkit_glue::WebPreferences* prefs) { | 137 webkit_glue::WebPreferences* prefs) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 203 |
160 ShellBrowserContext* | 204 ShellBrowserContext* |
161 ShellContentBrowserClient::off_the_record_browser_context() { | 205 ShellContentBrowserClient::off_the_record_browser_context() { |
162 return shell_browser_main_parts_->off_the_record_browser_context(); | 206 return shell_browser_main_parts_->off_the_record_browser_context(); |
163 } | 207 } |
164 | 208 |
165 AccessTokenStore* ShellContentBrowserClient::CreateAccessTokenStore() { | 209 AccessTokenStore* ShellContentBrowserClient::CreateAccessTokenStore() { |
166 return new ShellAccessTokenStore(browser_context()->GetRequestContext()); | 210 return new ShellAccessTokenStore(browser_context()->GetRequestContext()); |
167 } | 211 } |
168 | 212 |
| 213 ShellBrowserContext* |
| 214 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
| 215 BrowserContext* content_browser_context) { |
| 216 if (content_browser_context == browser_context()) |
| 217 return browser_context(); |
| 218 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
| 219 return off_the_record_browser_context(); |
| 220 } |
| 221 |
169 } // namespace content | 222 } // namespace content |
OLD | NEW |