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/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
11 #include "content/public/browser/notification_types.h" | 11 #include "content/public/browser/notification_types.h" |
12 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
13 #include "content/public/browser/resource_dispatcher_host.h" | 13 #include "content/public/browser/resource_dispatcher_host.h" |
14 #include "content/public/browser/storage_partition.h" | 14 #include "content/public/browser/storage_partition.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
| 16 #include "content/public/common/url_constants.h" |
16 #include "content/shell/geolocation/shell_access_token_store.h" | 17 #include "content/shell/geolocation/shell_access_token_store.h" |
17 #include "content/shell/shell.h" | 18 #include "content/shell/shell.h" |
18 #include "content/shell/shell_browser_context.h" | 19 #include "content/shell/shell_browser_context.h" |
19 #include "content/shell/shell_browser_main_parts.h" | 20 #include "content/shell/shell_browser_main_parts.h" |
20 #include "content/shell/shell_devtools_delegate.h" | 21 #include "content/shell/shell_devtools_delegate.h" |
21 #include "content/shell/shell_message_filter.h" | 22 #include "content/shell/shell_message_filter.h" |
22 #include "content/shell/shell_messages.h" | 23 #include "content/shell/shell_messages.h" |
23 #include "content/shell/shell_quota_permission_context.h" | 24 #include "content/shell/shell_quota_permission_context.h" |
24 #include "content/shell/shell_resource_dispatcher_host_delegate.h" | 25 #include "content/shell/shell_resource_dispatcher_host_delegate.h" |
25 #include "content/shell/shell_switches.h" | 26 #include "content/shell/shell_switches.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 BrowserContext* content_browser_context, | 138 BrowserContext* content_browser_context, |
138 const base::FilePath& partition_path, | 139 const base::FilePath& partition_path, |
139 bool in_memory, | 140 bool in_memory, |
140 ProtocolHandlerMap* protocol_handlers) { | 141 ProtocolHandlerMap* protocol_handlers) { |
141 ShellBrowserContext* shell_browser_context = | 142 ShellBrowserContext* shell_browser_context = |
142 ShellBrowserContextForBrowserContext(content_browser_context); | 143 ShellBrowserContextForBrowserContext(content_browser_context); |
143 return shell_browser_context->CreateRequestContextForStoragePartition( | 144 return shell_browser_context->CreateRequestContextForStoragePartition( |
144 partition_path, in_memory, protocol_handlers); | 145 partition_path, in_memory, protocol_handlers); |
145 } | 146 } |
146 | 147 |
| 148 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { |
| 149 if (!url.is_valid()) |
| 150 return false; |
| 151 DCHECK_EQ(url.scheme(), StringToLowerASCII(url.scheme())); |
| 152 // Keep in sync with ProtocolHandlers added by |
| 153 // ShellURLRequestContextGetter::GetURLRequestContext(). |
| 154 static const char* const kProtocolList[] = { |
| 155 chrome::kBlobScheme, |
| 156 chrome::kFileSystemScheme, |
| 157 chrome::kChromeUIScheme, |
| 158 chrome::kChromeDevToolsScheme, |
| 159 chrome::kDataScheme, |
| 160 chrome::kFileScheme, |
| 161 }; |
| 162 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { |
| 163 if (url.scheme() == kProtocolList[i]) |
| 164 return true; |
| 165 } |
| 166 return false; |
| 167 } |
| 168 |
147 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( | 169 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( |
148 CommandLine* command_line, int child_process_id) { | 170 CommandLine* command_line, int child_process_id) { |
149 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 171 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
150 command_line->AppendSwitch(switches::kDumpRenderTree); | 172 command_line->AppendSwitch(switches::kDumpRenderTree); |
151 } | 173 } |
152 | 174 |
153 void ShellContentBrowserClient::OverrideWebkitPrefs( | 175 void ShellContentBrowserClient::OverrideWebkitPrefs( |
154 RenderViewHost* render_view_host, | 176 RenderViewHost* render_view_host, |
155 const GURL& url, | 177 const GURL& url, |
156 webkit_glue::WebPreferences* prefs) { | 178 webkit_glue::WebPreferences* prefs) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 ShellBrowserContext* | 274 ShellBrowserContext* |
253 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 275 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
254 BrowserContext* content_browser_context) { | 276 BrowserContext* content_browser_context) { |
255 if (content_browser_context == browser_context()) | 277 if (content_browser_context == browser_context()) |
256 return browser_context(); | 278 return browser_context(); |
257 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 279 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
258 return off_the_record_browser_context(); | 280 return off_the_record_browser_context(); |
259 } | 281 } |
260 | 282 |
261 } // namespace content | 283 } // namespace content |
OLD | NEW |