| 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/browser/storage_partition_impl_map.h" | 5 #include "content/browser/storage_partition_impl_map.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 #endif | 162 #endif |
| 163 | 163 |
| 164 base::FilePath GetStoragePartitionDomainPath( | 164 base::FilePath GetStoragePartitionDomainPath( |
| 165 const std::string& partition_domain) { | 165 const std::string& partition_domain) { |
| 166 CHECK(base::IsStringUTF8(partition_domain)); | 166 CHECK(base::IsStringUTF8(partition_domain)); |
| 167 | 167 |
| 168 return base::FilePath(kStoragePartitionDirname).Append(kExtensionsDirname) | 168 return base::FilePath(kStoragePartitionDirname).Append(kExtensionsDirname) |
| 169 .Append(base::FilePath::FromUTF8Unsafe(partition_domain)); | 169 .Append(base::FilePath::FromUTF8Unsafe(partition_domain)); |
| 170 } | 170 } |
| 171 | 171 |
| 172 #if DCHECK_IS_ON() |
| 173 bool IsBuiltInProtocol(const std::string& scheme) { |
| 174 GURL scheme_as_gurl(scheme + url::kStandardSchemeSeparator); |
| 175 DCHECK(scheme_as_gurl.is_valid()) << scheme; |
| 176 return GetContentClient()->browser()->IsHandledURL(scheme_as_gurl); |
| 177 } |
| 178 #endif |
| 179 |
| 172 // Helper function for doing a depth-first deletion of the data on disk. | 180 // Helper function for doing a depth-first deletion of the data on disk. |
| 173 // Examines paths directly in |current_dir| (no recursion) and tries to | 181 // Examines paths directly in |current_dir| (no recursion) and tries to |
| 174 // delete from disk anything that is in, or isn't a parent of something in | 182 // delete from disk anything that is in, or isn't a parent of something in |
| 175 // |paths_to_keep|. Paths that need further expansion are added to | 183 // |paths_to_keep|. Paths that need further expansion are added to |
| 176 // |paths_to_consider|. | 184 // |paths_to_consider|. |
| 177 void ObliterateOneDirectory(const base::FilePath& current_dir, | 185 void ObliterateOneDirectory(const base::FilePath& current_dir, |
| 178 const std::vector<base::FilePath>& paths_to_keep, | 186 const std::vector<base::FilePath>& paths_to_keep, |
| 179 std::vector<base::FilePath>* paths_to_consider) { | 187 std::vector<base::FilePath>* paths_to_consider) { |
| 180 CHECK(current_dir.IsAbsolute()); | 188 CHECK(current_dir.IsAbsolute()); |
| 181 | 189 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 additional_webui_schemes.begin(); | 437 additional_webui_schemes.begin(); |
| 430 it != additional_webui_schemes.end(); | 438 it != additional_webui_schemes.end(); |
| 431 ++it) { | 439 ++it) { |
| 432 protocol_handlers[*it] = | 440 protocol_handlers[*it] = |
| 433 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( | 441 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
| 434 URLDataManagerBackend::CreateProtocolHandler( | 442 URLDataManagerBackend::CreateProtocolHandler( |
| 435 browser_context_->GetResourceContext(), | 443 browser_context_->GetResourceContext(), |
| 436 browser_context_->IsOffTheRecord(), | 444 browser_context_->IsOffTheRecord(), |
| 437 blob_storage_context).release()); | 445 blob_storage_context).release()); |
| 438 } | 446 } |
| 447 |
| 439 protocol_handlers[kChromeDevToolsScheme] = | 448 protocol_handlers[kChromeDevToolsScheme] = |
| 440 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( | 449 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
| 441 CreateDevToolsProtocolHandler(browser_context_->GetResourceContext(), | 450 CreateDevToolsProtocolHandler(browser_context_->GetResourceContext(), |
| 442 browser_context_->IsOffTheRecord())); | 451 browser_context_->IsOffTheRecord())); |
| 443 | 452 |
| 453 #if DCHECK_IS_ON() |
| 454 // The ContentBrowserClient's implementation of IsHandledURL must know about |
| 455 // all protocols handled by the content layer. |
| 456 for (const auto& handler : protocol_handlers) |
| 457 DCHECK(IsBuiltInProtocol(handler.first)) << handler.first; |
| 458 #endif // DCHECK_IS_ON() |
| 459 |
| 444 URLRequestInterceptorScopedVector request_interceptors; | 460 URLRequestInterceptorScopedVector request_interceptors; |
| 445 request_interceptors.push_back( | 461 request_interceptors.push_back( |
| 446 ServiceWorkerRequestHandler::CreateInterceptor( | 462 ServiceWorkerRequestHandler::CreateInterceptor( |
| 447 browser_context_->GetResourceContext()).release()); | 463 browser_context_->GetResourceContext()).release()); |
| 448 if (ForeignFetchRequestHandler::IsForeignFetchEnabled()) { | 464 if (ForeignFetchRequestHandler::IsForeignFetchEnabled()) { |
| 449 request_interceptors.push_back( | 465 request_interceptors.push_back( |
| 450 ForeignFetchRequestHandler::CreateInterceptor( | 466 ForeignFetchRequestHandler::CreateInterceptor( |
| 451 browser_context_->GetResourceContext()) | 467 browser_context_->GetResourceContext()) |
| 452 .release()); | 468 .release()); |
| 453 } | 469 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 | 621 |
| 606 // We do not call InitializeURLRequestContext() for media contexts because, | 622 // We do not call InitializeURLRequestContext() for media contexts because, |
| 607 // other than the HTTP cache, the media contexts share the same backing | 623 // other than the HTTP cache, the media contexts share the same backing |
| 608 // objects as their associated "normal" request context. Thus, the previous | 624 // objects as their associated "normal" request context. Thus, the previous |
| 609 // call serves to initialize the media request context for this storage | 625 // call serves to initialize the media request context for this storage |
| 610 // partition as well. | 626 // partition as well. |
| 611 } | 627 } |
| 612 } | 628 } |
| 613 | 629 |
| 614 } // namespace content | 630 } // namespace content |
| OLD | NEW |