Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: chrome/browser/dom_ui/chrome_url_data_manager.cc

Issue 15010: Implement extension:// protocol. (Closed)
Patch Set: add missing unit test Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/extensions/extension.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 char* pending_buf_; 76 char* pending_buf_;
77 int pending_buf_size_; 77 int pending_buf_size_;
78 std::string mime_type_; 78 std::string mime_type_;
79 79
80 DISALLOW_EVIL_CONSTRUCTORS(URLRequestChromeJob); 80 DISALLOW_EVIL_CONSTRUCTORS(URLRequestChromeJob);
81 }; 81 };
82 82
83 // URLRequestChromeFileJob is a URLRequestJob that acts like a file:// URL 83 // URLRequestChromeFileJob is a URLRequestJob that acts like a file:// URL
84 class URLRequestChromeFileJob : public URLRequestFileJob { 84 class URLRequestChromeFileJob : public URLRequestFileJob {
85 public: 85 public:
86 URLRequestChromeFileJob(URLRequest* request, const std::wstring& path); 86 URLRequestChromeFileJob(URLRequest* request, const FilePath& path);
87 virtual ~URLRequestChromeFileJob(); 87 virtual ~URLRequestChromeFileJob();
88 88
89 private: 89 private:
90 DISALLOW_EVIL_CONSTRUCTORS(URLRequestChromeFileJob); 90 DISALLOW_EVIL_CONSTRUCTORS(URLRequestChromeFileJob);
91 }; 91 };
92 92
93 void RegisterURLRequestChromeJob() { 93 void RegisterURLRequestChromeJob() {
94 // Being a standard scheme allows us to resolve relative paths 94 // Being a standard scheme allows us to resolve relative paths
95 url_util::AddStandardScheme(kChromeURLScheme); 95 url_util::AddStandardScheme(kChromeURLScheme);
96 96
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 &ChromeURLDataManager::DataAvailable, 237 &ChromeURLDataManager::DataAvailable,
238 request_id, scoped_refptr<RefCountedBytes>(bytes))); 238 request_id, scoped_refptr<RefCountedBytes>(bytes)));
239 } 239 }
240 240
241 // static 241 // static
242 URLRequestJob* ChromeURLDataManager::Factory(URLRequest* request, 242 URLRequestJob* ChromeURLDataManager::Factory(URLRequest* request,
243 const std::string& scheme) { 243 const std::string& scheme) {
244 // Try first with a file handler 244 // Try first with a file handler
245 std::wstring path; 245 std::wstring path;
246 if (ChromeURLDataManager::URLToFilePath(request->url(), &path)) 246 if (ChromeURLDataManager::URLToFilePath(request->url(), &path))
247 return new URLRequestChromeFileJob(request, path); 247 return new URLRequestChromeFileJob(request,
248 FilePath::FromWStringHack(path));
248 249
249 // Fall back to using a custom handler 250 // Fall back to using a custom handler
250 return new URLRequestChromeJob(request); 251 return new URLRequestChromeJob(request);
251 } 252 }
252 253
253 URLRequestChromeJob::URLRequestChromeJob(URLRequest* request) 254 URLRequestChromeJob::URLRequestChromeJob(URLRequest* request)
254 : URLRequestJob(request), data_offset_(0), pending_buf_(NULL) {} 255 : URLRequestJob(request), data_offset_(0), pending_buf_(NULL) {}
255 256
256 URLRequestChromeJob::~URLRequestChromeJob() { 257 URLRequestChromeJob::~URLRequestChromeJob() {
257 } 258 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 323
323 if (chrome_url_data_manager.StartRequest(request_->url(), this)) { 324 if (chrome_url_data_manager.StartRequest(request_->url(), this)) {
324 NotifyHeadersComplete(); 325 NotifyHeadersComplete();
325 } else { 326 } else {
326 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, 327 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED,
327 net::ERR_INVALID_URL)); 328 net::ERR_INVALID_URL));
328 } 329 }
329 } 330 }
330 331
331 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request, 332 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request,
332 const std::wstring& path) 333 const FilePath& path)
333 : URLRequestFileJob(request) { 334 : URLRequestFileJob(request, path) {
334 // set URLRequestFileJob::file_path_
335 this->file_path_ = FilePath::FromWStringHack(path);
336 } 335 }
337 336
338 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } 337 URLRequestChromeFileJob::~URLRequestChromeFileJob() { }
339 338
OLDNEW
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698