OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/thread.h" | 11 #include "base/thread.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
14 #include "chrome/common/ref_counted_util.h" | 14 #include "chrome/common/ref_counted_util.h" |
| 15 #include "chrome/common/url_constants.h" |
15 #include "googleurl/src/url_util.h" | 16 #include "googleurl/src/url_util.h" |
16 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
17 #include "net/url_request/url_request_file_job.h" | 18 #include "net/url_request/url_request_file_job.h" |
18 #include "net/url_request/url_request_job.h" | 19 #include "net/url_request/url_request_job.h" |
19 #ifdef CHROME_PERSONALIZATION | 20 #ifdef CHROME_PERSONALIZATION |
20 // TODO(timsteele): Remove all CHROME_PERSONALIZATION code in this file. | 21 // TODO(timsteele): Remove all CHROME_PERSONALIZATION code in this file. |
21 // It is only temporarily needed to configure some personalization data sources | 22 // It is only temporarily needed to configure some personalization data sources |
22 // that will go away soon. | 23 // that will go away soon. |
23 #include "chrome/personalization/personalization.h" | 24 #include "chrome/personalization/personalization.h" |
24 #endif | 25 #endif |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 void RegisterURLRequestChromeJob() { | 91 void RegisterURLRequestChromeJob() { |
91 // Being a standard scheme allows us to resolve relative paths. This method | 92 // Being a standard scheme allows us to resolve relative paths. This method |
92 // is invoked multiple times during testing, so only add the scheme once. | 93 // is invoked multiple times during testing, so only add the scheme once. |
93 url_parse::Component url_scheme_component(0, arraysize(kChromeURLScheme) - 1); | 94 url_parse::Component url_scheme_component(0, arraysize(kChromeURLScheme) - 1); |
94 if (!url_util::IsStandard(kChromeURLScheme, arraysize(kChromeURLScheme) - 1, | 95 if (!url_util::IsStandard(kChromeURLScheme, arraysize(kChromeURLScheme) - 1, |
95 url_scheme_component)) { | 96 url_scheme_component)) { |
96 url_util::AddStandardScheme(kChromeURLScheme); | 97 url_util::AddStandardScheme(kChromeURLScheme); |
97 } | 98 } |
98 | 99 |
99 std::wstring inspector_dir; | 100 std::wstring inspector_dir; |
100 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) | 101 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) { |
| 102 // TODO(yurys): remove "inspector" source when new developer tools support |
| 103 // all features of in-process Web Inspector and Console Debugger. For the |
| 104 // time being we need to serve the same content from chrome-ui://inspector |
| 105 // for the Console Debugger and in-process Web Inspector. |
101 chrome_url_data_manager.AddFileSource("inspector", inspector_dir); | 106 chrome_url_data_manager.AddFileSource("inspector", inspector_dir); |
| 107 chrome_url_data_manager.AddFileSource(chrome::kDevToolsHost, inspector_dir); |
| 108 } |
102 | 109 |
103 URLRequest::RegisterProtocolFactory(kChromeURLScheme, | 110 URLRequest::RegisterProtocolFactory(kChromeURLScheme, |
104 &ChromeURLDataManager::Factory); | 111 &ChromeURLDataManager::Factory); |
105 #ifdef CHROME_PERSONALIZATION | 112 #ifdef CHROME_PERSONALIZATION |
106 url_util::AddStandardScheme(kPersonalizationScheme); | 113 url_util::AddStandardScheme(kPersonalizationScheme); |
107 URLRequest::RegisterProtocolFactory(kPersonalizationScheme, | 114 URLRequest::RegisterProtocolFactory(kPersonalizationScheme, |
108 &ChromeURLDataManager::Factory); | 115 &ChromeURLDataManager::Factory); |
109 #endif | 116 #endif |
110 } | 117 } |
111 | 118 |
112 void UnregisterURLRequestChromeJob() { | 119 void UnregisterURLRequestChromeJob() { |
113 std::wstring inspector_dir; | 120 std::wstring inspector_dir; |
114 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) | 121 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) { |
115 chrome_url_data_manager.RemoveFileSource("inspector"); | 122 chrome_url_data_manager.RemoveFileSource("inspector"); |
| 123 chrome_url_data_manager.RemoveFileSource(chrome::kDevToolsHost); |
| 124 } |
116 } | 125 } |
117 | 126 |
118 // static | 127 // static |
119 void ChromeURLDataManager::URLToRequest(const GURL& url, | 128 void ChromeURLDataManager::URLToRequest(const GURL& url, |
120 std::string* source_name, | 129 std::string* source_name, |
121 std::string* path) { | 130 std::string* path) { |
122 #ifdef CHROME_PERSONALIZATION | 131 #ifdef CHROME_PERSONALIZATION |
123 DCHECK(url.SchemeIs(kChromeURLScheme) || | 132 DCHECK(url.SchemeIs(kChromeURLScheme) || |
124 url.SchemeIs(kPersonalizationScheme)); | 133 url.SchemeIs(kPersonalizationScheme)); |
125 #else | 134 #else |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 } | 350 } |
342 } | 351 } |
343 | 352 |
344 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request, | 353 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request, |
345 const FilePath& path) | 354 const FilePath& path) |
346 : URLRequestFileJob(request, path) { | 355 : URLRequestFileJob(request, path) { |
347 } | 356 } |
348 | 357 |
349 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } | 358 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } |
350 | 359 |
OLD | NEW |