| 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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 8 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 11 #include "base/ref_counted_memory.h" | 12 #include "base/ref_counted_memory.h" |
| 12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 13 #include "chrome/browser/net/chrome_url_request_context.h" | 14 #include "chrome/browser/net/chrome_url_request_context.h" |
| 14 #include "chrome/browser/net/view_blob_internals_job_factory.h" | 15 #include "chrome/browser/net/view_blob_internals_job_factory.h" |
| 15 #include "chrome/browser/net/view_http_cache_job_factory.h" | 16 #include "chrome/browser/net/view_http_cache_job_factory.h" |
| 16 #include "chrome/browser/ui/webui/shared_resources_data_source.h" | 17 #include "chrome/browser/ui/webui/shared_resources_data_source.h" |
| 17 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 19 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 19 #include "content/browser/appcache/view_appcache_internals_job_factory.h" | 21 #include "content/browser/appcache/view_appcache_internals_job_factory.h" |
| 20 #include "content/browser/browser_thread.h" | 22 #include "content/browser/browser_thread.h" |
| 21 #include "googleurl/src/url_util.h" | 23 #include "googleurl/src/url_util.h" |
| 22 #include "grit/platform_locale_settings.h" | 24 #include "grit/platform_locale_settings.h" |
| 23 #include "net/base/io_buffer.h" | 25 #include "net/base/io_buffer.h" |
| 24 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
| 25 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
| 26 #include "net/url_request/url_request_file_job.h" | 28 #include "net/url_request/url_request_file_job.h" |
| 27 #include "net/url_request/url_request_job.h" | 29 #include "net/url_request/url_request_job.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 scoped_refptr<URLRequestChromeJob> job(i->second); | 248 scoped_refptr<URLRequestChromeJob> job(i->second); |
| 247 pending_requests_.erase(i); | 249 pending_requests_.erase(i); |
| 248 job->DataAvailable(bytes); | 250 job->DataAvailable(bytes); |
| 249 } | 251 } |
| 250 } | 252 } |
| 251 | 253 |
| 252 // static | 254 // static |
| 253 net::URLRequestJob* ChromeURLDataManagerBackend::Factory( | 255 net::URLRequestJob* ChromeURLDataManagerBackend::Factory( |
| 254 net::URLRequest* request, | 256 net::URLRequest* request, |
| 255 const std::string& scheme) { | 257 const std::string& scheme) { |
| 256 // Try first with a file handler | 258 |
| 257 FilePath path; | 259 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugDevTools)) { |
| 258 if (DevToolsJobFactory::IsSupportedURL(request->url(), &path)) | 260 // Try loading chrome-devtools:// files from disk. |
| 259 return DevToolsJobFactory::CreateJobForRequest(request, path); | 261 FilePath path; |
| 262 if (DevToolsJobFactory::IsSupportedURL(request->url(), &path)) |
| 263 return DevToolsJobFactory::CreateJobForRequest(request, path); |
| 264 } |
| 260 | 265 |
| 261 // Next check for chrome://view-http-cache/*, which uses its own job type. | 266 // Next check for chrome://view-http-cache/*, which uses its own job type. |
| 262 if (ViewHttpCacheJobFactory::IsSupportedURL(request->url())) | 267 if (ViewHttpCacheJobFactory::IsSupportedURL(request->url())) |
| 263 return ViewHttpCacheJobFactory::CreateJobForRequest(request); | 268 return ViewHttpCacheJobFactory::CreateJobForRequest(request); |
| 264 | 269 |
| 265 // Next check for chrome://appcache-internals/, which uses its own job type. | 270 // Next check for chrome://appcache-internals/, which uses its own job type. |
| 266 if (ViewAppCacheInternalsJobFactory::IsSupportedURL(request->url())) | 271 if (ViewAppCacheInternalsJobFactory::IsSupportedURL(request->url())) |
| 267 return ViewAppCacheInternalsJobFactory::CreateJobForRequest(request); | 272 return ViewAppCacheInternalsJobFactory::CreateJobForRequest(request); |
| 268 | 273 |
| 269 // Next check for chrome://blob-internals/, which uses its own job type. | 274 // Next check for chrome://blob-internals/, which uses its own job type. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 return false; | 410 return false; |
| 406 | 411 |
| 407 *path = inspector_dir.AppendASCII(relative_path); | 412 *path = inspector_dir.AppendASCII(relative_path); |
| 408 return true; | 413 return true; |
| 409 } | 414 } |
| 410 | 415 |
| 411 net::URLRequestJob* DevToolsJobFactory::CreateJobForRequest( | 416 net::URLRequestJob* DevToolsJobFactory::CreateJobForRequest( |
| 412 net::URLRequest* request, const FilePath& path) { | 417 net::URLRequest* request, const FilePath& path) { |
| 413 return new URLRequestChromeFileJob(request, path); | 418 return new URLRequestChromeFileJob(request, path); |
| 414 } | 419 } |
| OLD | NEW |