| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/chrome_url_data_manager.h" | 5 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/thread.h" | 14 #include "base/thread.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
| 17 #include "base/win_util.h" | 17 #include "base/win_util.h" |
| 18 #endif | 18 #endif |
| 19 #include "chrome/browser/appcache/view_appcache_internals_job_factory.h" | 19 #include "chrome/browser/appcache/view_appcache_internals_job_factory.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_thread.h" | 21 #include "chrome/browser/chrome_thread.h" |
| 22 #include "chrome/browser/dom_ui/shared_resources_data_source.h" |
| 22 #include "chrome/browser/net/chrome_url_request_context.h" | 23 #include "chrome/browser/net/chrome_url_request_context.h" |
| 23 #include "chrome/browser/net/view_http_cache_job_factory.h" | 24 #include "chrome/browser/net/view_http_cache_job_factory.h" |
| 24 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/ref_counted_util.h" | 26 #include "chrome/common/ref_counted_util.h" |
| 26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 27 #include "googleurl/src/url_util.h" | 28 #include "googleurl/src/url_util.h" |
| 28 #include "grit/platform_locale_settings.h" | 29 #include "grit/platform_locale_settings.h" |
| 29 #include "net/base/io_buffer.h" | 30 #include "net/base/io_buffer.h" |
| 30 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
| 31 #include "net/url_request/url_request.h" | 32 #include "net/url_request/url_request.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 DISALLOW_COPY_AND_ASSIGN(URLRequestChromeFileJob); | 92 DISALLOW_COPY_AND_ASSIGN(URLRequestChromeFileJob); |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 void RegisterURLRequestChromeJob() { | 95 void RegisterURLRequestChromeJob() { |
| 95 FilePath inspector_dir; | 96 FilePath inspector_dir; |
| 96 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) { | 97 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) { |
| 97 Singleton<ChromeURLDataManager>()->AddFileSource( | 98 Singleton<ChromeURLDataManager>()->AddFileSource( |
| 98 chrome::kChromeUIDevToolsHost, inspector_dir); | 99 chrome::kChromeUIDevToolsHost, inspector_dir); |
| 99 } | 100 } |
| 100 | 101 |
| 101 // Set up the chrome://resources/ source. | 102 SharedResourcesDataSource::Register(); |
| 102 FilePath resources_dir; | |
| 103 if (PathService::Get(chrome::DIR_SHARED_RESOURCES, &resources_dir)) { | |
| 104 Singleton<ChromeURLDataManager>()->AddFileSource( | |
| 105 chrome::kChromeUIResourcesHost, resources_dir); | |
| 106 } | |
| 107 | |
| 108 URLRequest::RegisterProtocolFactory(chrome::kChromeUIScheme, | 103 URLRequest::RegisterProtocolFactory(chrome::kChromeUIScheme, |
| 109 &ChromeURLDataManager::Factory); | 104 &ChromeURLDataManager::Factory); |
| 110 } | 105 } |
| 111 | 106 |
| 112 void UnregisterURLRequestChromeJob() { | 107 void UnregisterURLRequestChromeJob() { |
| 113 FilePath inspector_dir; | 108 FilePath inspector_dir; |
| 114 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) { | 109 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) { |
| 115 Singleton<ChromeURLDataManager>()->RemoveFileSource( | 110 Singleton<ChromeURLDataManager>()->RemoveFileSource( |
| 116 chrome::kChromeUIDevToolsHost); | 111 chrome::kChromeUIDevToolsHost); |
| 117 } | 112 } |
| 118 | |
| 119 FilePath resources_dir; | |
| 120 if (PathService::Get(chrome::DIR_SHARED_RESOURCES, &resources_dir)) { | |
| 121 Singleton<ChromeURLDataManager>()->RemoveFileSource( | |
| 122 chrome::kChromeUIResourcesHost); | |
| 123 } | |
| 124 } | 113 } |
| 125 | 114 |
| 126 // static | 115 // static |
| 127 void ChromeURLDataManager::URLToRequest(const GURL& url, | 116 void ChromeURLDataManager::URLToRequest(const GURL& url, |
| 128 std::string* source_name, | 117 std::string* source_name, |
| 129 std::string* path) { | 118 std::string* path) { |
| 130 DCHECK(url.SchemeIs(chrome::kChromeUIScheme)); | 119 DCHECK(url.SchemeIs(chrome::kChromeUIScheme)); |
| 131 | 120 |
| 132 if (!url.is_valid()) { | 121 if (!url.is_valid()) { |
| 133 NOTREACHED(); | 122 NOTREACHED(); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 net::ERR_INVALID_URL)); | 402 net::ERR_INVALID_URL)); |
| 414 } | 403 } |
| 415 } | 404 } |
| 416 | 405 |
| 417 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request, | 406 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request, |
| 418 const FilePath& path) | 407 const FilePath& path) |
| 419 : URLRequestFileJob(request, path) { | 408 : URLRequestFileJob(request, path) { |
| 420 } | 409 } |
| 421 | 410 |
| 422 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } | 411 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } |
| OLD | NEW |