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/webui/url_data_manager_backend.h" | 5 #include "content/browser/webui/url_data_manager_backend.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 } | 480 } |
481 return false; | 481 return false; |
482 } | 482 } |
483 | 483 |
484 class ChromeProtocolHandler | 484 class ChromeProtocolHandler |
485 : public net::URLRequestJobFactory::ProtocolHandler { | 485 : public net::URLRequestJobFactory::ProtocolHandler { |
486 public: | 486 public: |
487 // |is_incognito| should be set for incognito profiles. | 487 // |is_incognito| should be set for incognito profiles. |
488 ChromeProtocolHandler(ResourceContext* resource_context, | 488 ChromeProtocolHandler(ResourceContext* resource_context, |
489 bool is_incognito, | 489 bool is_incognito, |
490 AppCacheServiceImpl* appcache_service, | |
491 ChromeBlobStorageContext* blob_storage_context) | 490 ChromeBlobStorageContext* blob_storage_context) |
492 : resource_context_(resource_context), | 491 : resource_context_(resource_context), |
493 is_incognito_(is_incognito), | 492 is_incognito_(is_incognito), |
494 appcache_service_(appcache_service), | |
495 blob_storage_context_(blob_storage_context) {} | 493 blob_storage_context_(blob_storage_context) {} |
496 ~ChromeProtocolHandler() override {} | 494 ~ChromeProtocolHandler() override {} |
497 | 495 |
498 net::URLRequestJob* MaybeCreateJob( | 496 net::URLRequestJob* MaybeCreateJob( |
499 net::URLRequest* request, | 497 net::URLRequest* request, |
500 net::NetworkDelegate* network_delegate) const override { | 498 net::NetworkDelegate* network_delegate) const override { |
501 DCHECK(request); | 499 DCHECK(request); |
502 | 500 |
503 // Check for chrome://view-http-cache/*, which uses its own job type. | 501 // Check for chrome://view-http-cache/*, which uses its own job type. |
504 if (ViewHttpCacheJobFactory::IsSupportedURL(request->url())) | 502 if (ViewHttpCacheJobFactory::IsSupportedURL(request->url())) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 bool IsSafeRedirectTarget(const GURL& location) const override { | 542 bool IsSafeRedirectTarget(const GURL& location) const override { |
545 return false; | 543 return false; |
546 } | 544 } |
547 | 545 |
548 private: | 546 private: |
549 // These members are owned by ProfileIOData, which owns this ProtocolHandler. | 547 // These members are owned by ProfileIOData, which owns this ProtocolHandler. |
550 content::ResourceContext* const resource_context_; | 548 content::ResourceContext* const resource_context_; |
551 | 549 |
552 // True when generated from an incognito profile. | 550 // True when generated from an incognito profile. |
553 const bool is_incognito_; | 551 const bool is_incognito_; |
554 AppCacheServiceImpl* appcache_service_; | |
555 ChromeBlobStorageContext* blob_storage_context_; | 552 ChromeBlobStorageContext* blob_storage_context_; |
556 | 553 |
557 DISALLOW_COPY_AND_ASSIGN(ChromeProtocolHandler); | 554 DISALLOW_COPY_AND_ASSIGN(ChromeProtocolHandler); |
558 }; | 555 }; |
559 | 556 |
560 } // namespace | 557 } // namespace |
561 | 558 |
562 URLDataManagerBackend::URLDataManagerBackend() | 559 URLDataManagerBackend::URLDataManagerBackend() |
563 : next_request_id_(0) { | 560 : next_request_id_(0) { |
564 URLDataSource* shared_source = new SharedResourcesDataSource(); | 561 URLDataSource* shared_source = new SharedResourcesDataSource(); |
565 URLDataSourceImpl* source_impl = | 562 URLDataSourceImpl* source_impl = |
566 new URLDataSourceImpl(shared_source->GetSource(), shared_source); | 563 new URLDataSourceImpl(shared_source->GetSource(), shared_source); |
567 AddDataSource(source_impl); | 564 AddDataSource(source_impl); |
568 } | 565 } |
569 | 566 |
570 URLDataManagerBackend::~URLDataManagerBackend() { | 567 URLDataManagerBackend::~URLDataManagerBackend() { |
571 for (DataSourceMap::iterator i = data_sources_.begin(); | 568 for (DataSourceMap::iterator i = data_sources_.begin(); |
572 i != data_sources_.end(); ++i) { | 569 i != data_sources_.end(); ++i) { |
573 i->second->backend_ = NULL; | 570 i->second->backend_ = NULL; |
574 } | 571 } |
575 data_sources_.clear(); | 572 data_sources_.clear(); |
576 } | 573 } |
577 | 574 |
578 // static | 575 // static |
579 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 576 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
580 URLDataManagerBackend::CreateProtocolHandler( | 577 URLDataManagerBackend::CreateProtocolHandler( |
581 content::ResourceContext* resource_context, | 578 content::ResourceContext* resource_context, |
582 bool is_incognito, | 579 bool is_incognito, |
583 AppCacheServiceImpl* appcache_service, | |
584 ChromeBlobStorageContext* blob_storage_context) { | 580 ChromeBlobStorageContext* blob_storage_context) { |
585 DCHECK(resource_context); | 581 DCHECK(resource_context); |
586 return make_scoped_ptr(new ChromeProtocolHandler( | 582 return make_scoped_ptr(new ChromeProtocolHandler( |
587 resource_context, is_incognito, appcache_service, blob_storage_context)); | 583 resource_context, is_incognito, blob_storage_context)); |
588 } | 584 } |
589 | 585 |
590 void URLDataManagerBackend::AddDataSource( | 586 void URLDataManagerBackend::AddDataSource( |
591 URLDataSourceImpl* source) { | 587 URLDataSourceImpl* source) { |
592 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 588 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
593 DataSourceMap::iterator i = data_sources_.find(source->source_name()); | 589 DataSourceMap::iterator i = data_sources_.find(source->source_name()); |
594 if (i != data_sources_.end()) { | 590 if (i != data_sources_.end()) { |
595 if (!source->source()->ShouldReplaceExistingSource()) | 591 if (!source->source()->ShouldReplaceExistingSource()) |
596 return; | 592 return; |
597 i->second->backend_ = NULL; | 593 i->second->backend_ = NULL; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 | 797 |
802 } // namespace | 798 } // namespace |
803 | 799 |
804 net::URLRequestJobFactory::ProtocolHandler* | 800 net::URLRequestJobFactory::ProtocolHandler* |
805 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, | 801 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, |
806 bool is_incognito) { | 802 bool is_incognito) { |
807 return new DevToolsJobFactory(resource_context, is_incognito); | 803 return new DevToolsJobFactory(resource_context, is_incognito); |
808 } | 804 } |
809 | 805 |
810 } // namespace content | 806 } // namespace content |
OLD | NEW |