| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 138 } |
| 139 | 139 |
| 140 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( | 140 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( |
| 141 const MainFunctionParams& parameters) { | 141 const MainFunctionParams& parameters) { |
| 142 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); | 142 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); |
| 143 return shell_browser_main_parts_; | 143 return shell_browser_main_parts_; |
| 144 } | 144 } |
| 145 | 145 |
| 146 bool ShellContentBrowserClient::DoesSiteRequireDedicatedProcess( | 146 bool ShellContentBrowserClient::DoesSiteRequireDedicatedProcess( |
| 147 BrowserContext* browser_context, | 147 BrowserContext* browser_context, |
| 148 const GURL& effective_url) { | 148 const GURL& effective_site_url) { |
| 149 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 149 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 150 DCHECK(command_line->HasSwitch(switches::kIsolateSitesForTesting)); | 150 DCHECK(command_line->HasSwitch(switches::kIsolateSitesForTesting)); |
| 151 std::string pattern = | 151 std::string pattern = |
| 152 command_line->GetSwitchValueASCII(switches::kIsolateSitesForTesting); | 152 command_line->GetSwitchValueASCII(switches::kIsolateSitesForTesting); |
| 153 // Practically |origin| is the same as |effective_url.spec()|, except Origin | 153 url::Origin origin(effective_site_url); |
| 154 // serialization strips the trailing "/", which makes for cleaner patterns. | 154 |
| 155 std::string origin = url::Origin(effective_url).Serialize(); | 155 // Schemes like blob or filesystem, which have an embedded origin, should |
| 156 return base::MatchPattern(origin, pattern); | 156 // already have been canonicalized to the origin site. |
| 157 CHECK_EQ(origin.scheme(), effective_site_url.scheme()) |
| 158 << "a site url should have the same scheme as its origin."; |
| 159 |
| 160 // Practically |origin.Serialize()| is the same as |
| 161 // |effective_site_url.spec()|, except Origin serialization strips the |
| 162 // trailing "/", which makes for cleaner wildcard patterns. |
| 163 return base::MatchPattern(origin.Serialize(), pattern); |
| 157 } | 164 } |
| 158 | 165 |
| 159 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { | 166 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { |
| 160 if (!url.is_valid()) | 167 if (!url.is_valid()) |
| 161 return false; | 168 return false; |
| 162 // Keep in sync with ProtocolHandlers added by | 169 // Keep in sync with ProtocolHandlers added by |
| 163 // ShellURLRequestContextGetter::GetURLRequestContext(). | 170 // ShellURLRequestContextGetter::GetURLRequestContext(). |
| 164 static const char* const kProtocolList[] = { | 171 static const char* const kProtocolList[] = { |
| 165 url::kBlobScheme, | 172 url::kBlobScheme, |
| 166 url::kFileSystemScheme, | 173 url::kFileSystemScheme, |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 ShellBrowserContext* ShellContentBrowserClient::browser_context() { | 349 ShellBrowserContext* ShellContentBrowserClient::browser_context() { |
| 343 return shell_browser_main_parts_->browser_context(); | 350 return shell_browser_main_parts_->browser_context(); |
| 344 } | 351 } |
| 345 | 352 |
| 346 ShellBrowserContext* | 353 ShellBrowserContext* |
| 347 ShellContentBrowserClient::off_the_record_browser_context() { | 354 ShellContentBrowserClient::off_the_record_browser_context() { |
| 348 return shell_browser_main_parts_->off_the_record_browser_context(); | 355 return shell_browser_main_parts_->off_the_record_browser_context(); |
| 349 } | 356 } |
| 350 | 357 |
| 351 } // namespace content | 358 } // namespace content |
| OLD | NEW |