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/common/shell_messages.h" | 17 #include "content/shell/common/shell_messages.h" |
17 #include "content/shell/common/shell_switches.h" | 18 #include "content/shell/common/shell_switches.h" |
18 #include "content/shell/common/webkit_test_helpers.h" | 19 #include "content/shell/common/webkit_test_helpers.h" |
19 #include "content/shell/geolocation/shell_access_token_store.h" | 20 #include "content/shell/geolocation/shell_access_token_store.h" |
20 #include "content/shell/shell.h" | 21 #include "content/shell/shell.h" |
21 #include "content/shell/shell_browser_context.h" | 22 #include "content/shell/shell_browser_context.h" |
22 #include "content/shell/shell_browser_main_parts.h" | 23 #include "content/shell/shell_browser_main_parts.h" |
23 #include "content/shell/shell_devtools_delegate.h" | 24 #include "content/shell/shell_devtools_delegate.h" |
24 #include "content/shell/shell_message_filter.h" | 25 #include "content/shell/shell_message_filter.h" |
25 #include "content/shell/shell_quota_permission_context.h" | 26 #include "content/shell/shell_quota_permission_context.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 BrowserContext* content_browser_context, | 106 BrowserContext* content_browser_context, |
106 const base::FilePath& partition_path, | 107 const base::FilePath& partition_path, |
107 bool in_memory, | 108 bool in_memory, |
108 ProtocolHandlerMap* protocol_handlers) { | 109 ProtocolHandlerMap* protocol_handlers) { |
109 ShellBrowserContext* shell_browser_context = | 110 ShellBrowserContext* shell_browser_context = |
110 ShellBrowserContextForBrowserContext(content_browser_context); | 111 ShellBrowserContextForBrowserContext(content_browser_context); |
111 return shell_browser_context->CreateRequestContextForStoragePartition( | 112 return shell_browser_context->CreateRequestContextForStoragePartition( |
112 partition_path, in_memory, protocol_handlers); | 113 partition_path, in_memory, protocol_handlers); |
113 } | 114 } |
114 | 115 |
| 116 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { |
| 117 if (!url.is_valid()) |
| 118 return false; |
| 119 DCHECK_EQ(url.scheme(), StringToLowerASCII(url.scheme())); |
| 120 // Keep in sync with ProtocolHandlers added by |
| 121 // ShellURLRequestContextGetter::GetURLRequestContext(). |
| 122 static const char* const kProtocolList[] = { |
| 123 chrome::kBlobScheme, |
| 124 chrome::kFileSystemScheme, |
| 125 chrome::kChromeUIScheme, |
| 126 chrome::kChromeDevToolsScheme, |
| 127 chrome::kDataScheme, |
| 128 chrome::kFileScheme, |
| 129 }; |
| 130 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { |
| 131 if (url.scheme() == kProtocolList[i]) |
| 132 return true; |
| 133 } |
| 134 return false; |
| 135 } |
| 136 |
115 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( | 137 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( |
116 CommandLine* command_line, int child_process_id) { | 138 CommandLine* command_line, int child_process_id) { |
117 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 139 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
118 command_line->AppendSwitch(switches::kDumpRenderTree); | 140 command_line->AppendSwitch(switches::kDumpRenderTree); |
119 } | 141 } |
120 | 142 |
121 void ShellContentBrowserClient::OverrideWebkitPrefs( | 143 void ShellContentBrowserClient::OverrideWebkitPrefs( |
122 RenderViewHost* render_view_host, | 144 RenderViewHost* render_view_host, |
123 const GURL& url, | 145 const GURL& url, |
124 WebPreferences* prefs) { | 146 WebPreferences* prefs) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 ShellBrowserContext* | 242 ShellBrowserContext* |
221 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 243 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
222 BrowserContext* content_browser_context) { | 244 BrowserContext* content_browser_context) { |
223 if (content_browser_context == browser_context()) | 245 if (content_browser_context == browser_context()) |
224 return browser_context(); | 246 return browser_context(); |
225 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 247 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
226 return off_the_record_browser_context(); | 248 return off_the_record_browser_context(); |
227 } | 249 } |
228 | 250 |
229 } // namespace content | 251 } // namespace content |
OLD | NEW |