Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: content/browser/webui/url_data_manager_backend.cc

Issue 12386009: Remove the chrome:// protocol interceptor since it's not used anymore now that the chrome job facto… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/ref_counted_memory.h" 17 #include "base/memory/ref_counted_memory.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/message_loop.h" 19 #include "base/message_loop.h"
20 #include "base/string_util.h" 20 #include "base/string_util.h"
21 #include "content/browser/fileapi/chrome_blob_storage_context.h"
22 #include "content/browser/histogram_internals_request_job.h"
23 #include "content/browser/net/view_blob_internals_job_factory.h"
24 #include "content/browser/net/view_http_cache_job_factory.h"
21 #include "content/browser/resource_context_impl.h" 25 #include "content/browser/resource_context_impl.h"
26 #include "content/browser/tcmalloc_internals_request_job.h"
22 #include "content/browser/webui/shared_resources_data_source.h" 27 #include "content/browser/webui/shared_resources_data_source.h"
23 #include "content/browser/webui/url_data_source_impl.h" 28 #include "content/browser/webui/url_data_source_impl.h"
24 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
25 #include "content/public/common/url_constants.h" 30 #include "content/public/common/url_constants.h"
26 #include "googleurl/src/url_util.h" 31 #include "googleurl/src/url_util.h"
27 #include "net/base/io_buffer.h" 32 #include "net/base/io_buffer.h"
28 #include "net/base/net_errors.h" 33 #include "net/base/net_errors.h"
29 #include "net/http/http_response_headers.h" 34 #include "net/http/http_response_headers.h"
30 #include "net/url_request/url_request.h" 35 #include "net/url_request/url_request.h"
31 #include "net/url_request/url_request_context.h" 36 #include "net/url_request/url_request_context.h"
32 #include "net/url_request/url_request_job.h" 37 #include "net/url_request/url_request_job.h"
33 #include "net/url_request/url_request_job_factory.h" 38 #include "net/url_request/url_request_job_factory.h"
39 #include "webkit/appcache/view_appcache_internals_job.h"
40
41 using appcache::AppCacheService;
34 42
35 namespace content { 43 namespace content {
36 44
37 namespace { 45 namespace {
38 46
39 // TODO(tsepez) remove unsafe-eval when bidichecker_packaged.js fixed. 47 // TODO(tsepez) remove unsafe-eval when bidichecker_packaged.js fixed.
40 const char kChromeURLContentSecurityPolicyHeaderBase[] = 48 const char kChromeURLContentSecurityPolicyHeaderBase[] =
41 "Content-Security-Policy: script-src chrome://resources " 49 "Content-Security-Policy: script-src chrome://resources "
42 "'self' 'unsafe-eval'; "; 50 "'self' 'unsafe-eval'; ";
43 51
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 335 }
328 336
329 } // namespace 337 } // namespace
330 338
331 namespace { 339 namespace {
332 340
333 class ChromeProtocolHandler 341 class ChromeProtocolHandler
334 : public net::URLRequestJobFactory::ProtocolHandler { 342 : public net::URLRequestJobFactory::ProtocolHandler {
335 public: 343 public:
336 // |is_incognito| should be set for incognito profiles. 344 // |is_incognito| should be set for incognito profiles.
337 explicit ChromeProtocolHandler(content::ResourceContext* resource_context, 345 ChromeProtocolHandler(ResourceContext* resource_context,
338 bool is_incognito); 346 bool is_incognito,
339 virtual ~ChromeProtocolHandler(); 347 AppCacheService* appcache_service,
348 ChromeBlobStorageContext* blob_storage_context)
349 : resource_context_(resource_context),
350 is_incognito_(is_incognito),
351 appcache_service_(appcache_service),
352 blob_storage_context_(blob_storage_context) {}
353 virtual ~ChromeProtocolHandler() {}
340 354
341 virtual net::URLRequestJob* MaybeCreateJob( 355 virtual net::URLRequestJob* MaybeCreateJob(
342 net::URLRequest* request, 356 net::URLRequest* request,
343 net::NetworkDelegate* network_delegate) const OVERRIDE; 357 net::NetworkDelegate* network_delegate) const OVERRIDE {
358 DCHECK(request);
359
360 // Check for chrome://view-http-cache/*, which uses its own job type.
361 if (ViewHttpCacheJobFactory::IsSupportedURL(request->url()))
362 return ViewHttpCacheJobFactory::CreateJobForRequest(request,
363 network_delegate);
364
365 // Next check for chrome://appcache-internals/, which uses its own job type.
366 if (request->url().SchemeIs(chrome::kChromeUIScheme) &&
367 request->url().host() == chrome::kChromeUIAppCacheInternalsHost) {
368 return appcache::ViewAppCacheInternalsJobFactory::CreateJobForRequest(
369 request, network_delegate, appcache_service_);
370 }
371
372 // Next check for chrome://blob-internals/, which uses its own job type.
373 if (ViewBlobInternalsJobFactory::IsSupportedURL(request->url())) {
374 return ViewBlobInternalsJobFactory::CreateJobForRequest(
375 request, network_delegate, blob_storage_context_->controller());
376 }
377
378 #if defined(USE_TCMALLOC)
379 // Next check for chrome://tcmalloc/, which uses its own job type.
380 if (request->url().SchemeIs(chrome::kChromeUIScheme) &&
381 request->url().host() == chrome::kChromeUITcmallocHost) {
382 return new TcmallocInternalsRequestJob(request, network_delegate);
383 }
384 #endif
385
386 // Next check for chrome://histograms/, which uses its own job type.
387 if (request->url().SchemeIs(chrome::kChromeUIScheme) &&
388 request->url().host() == chrome::kChromeUIHistogramHost) {
389 return new HistogramInternalsRequestJob(request, network_delegate);
390 }
391
392 // Fall back to using a custom handler
393 return new URLRequestChromeJob(
394 request, network_delegate,
395 GetURLDataManagerForResourceContext(resource_context_), is_incognito_);
396 }
344 397
345 private: 398 private:
346 // These members are owned by ProfileIOData, which owns this ProtocolHandler. 399 // These members are owned by ProfileIOData, which owns this ProtocolHandler.
347 content::ResourceContext* const resource_context_; 400 content::ResourceContext* const resource_context_;
348 401
349 // True when generated from an incognito profile. 402 // True when generated from an incognito profile.
350 const bool is_incognito_; 403 const bool is_incognito_;
404 AppCacheService* appcache_service_;
405 ChromeBlobStorageContext* blob_storage_context_;
351 406
352 DISALLOW_COPY_AND_ASSIGN(ChromeProtocolHandler); 407 DISALLOW_COPY_AND_ASSIGN(ChromeProtocolHandler);
353 }; 408 };
354 409
355 ChromeProtocolHandler::ChromeProtocolHandler(
356 content::ResourceContext* resource_context, bool is_incognito)
357 : resource_context_(resource_context), is_incognito_(is_incognito) {}
358
359 ChromeProtocolHandler::~ChromeProtocolHandler() {}
360
361 net::URLRequestJob* ChromeProtocolHandler::MaybeCreateJob(
362 net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
363 DCHECK(request);
364
365 // Fall back to using a custom handler
366 return new URLRequestChromeJob(
367 request, network_delegate,
368 GetURLDataManagerForResourceContext(resource_context_), is_incognito_);
369 }
370
371 } // namespace 410 } // namespace
372 411
373 URLDataManagerBackend::URLDataManagerBackend() 412 URLDataManagerBackend::URLDataManagerBackend()
374 : next_request_id_(0) { 413 : next_request_id_(0) {
375 URLDataSource* shared_source = new SharedResourcesDataSource(); 414 URLDataSource* shared_source = new SharedResourcesDataSource();
376 URLDataSourceImpl* source_impl = 415 URLDataSourceImpl* source_impl =
377 new URLDataSourceImpl(shared_source->GetSource(), shared_source); 416 new URLDataSourceImpl(shared_source->GetSource(), shared_source);
378 AddDataSource(source_impl); 417 AddDataSource(source_impl);
379 } 418 }
380 419
381 URLDataManagerBackend::~URLDataManagerBackend() { 420 URLDataManagerBackend::~URLDataManagerBackend() {
382 for (DataSourceMap::iterator i = data_sources_.begin(); 421 for (DataSourceMap::iterator i = data_sources_.begin();
383 i != data_sources_.end(); ++i) { 422 i != data_sources_.end(); ++i) {
384 i->second->backend_ = NULL; 423 i->second->backend_ = NULL;
385 } 424 }
386 data_sources_.clear(); 425 data_sources_.clear();
387 } 426 }
388 427
389 // static 428 // static
390 net::URLRequestJobFactory::ProtocolHandler* 429 net::URLRequestJobFactory::ProtocolHandler*
391 URLDataManagerBackend::CreateProtocolHandler( 430 URLDataManagerBackend::CreateProtocolHandler(
392 content::ResourceContext* resource_context, bool is_incognito) { 431 content::ResourceContext* resource_context,
432 bool is_incognito,
433 AppCacheService* appcache_service,
434 ChromeBlobStorageContext* blob_storage_context) {
393 DCHECK(resource_context); 435 DCHECK(resource_context);
394 return new ChromeProtocolHandler(resource_context, is_incognito); 436 return new ChromeProtocolHandler(
437 resource_context, is_incognito, appcache_service, blob_storage_context);
395 } 438 }
396 439
397 void URLDataManagerBackend::AddDataSource( 440 void URLDataManagerBackend::AddDataSource(
398 URLDataSourceImpl* source) { 441 URLDataSourceImpl* source) {
399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 442 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
400 DataSourceMap::iterator i = data_sources_.find(source->source_name()); 443 DataSourceMap::iterator i = data_sources_.find(source->source_name());
401 if (i != data_sources_.end()) { 444 if (i != data_sources_.end()) {
402 if (!source->source()->ShouldReplaceExistingSource()) 445 if (!source->source()->ShouldReplaceExistingSource())
403 return; 446 return;
404 i->second->backend_ = NULL; 447 i->second->backend_ = NULL;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 605
563 } // namespace 606 } // namespace
564 607
565 net::URLRequestJobFactory::ProtocolHandler* 608 net::URLRequestJobFactory::ProtocolHandler*
566 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, 609 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context,
567 bool is_incognito) { 610 bool is_incognito) {
568 return new DevToolsJobFactory(resource_context, is_incognito); 611 return new DevToolsJobFactory(resource_context, is_incognito);
569 } 612 }
570 613
571 } // namespace content 614 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/webui/url_data_manager_backend.h ('k') | content/public/browser/content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698