| 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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/strings/pattern.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "content/public/browser/client_certificate_delegate.h" | 14 #include "content/public/browser/client_certificate_delegate.h" |
| 14 #include "content/public/browser/page_navigator.h" | 15 #include "content/public/browser/page_navigator.h" |
| 15 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/resource_dispatcher_host.h" | 17 #include "content/public/browser/resource_dispatcher_host.h" |
| 17 #include "content/public/browser/storage_partition.h" | 18 #include "content/public/browser/storage_partition.h" |
| 18 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 19 #include "content/public/common/url_constants.h" | 20 #include "content/public/common/url_constants.h" |
| 20 #include "content/public/common/web_preferences.h" | 21 #include "content/public/common/web_preferences.h" |
| 21 #include "content/public/test/test_mojo_app.h" | 22 #include "content/public/test/test_mojo_app.h" |
| 22 #include "content/shell/browser/blink_test_controller.h" | 23 #include "content/shell/browser/blink_test_controller.h" |
| 23 #include "content/shell/browser/layout_test/layout_test_browser_main_parts.h" | 24 #include "content/shell/browser/layout_test/layout_test_browser_main_parts.h" |
| 24 #include "content/shell/browser/layout_test/layout_test_resource_dispatcher_host
_delegate.h" | 25 #include "content/shell/browser/layout_test/layout_test_resource_dispatcher_host
_delegate.h" |
| 25 #include "content/shell/browser/shell.h" | 26 #include "content/shell/browser/shell.h" |
| 26 #include "content/shell/browser/shell_access_token_store.h" | 27 #include "content/shell/browser/shell_access_token_store.h" |
| 27 #include "content/shell/browser/shell_browser_context.h" | 28 #include "content/shell/browser/shell_browser_context.h" |
| 28 #include "content/shell/browser/shell_browser_main_parts.h" | 29 #include "content/shell/browser/shell_browser_main_parts.h" |
| 29 #include "content/shell/browser/shell_devtools_manager_delegate.h" | 30 #include "content/shell/browser/shell_devtools_manager_delegate.h" |
| 30 #include "content/shell/browser/shell_net_log.h" | 31 #include "content/shell/browser/shell_net_log.h" |
| 31 #include "content/shell/browser/shell_quota_permission_context.h" | 32 #include "content/shell/browser/shell_quota_permission_context.h" |
| 32 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" | 33 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" |
| 33 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" | 34 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" |
| 34 #include "content/shell/common/shell_messages.h" | 35 #include "content/shell/common/shell_messages.h" |
| 35 #include "content/shell/common/shell_switches.h" | 36 #include "content/shell/common/shell_switches.h" |
| 36 #include "net/url_request/url_request_context_getter.h" | 37 #include "net/url_request/url_request_context_getter.h" |
| 37 #include "url/gurl.h" | 38 #include "url/gurl.h" |
| 39 #include "url/origin.h" |
| 38 | 40 |
| 39 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
| 40 #include "base/android/apk_assets.h" | 42 #include "base/android/apk_assets.h" |
| 41 #include "base/android/path_utils.h" | 43 #include "base/android/path_utils.h" |
| 42 #include "components/crash/content/browser/crash_dump_manager_android.h" | 44 #include "components/crash/content/browser/crash_dump_manager_android.h" |
| 43 #include "content/shell/android/shell_descriptors.h" | 45 #include "content/shell/android/shell_descriptors.h" |
| 44 #endif | 46 #endif |
| 45 | 47 |
| 46 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 48 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 47 #include "base/debug/leak_annotations.h" | 49 #include "base/debug/leak_annotations.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 141 |
| 140 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( | 142 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( |
| 141 const MainFunctionParams& parameters) { | 143 const MainFunctionParams& parameters) { |
| 142 shell_browser_main_parts_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 144 shell_browser_main_parts_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 143 switches::kRunLayoutTest) | 145 switches::kRunLayoutTest) |
| 144 ? new LayoutTestBrowserMainParts(parameters) | 146 ? new LayoutTestBrowserMainParts(parameters) |
| 145 : new ShellBrowserMainParts(parameters); | 147 : new ShellBrowserMainParts(parameters); |
| 146 return shell_browser_main_parts_; | 148 return shell_browser_main_parts_; |
| 147 } | 149 } |
| 148 | 150 |
| 151 bool ShellContentBrowserClient::DoesSiteRequireDedicatedProcess( |
| 152 BrowserContext* browser_context, |
| 153 const GURL& effective_url) { |
| 154 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 155 DCHECK(command_line->HasSwitch(switches::kIsolateSitesForTesting)); |
| 156 std::string pattern = |
| 157 command_line->GetSwitchValueASCII(switches::kIsolateSitesForTesting); |
| 158 // Practically |origin| is the same as |effective_url.spec()|, except Origin |
| 159 // serialization strips the trailing "/", which makes for cleaner patterns. |
| 160 std::string origin = url::Origin(effective_url).Serialize(); |
| 161 return base::MatchPattern(origin, pattern); |
| 162 } |
| 163 |
| 149 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( | 164 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( |
| 150 BrowserContext* content_browser_context, | 165 BrowserContext* content_browser_context, |
| 151 ProtocolHandlerMap* protocol_handlers, | 166 ProtocolHandlerMap* protocol_handlers, |
| 152 URLRequestInterceptorScopedVector request_interceptors) { | 167 URLRequestInterceptorScopedVector request_interceptors) { |
| 153 ShellBrowserContext* shell_browser_context = | 168 ShellBrowserContext* shell_browser_context = |
| 154 ShellBrowserContextForBrowserContext(content_browser_context); | 169 ShellBrowserContextForBrowserContext(content_browser_context); |
| 155 return shell_browser_context->CreateRequestContext( | 170 return shell_browser_context->CreateRequestContext( |
| 156 protocol_handlers, request_interceptors.Pass()); | 171 protocol_handlers, request_interceptors.Pass()); |
| 157 } | 172 } |
| 158 | 173 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 switches::kCrashDumpsDir)); | 260 switches::kCrashDumpsDir)); |
| 246 } | 261 } |
| 247 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 262 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 248 switches::kEnableLeakDetection)) { | 263 switches::kEnableLeakDetection)) { |
| 249 command_line->AppendSwitchASCII( | 264 command_line->AppendSwitchASCII( |
| 250 switches::kEnableLeakDetection, | 265 switches::kEnableLeakDetection, |
| 251 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 266 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 252 switches::kEnableLeakDetection)); | 267 switches::kEnableLeakDetection)); |
| 253 } | 268 } |
| 254 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 269 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 270 switches::kIsolateSitesForTesting)) { |
| 271 command_line->AppendSwitchASCII( |
| 272 switches::kIsolateSitesForTesting, |
| 273 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 274 switches::kIsolateSitesForTesting)); |
| 275 } |
| 276 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 255 switches::kRegisterFontFiles)) { | 277 switches::kRegisterFontFiles)) { |
| 256 command_line->AppendSwitchASCII( | 278 command_line->AppendSwitchASCII( |
| 257 switches::kRegisterFontFiles, | 279 switches::kRegisterFontFiles, |
| 258 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 280 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 259 switches::kRegisterFontFiles)); | 281 switches::kRegisterFontFiles)); |
| 260 } | 282 } |
| 261 } | 283 } |
| 262 | 284 |
| 263 void ShellContentBrowserClient::OverrideWebkitPrefs( | 285 void ShellContentBrowserClient::OverrideWebkitPrefs( |
| 264 RenderViewHost* render_view_host, | 286 RenderViewHost* render_view_host, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 ShellBrowserContext* | 428 ShellBrowserContext* |
| 407 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 429 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
| 408 BrowserContext* content_browser_context) { | 430 BrowserContext* content_browser_context) { |
| 409 if (content_browser_context == browser_context()) | 431 if (content_browser_context == browser_context()) |
| 410 return browser_context(); | 432 return browser_context(); |
| 411 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 433 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
| 412 return off_the_record_browser_context(); | 434 return off_the_record_browser_context(); |
| 413 } | 435 } |
| 414 | 436 |
| 415 } // namespace content | 437 } // namespace content |
| OLD | NEW |