| 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 "googleurl/src/url_util.h" | 15 #include "googleurl/src/url_util.h" |
| 16 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
| 17 #include "net/url_request/url_request_file_job.h" | 17 #include "net/url_request/url_request_file_job.h" |
| 18 #include "net/url_request/url_request_job.h" | 18 #include "net/url_request/url_request_job.h" |
| 19 #ifdef CHROME_PERSONALIZATION | 19 #ifdef CHROME_PERSONALIZATION |
| 20 // TODO(timsteele): Remove all CHROME_PERSONALIZATION code in this file. | 20 // TODO(timsteele): Remove all CHROME_PERSONALIZATION code in this file. |
| 21 // It is only temporarily needed to configure some personalization data sources | 21 // It is only temporarily needed to configure some personalization data sources |
| 22 // that will go away soon. | 22 // that will go away soon. |
| 23 #include "chrome/personalization/personalization.h" | 23 #include "chrome/personalization/personalization.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 // The URL scheme used for internal chrome resources. | 26 // The URL scheme used for internal chrome resources. |
| 27 // TODO(glen): Choose a better location for this. | 27 // TODO(glen): Choose a better location for this. |
| 28 static const char kChromeURLScheme[] = "chrome"; | 28 static const char kChromeURLScheme[] = "chrome-ui"; |
| 29 | 29 |
| 30 // The single global instance of ChromeURLDataManager. | 30 // The single global instance of ChromeURLDataManager. |
| 31 ChromeURLDataManager chrome_url_data_manager; | 31 ChromeURLDataManager chrome_url_data_manager; |
| 32 | 32 |
| 33 // URLRequestChromeJob is a URLRequestJob that manages running chrome-internal | 33 // URLRequestChromeJob is a URLRequestJob that manages running chrome-internal |
| 34 // resource requests asynchronously. | 34 // resource requests asynchronously. |
| 35 // It hands off URL requests to ChromeURLDataManager, which asynchronously | 35 // It hands off URL requests to ChromeURLDataManager, which asynchronously |
| 36 // calls back once the data is available. | 36 // calls back once the data is available. |
| 37 class URLRequestChromeJob : public URLRequestJob { | 37 class URLRequestChromeJob : public URLRequestJob { |
| 38 public: | 38 public: |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 url.SchemeIs(kPersonalizationScheme)); | 124 url.SchemeIs(kPersonalizationScheme)); |
| 125 #else | 125 #else |
| 126 DCHECK(url.SchemeIs(kChromeURLScheme)); | 126 DCHECK(url.SchemeIs(kChromeURLScheme)); |
| 127 #endif | 127 #endif |
| 128 | 128 |
| 129 if (!url.is_valid()) { | 129 if (!url.is_valid()) { |
| 130 NOTREACHED(); | 130 NOTREACHED(); |
| 131 return; | 131 return; |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Our input looks like: chrome://source_name/extra_bits?foo . | 134 // Our input looks like: chrome-ui://source_name/extra_bits?foo . |
| 135 // So the url's "host" is our source, and everything after the host is | 135 // So the url's "host" is our source, and everything after the host is |
| 136 // the path. | 136 // the path. |
| 137 source_name->assign(url.host()); | 137 source_name->assign(url.host()); |
| 138 | 138 |
| 139 const std::string& spec = url.possibly_invalid_spec(); | 139 const std::string& spec = url.possibly_invalid_spec(); |
| 140 const url_parse::Parsed& parsed = url.parsed_for_possibly_invalid_spec(); | 140 const url_parse::Parsed& parsed = url.parsed_for_possibly_invalid_spec(); |
| 141 int offset = parsed.CountCharactersBefore(url_parse::Parsed::PATH, false); | 141 int offset = parsed.CountCharactersBefore(url_parse::Parsed::PATH, false); |
| 142 ++offset; // Skip the slash at the beginning of the path. | 142 ++offset; // Skip the slash at the beginning of the path. |
| 143 if (offset < static_cast<int>(spec.size())) | 143 if (offset < static_cast<int>(spec.size())) |
| 144 path->assign(spec.substr(offset)); | 144 path->assign(spec.substr(offset)); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 337 } |
| 338 } | 338 } |
| 339 | 339 |
| 340 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request, | 340 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request, |
| 341 const FilePath& path) | 341 const FilePath& path) |
| 342 : URLRequestFileJob(request, path) { | 342 : URLRequestFileJob(request, path) { |
| 343 } | 343 } |
| 344 | 344 |
| 345 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } | 345 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } |
| 346 | 346 |
| OLD | NEW |