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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 150 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
151 DCHECK(command_line->HasSwitch(switches::kIsolateSitesForTesting)); | 151 DCHECK(command_line->HasSwitch(switches::kIsolateSitesForTesting)); |
152 std::string pattern = | 152 std::string pattern = |
153 command_line->GetSwitchValueASCII(switches::kIsolateSitesForTesting); | 153 command_line->GetSwitchValueASCII(switches::kIsolateSitesForTesting); |
154 // Practically |origin| is the same as |effective_url.spec()|, except Origin | 154 // Practically |origin| is the same as |effective_url.spec()|, except Origin |
155 // serialization strips the trailing "/", which makes for cleaner patterns. | 155 // serialization strips the trailing "/", which makes for cleaner patterns. |
156 std::string origin = url::Origin(effective_url).Serialize(); | 156 std::string origin = url::Origin(effective_url).Serialize(); |
157 return base::MatchPattern(origin, pattern); | 157 return base::MatchPattern(origin, pattern); |
158 } | 158 } |
159 | 159 |
160 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( | |
161 BrowserContext* content_browser_context, | |
162 ProtocolHandlerMap* protocol_handlers, | |
163 URLRequestInterceptorScopedVector request_interceptors) { | |
164 ShellBrowserContext* shell_browser_context = | |
165 ShellBrowserContextForBrowserContext(content_browser_context); | |
166 return shell_browser_context->CreateRequestContext( | |
167 protocol_handlers, std::move(request_interceptors)); | |
168 } | |
169 | |
170 net::URLRequestContextGetter* | |
171 ShellContentBrowserClient::CreateRequestContextForStoragePartition( | |
172 BrowserContext* content_browser_context, | |
173 const base::FilePath& partition_path, | |
174 bool in_memory, | |
175 ProtocolHandlerMap* protocol_handlers, | |
176 URLRequestInterceptorScopedVector request_interceptors) { | |
177 ShellBrowserContext* shell_browser_context = | |
178 ShellBrowserContextForBrowserContext(content_browser_context); | |
179 return shell_browser_context->CreateRequestContextForStoragePartition( | |
180 partition_path, in_memory, protocol_handlers, | |
181 std::move(request_interceptors)); | |
182 } | |
183 | |
184 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { | 160 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { |
185 if (!url.is_valid()) | 161 if (!url.is_valid()) |
186 return false; | 162 return false; |
187 // Keep in sync with ProtocolHandlers added by | 163 // Keep in sync with ProtocolHandlers added by |
188 // ShellURLRequestContextGetter::GetURLRequestContext(). | 164 // ShellURLRequestContextGetter::GetURLRequestContext(). |
189 static const char* const kProtocolList[] = { | 165 static const char* const kProtocolList[] = { |
190 url::kBlobScheme, | 166 url::kBlobScheme, |
191 url::kFileSystemScheme, | 167 url::kFileSystemScheme, |
192 kChromeUIScheme, | 168 kChromeUIScheme, |
193 kChromeDevToolsScheme, | 169 kChromeDevToolsScheme, |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 349 |
374 ShellBrowserContext* | 350 ShellBrowserContext* |
375 ShellContentBrowserClient::off_the_record_browser_context() { | 351 ShellContentBrowserClient::off_the_record_browser_context() { |
376 return shell_browser_main_parts_->off_the_record_browser_context(); | 352 return shell_browser_main_parts_->off_the_record_browser_context(); |
377 } | 353 } |
378 | 354 |
379 AccessTokenStore* ShellContentBrowserClient::CreateAccessTokenStore() { | 355 AccessTokenStore* ShellContentBrowserClient::CreateAccessTokenStore() { |
380 return new ShellAccessTokenStore(browser_context()); | 356 return new ShellAccessTokenStore(browser_context()); |
381 } | 357 } |
382 | 358 |
383 ShellBrowserContext* | |
384 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | |
385 BrowserContext* content_browser_context) { | |
386 if (content_browser_context == browser_context()) | |
387 return browser_context(); | |
388 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | |
389 return off_the_record_browser_context(); | |
390 } | |
391 | |
392 } // namespace content | 359 } // namespace content |
OLD | NEW |