| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "chrome/browser/net/chrome_url_request_context.h" | 14 #include "chrome/browser/net/chrome_url_request_context.h" |
| 15 #include "chrome/browser/net/view_blob_internals_job_factory.h" | 15 #include "chrome/browser/net/view_blob_internals_job_factory.h" |
| 16 #include "chrome/browser/net/view_http_cache_job_factory.h" | 16 #include "chrome/browser/net/view_http_cache_job_factory.h" |
| 17 #include "chrome/browser/ui/webui/shared_resources_data_source.h" | 17 #include "chrome/browser/ui/webui/shared_resources_data_source.h" |
| 18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 21 #include "content/browser/appcache/view_appcache_internals_job_factory.h" | |
| 22 #include "content/browser/browser_thread.h" | 21 #include "content/browser/browser_thread.h" |
| 23 #include "googleurl/src/url_util.h" | 22 #include "googleurl/src/url_util.h" |
| 24 #include "grit/platform_locale_settings.h" | 23 #include "grit/platform_locale_settings.h" |
| 25 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
| 26 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 27 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
| 28 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
| 29 #include "net/url_request/url_request_file_job.h" | 28 #include "net/url_request/url_request_file_job.h" |
| 30 #include "net/url_request/url_request_job.h" | 29 #include "net/url_request/url_request_job.h" |
| 30 #include "webkit/appcache/view_appcache_internals_job.h" |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 ChromeURLDataManagerBackend* GetBackend(net::URLRequest* request) { | 34 ChromeURLDataManagerBackend* GetBackend(net::URLRequest* request) { |
| 35 return static_cast<ChromeURLRequestContext*>(request->context())-> | 35 return static_cast<ChromeURLRequestContext*>(request->context())-> |
| 36 GetChromeURLDataManagerBackend(); | 36 GetChromeURLDataManagerBackend(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Parse a URL into the components used to resolve its request. |source_name| | 39 // Parse a URL into the components used to resolve its request. |source_name| |
| 40 // is the hostname and |path| is the remaining portion of the URL. | 40 // is the hostname and |path| is the remaining portion of the URL. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 55 | 55 |
| 56 const std::string& spec = url.possibly_invalid_spec(); | 56 const std::string& spec = url.possibly_invalid_spec(); |
| 57 const url_parse::Parsed& parsed = url.parsed_for_possibly_invalid_spec(); | 57 const url_parse::Parsed& parsed = url.parsed_for_possibly_invalid_spec(); |
| 58 // + 1 to skip the slash at the beginning of the path. | 58 // + 1 to skip the slash at the beginning of the path. |
| 59 int offset = parsed.CountCharactersBefore(url_parse::Parsed::PATH, false) + 1; | 59 int offset = parsed.CountCharactersBefore(url_parse::Parsed::PATH, false) + 1; |
| 60 | 60 |
| 61 if (offset < static_cast<int>(spec.size())) | 61 if (offset < static_cast<int>(spec.size())) |
| 62 path->assign(spec.substr(offset)); | 62 path->assign(spec.substr(offset)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool IsViewAppCacheInternalsURL(const GURL& url) { |
| 66 return StartsWithASCII(url.spec(), |
| 67 chrome::kAppCacheViewInternalsURL, |
| 68 true /*case_sensitive*/); |
| 69 } |
| 70 |
| 65 } // namespace | 71 } // namespace |
| 66 | 72 |
| 67 // URLRequestChromeJob is a net::URLRequestJob that manages running | 73 // URLRequestChromeJob is a net::URLRequestJob that manages running |
| 68 // chrome-internal resource requests asynchronously. | 74 // chrome-internal resource requests asynchronously. |
| 69 // It hands off URL requests to ChromeURLDataManager, which asynchronously | 75 // It hands off URL requests to ChromeURLDataManager, which asynchronously |
| 70 // calls back once the data is available. | 76 // calls back once the data is available. |
| 71 class URLRequestChromeJob : public net::URLRequestJob { | 77 class URLRequestChromeJob : public net::URLRequestJob { |
| 72 public: | 78 public: |
| 73 explicit URLRequestChromeJob(net::URLRequest* request); | 79 explicit URLRequestChromeJob(net::URLRequest* request); |
| 74 | 80 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 FilePath path; | 273 FilePath path; |
| 268 if (DevToolsJobFactory::IsSupportedURL(request->url(), &path)) | 274 if (DevToolsJobFactory::IsSupportedURL(request->url(), &path)) |
| 269 return DevToolsJobFactory::CreateJobForRequest(request, path); | 275 return DevToolsJobFactory::CreateJobForRequest(request, path); |
| 270 } | 276 } |
| 271 | 277 |
| 272 // Next check for chrome://view-http-cache/*, which uses its own job type. | 278 // Next check for chrome://view-http-cache/*, which uses its own job type. |
| 273 if (ViewHttpCacheJobFactory::IsSupportedURL(request->url())) | 279 if (ViewHttpCacheJobFactory::IsSupportedURL(request->url())) |
| 274 return ViewHttpCacheJobFactory::CreateJobForRequest(request); | 280 return ViewHttpCacheJobFactory::CreateJobForRequest(request); |
| 275 | 281 |
| 276 // Next check for chrome://appcache-internals/, which uses its own job type. | 282 // Next check for chrome://appcache-internals/, which uses its own job type. |
| 277 if (ViewAppCacheInternalsJobFactory::IsSupportedURL(request->url())) | 283 if (IsViewAppCacheInternalsURL(request->url())) |
| 278 return ViewAppCacheInternalsJobFactory::CreateJobForRequest( | 284 return new appcache::ViewAppCacheInternalsJob( |
| 279 request, chrome_request_context->appcache_service()); | 285 request, chrome_request_context->appcache_service()); |
| 280 | 286 |
| 281 // Next check for chrome://blob-internals/, which uses its own job type. | 287 // Next check for chrome://blob-internals/, which uses its own job type. |
| 282 if (ViewBlobInternalsJobFactory::IsSupportedURL(request->url())) | 288 if (ViewBlobInternalsJobFactory::IsSupportedURL(request->url())) |
| 283 return ViewBlobInternalsJobFactory::CreateJobForRequest(request); | 289 return ViewBlobInternalsJobFactory::CreateJobForRequest(request); |
| 284 | 290 |
| 285 // Fall back to using a custom handler | 291 // Fall back to using a custom handler |
| 286 return new URLRequestChromeJob(request); | 292 return new URLRequestChromeJob(request); |
| 287 } | 293 } |
| 288 | 294 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 return false; | 449 return false; |
| 444 | 450 |
| 445 *path = inspector_dir.AppendASCII(relative_path); | 451 *path = inspector_dir.AppendASCII(relative_path); |
| 446 return true; | 452 return true; |
| 447 } | 453 } |
| 448 | 454 |
| 449 net::URLRequestJob* DevToolsJobFactory::CreateJobForRequest( | 455 net::URLRequestJob* DevToolsJobFactory::CreateJobForRequest( |
| 450 net::URLRequest* request, const FilePath& path) { | 456 net::URLRequest* request, const FilePath& path) { |
| 451 return new URLRequestChromeFileJob(request, path); | 457 return new URLRequestChromeFileJob(request, path); |
| 452 } | 458 } |
| OLD | NEW |