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 "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" | 5 #include "chrome/browser/ui/webui/chrome_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/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
15 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "chrome/browser/net/chrome_url_request_context.h" | 20 #include "chrome/browser/net/chrome_url_request_context.h" |
21 #include "chrome/browser/net/view_blob_internals_job_factory.h" | 21 #include "chrome/browser/net/view_blob_internals_job_factory.h" |
22 #include "chrome/browser/net/view_http_cache_job_factory.h" | 22 #include "chrome/browser/net/view_http_cache_job_factory.h" |
23 #include "chrome/browser/ui/webui/shared_resources_data_source.h" | 23 #include "chrome/browser/ui/webui/shared_resources_data_source.h" |
24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
27 #include "content/browser/appcache/chrome_appcache_service.h" | |
28 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
29 #include "googleurl/src/url_util.h" | 28 #include "googleurl/src/url_util.h" |
30 #include "grit/platform_locale_settings.h" | 29 #include "grit/platform_locale_settings.h" |
31 #include "net/base/io_buffer.h" | 30 #include "net/base/io_buffer.h" |
32 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
33 #include "net/http/http_response_headers.h" | 32 #include "net/http/http_response_headers.h" |
34 #include "net/url_request/url_request.h" | 33 #include "net/url_request/url_request.h" |
35 #include "net/url_request/url_request_file_job.h" | 34 #include "net/url_request/url_request_file_job.h" |
36 #include "net/url_request/url_request_job.h" | 35 #include "net/url_request/url_request_job.h" |
37 #include "net/url_request/url_request_job_factory.h" | 36 #include "net/url_request/url_request_job_factory.h" |
| 37 #include "webkit/appcache/appcache_service.h" |
38 #include "webkit/appcache/view_appcache_internals_job.h" | 38 #include "webkit/appcache/view_appcache_internals_job.h" |
39 | 39 |
40 using content::BrowserThread; | 40 using content::BrowserThread; |
41 | 41 |
42 namespace { | 42 namespace { |
43 | 43 |
44 // X-WebKit-CSP is our development name for Content-Security-Policy. | 44 // X-WebKit-CSP is our development name for Content-Security-Policy. |
45 // TODO(tsepez) rename when Content-security-policy is done. | 45 // TODO(tsepez) rename when Content-security-policy is done. |
46 // TODO(tsepez) remove unsafe-eval when bidichecker_packaged.js fixed. | 46 // TODO(tsepez) remove unsafe-eval when bidichecker_packaged.js fixed. |
47 // TODO(tsepez) chrome-extension: permits the ChromeVox screen reader | 47 // TODO(tsepez) chrome-extension: permits the ChromeVox screen reader |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 bool IsViewAppCacheInternalsURL(const GURL& url) { | 322 bool IsViewAppCacheInternalsURL(const GURL& url) { |
323 return url.SchemeIs(chrome::kChromeUIScheme) && | 323 return url.SchemeIs(chrome::kChromeUIScheme) && |
324 url.host() == chrome::kChromeUIAppCacheInternalsHost; | 324 url.host() == chrome::kChromeUIAppCacheInternalsHost; |
325 } | 325 } |
326 | 326 |
327 class ChromeProtocolHandler | 327 class ChromeProtocolHandler |
328 : public net::URLRequestJobFactory::ProtocolHandler { | 328 : public net::URLRequestJobFactory::ProtocolHandler { |
329 public: | 329 public: |
330 ChromeProtocolHandler( | 330 ChromeProtocolHandler( |
331 ChromeURLDataManagerBackend* backend, | 331 ChromeURLDataManagerBackend* backend, |
332 ChromeAppCacheService* appcache_service, | 332 appcache::AppCacheService* appcache_service, |
333 webkit_blob::BlobStorageController* blob_storage_controller); | 333 webkit_blob::BlobStorageController* blob_storage_controller); |
334 ~ChromeProtocolHandler(); | 334 ~ChromeProtocolHandler(); |
335 | 335 |
336 virtual net::URLRequestJob* MaybeCreateJob( | 336 virtual net::URLRequestJob* MaybeCreateJob( |
337 net::URLRequest* request) const OVERRIDE; | 337 net::URLRequest* request) const OVERRIDE; |
338 | 338 |
339 private: | 339 private: |
340 // These members are owned by ProfileIOData, which owns this ProtocolHandler. | 340 // These members are owned by ProfileIOData, which owns this ProtocolHandler. |
341 ChromeURLDataManagerBackend* const backend_; | 341 ChromeURLDataManagerBackend* const backend_; |
342 ChromeAppCacheService* const appcache_service_; | 342 appcache::AppCacheService* const appcache_service_; |
343 webkit_blob::BlobStorageController* const blob_storage_controller_; | 343 webkit_blob::BlobStorageController* const blob_storage_controller_; |
344 | 344 |
345 DISALLOW_COPY_AND_ASSIGN(ChromeProtocolHandler); | 345 DISALLOW_COPY_AND_ASSIGN(ChromeProtocolHandler); |
346 }; | 346 }; |
347 | 347 |
348 ChromeProtocolHandler::ChromeProtocolHandler( | 348 ChromeProtocolHandler::ChromeProtocolHandler( |
349 ChromeURLDataManagerBackend* backend, | 349 ChromeURLDataManagerBackend* backend, |
350 ChromeAppCacheService* appcache_service, | 350 appcache::AppCacheService* appcache_service, |
351 webkit_blob::BlobStorageController* blob_storage_controller) | 351 webkit_blob::BlobStorageController* blob_storage_controller) |
352 : backend_(backend), | 352 : backend_(backend), |
353 appcache_service_(appcache_service), | 353 appcache_service_(appcache_service), |
354 blob_storage_controller_(blob_storage_controller) {} | 354 blob_storage_controller_(blob_storage_controller) {} |
355 | 355 |
356 ChromeProtocolHandler::~ChromeProtocolHandler() {} | 356 ChromeProtocolHandler::~ChromeProtocolHandler() {} |
357 | 357 |
358 net::URLRequestJob* ChromeProtocolHandler::MaybeCreateJob( | 358 net::URLRequestJob* ChromeProtocolHandler::MaybeCreateJob( |
359 net::URLRequest* request) const { | 359 net::URLRequest* request) const { |
360 DCHECK(request); | 360 DCHECK(request); |
(...skipping 28 matching lines...) Expand all Loading... |
389 i != data_sources_.end(); ++i) { | 389 i != data_sources_.end(); ++i) { |
390 i->second->backend_ = NULL; | 390 i->second->backend_ = NULL; |
391 } | 391 } |
392 data_sources_.clear(); | 392 data_sources_.clear(); |
393 } | 393 } |
394 | 394 |
395 // static | 395 // static |
396 net::URLRequestJobFactory::ProtocolHandler* | 396 net::URLRequestJobFactory::ProtocolHandler* |
397 ChromeURLDataManagerBackend::CreateProtocolHandler( | 397 ChromeURLDataManagerBackend::CreateProtocolHandler( |
398 ChromeURLDataManagerBackend* backend, | 398 ChromeURLDataManagerBackend* backend, |
399 ChromeAppCacheService* appcache_service, | 399 appcache::AppCacheService* appcache_service, |
400 webkit_blob::BlobStorageController* blob_storage_controller) { | 400 webkit_blob::BlobStorageController* blob_storage_controller) { |
401 DCHECK(appcache_service); | 401 DCHECK(appcache_service); |
402 DCHECK(blob_storage_controller); | 402 DCHECK(blob_storage_controller); |
403 DCHECK(backend); | 403 DCHECK(backend); |
404 return new ChromeProtocolHandler( | 404 return new ChromeProtocolHandler( |
405 backend, appcache_service, blob_storage_controller); | 405 backend, appcache_service, blob_storage_controller); |
406 } | 406 } |
407 | 407 |
408 void ChromeURLDataManagerBackend::AddDataSource( | 408 void ChromeURLDataManagerBackend::AddDataSource( |
409 ChromeURLDataManager::DataSource* source) { | 409 ChromeURLDataManager::DataSource* source) { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 | 587 |
588 return new URLRequestChromeJob(request, backend_); | 588 return new URLRequestChromeJob(request, backend_); |
589 } | 589 } |
590 | 590 |
591 } // namespace | 591 } // namespace |
592 | 592 |
593 net::URLRequestJobFactory::ProtocolHandler* | 593 net::URLRequestJobFactory::ProtocolHandler* |
594 CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend) { | 594 CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend) { |
595 return new DevToolsJobFactory(backend); | 595 return new DevToolsJobFactory(backend); |
596 } | 596 } |
OLD | NEW |