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" |
11 #include "content/public/browser/resource_dispatcher_host.h" | 11 #include "content/public/browser/resource_dispatcher_host.h" |
12 #include "content/public/browser/storage_partition.h" | 12 #include "content/public/browser/storage_partition.h" |
13 #include "content/public/common/url_constants.h" | |
14 #include "content/shell/geolocation/shell_access_token_store.h" | 13 #include "content/shell/geolocation/shell_access_token_store.h" |
15 #include "content/shell/shell.h" | 14 #include "content/shell/shell.h" |
16 #include "content/shell/shell_browser_context.h" | 15 #include "content/shell/shell_browser_context.h" |
17 #include "content/shell/shell_browser_main_parts.h" | 16 #include "content/shell/shell_browser_main_parts.h" |
18 #include "content/shell/shell_devtools_delegate.h" | 17 #include "content/shell/shell_devtools_delegate.h" |
19 #include "content/shell/shell_message_filter.h" | 18 #include "content/shell/shell_message_filter.h" |
20 #include "content/shell/shell_messages.h" | 19 #include "content/shell/shell_messages.h" |
21 #include "content/shell/shell_resource_dispatcher_host_delegate.h" | 20 #include "content/shell/shell_resource_dispatcher_host_delegate.h" |
22 #include "content/shell/shell_switches.h" | 21 #include "content/shell/shell_switches.h" |
23 #include "content/shell/shell_web_contents_view_delegate_creator.h" | 22 #include "content/shell/shell_web_contents_view_delegate_creator.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 BrowserContext* content_browser_context, | 127 BrowserContext* content_browser_context, |
129 const base::FilePath& partition_path, | 128 const base::FilePath& partition_path, |
130 bool in_memory, | 129 bool in_memory, |
131 ProtocolHandlerMap* protocol_handlers) { | 130 ProtocolHandlerMap* protocol_handlers) { |
132 ShellBrowserContext* shell_browser_context = | 131 ShellBrowserContext* shell_browser_context = |
133 ShellBrowserContextForBrowserContext(content_browser_context); | 132 ShellBrowserContextForBrowserContext(content_browser_context); |
134 return shell_browser_context->CreateRequestContextForStoragePartition( | 133 return shell_browser_context->CreateRequestContextForStoragePartition( |
135 partition_path, in_memory, protocol_handlers); | 134 partition_path, in_memory, protocol_handlers); |
136 } | 135 } |
137 | 136 |
138 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { | |
139 if (!url.is_valid()) | |
140 return false; | |
141 DCHECK_EQ(url.scheme(), StringToLowerASCII(url.scheme())); | |
142 // Keep in sync with ProtocolHandlers added by | |
143 // ShellURLRequestContextGetter::GetURLRequestContext(). | |
144 static const char* const kProtocolList[] = { | |
145 chrome::kBlobScheme, | |
146 chrome::kFileSystemScheme, | |
147 chrome::kChromeUIScheme, | |
148 chrome::kChromeDevToolsScheme, | |
149 chrome::kDataScheme, | |
150 chrome::kFileScheme, | |
151 }; | |
152 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { | |
153 if (url.scheme() == kProtocolList[i]) | |
154 return true; | |
155 } | |
156 return false; | |
157 } | |
158 | |
159 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( | 137 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( |
160 CommandLine* command_line, int child_process_id) { | 138 CommandLine* command_line, int child_process_id) { |
161 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 139 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
162 command_line->AppendSwitch(switches::kDumpRenderTree); | 140 command_line->AppendSwitch(switches::kDumpRenderTree); |
163 } | 141 } |
164 | 142 |
165 void ShellContentBrowserClient::OverrideWebkitPrefs( | 143 void ShellContentBrowserClient::OverrideWebkitPrefs( |
166 RenderViewHost* render_view_host, | 144 RenderViewHost* render_view_host, |
167 const GURL& url, | 145 const GURL& url, |
168 webkit_glue::WebPreferences* prefs) { | 146 webkit_glue::WebPreferences* prefs) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 ShellBrowserContext* | 209 ShellBrowserContext* |
232 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 210 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
233 BrowserContext* content_browser_context) { | 211 BrowserContext* content_browser_context) { |
234 if (content_browser_context == browser_context()) | 212 if (content_browser_context == browser_context()) |
235 return browser_context(); | 213 return browser_context(); |
236 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 214 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
237 return off_the_record_browser_context(); | 215 return off_the_record_browser_context(); |
238 } | 216 } |
239 | 217 |
240 } // namespace content | 218 } // namespace content |
OLD | NEW |