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

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

Issue 155067: Hookup Print HTML page to the DOM UI for Print Preview and Settings... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months 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 | Annotate | Revision Log
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 "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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // all features of in-process Web Inspector and Console Debugger. For the 109 // all features of in-process Web Inspector and Console Debugger. For the
110 // time being we need to serve the same content from chrome://inspector 110 // time being we need to serve the same content from chrome://inspector
111 // for the Console Debugger and in-process Web Inspector. 111 // for the Console Debugger and in-process Web Inspector.
112 chrome_url_data_manager.AddFileSource("inspector", inspector_dir); 112 chrome_url_data_manager.AddFileSource("inspector", inspector_dir);
113 chrome_url_data_manager.AddFileSource(chrome::kChromeUIDevToolsHost, 113 chrome_url_data_manager.AddFileSource(chrome::kChromeUIDevToolsHost,
114 inspector_dir); 114 inspector_dir);
115 } 115 }
116 116
117 URLRequest::RegisterProtocolFactory(kChromeURLScheme, 117 URLRequest::RegisterProtocolFactory(kChromeURLScheme,
118 &ChromeURLDataManager::Factory); 118 &ChromeURLDataManager::Factory);
119 URLRequest::RegisterProtocolFactory(chrome::kPrintScheme,
120 &ChromeURLDataManager::Factory);
119 #ifdef CHROME_PERSONALIZATION 121 #ifdef CHROME_PERSONALIZATION
120 url_util::AddStandardScheme(kPersonalizationScheme); 122 url_util::AddStandardScheme(kPersonalizationScheme);
121 URLRequest::RegisterProtocolFactory(kPersonalizationScheme, 123 URLRequest::RegisterProtocolFactory(kPersonalizationScheme,
122 &ChromeURLDataManager::Factory); 124 &ChromeURLDataManager::Factory);
123 #endif 125 #endif
124 } 126 }
125 127
126 void UnregisterURLRequestChromeJob() { 128 void UnregisterURLRequestChromeJob() {
127 std::wstring inspector_dir; 129 std::wstring inspector_dir;
128 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) { 130 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) {
129 chrome_url_data_manager.RemoveFileSource("inspector"); 131 chrome_url_data_manager.RemoveFileSource("inspector");
130 chrome_url_data_manager.RemoveFileSource(chrome::kChromeUIDevToolsHost); 132 chrome_url_data_manager.RemoveFileSource(chrome::kChromeUIDevToolsHost);
131 } 133 }
132 } 134 }
133 135
134 // static 136 // static
135 void ChromeURLDataManager::URLToRequest(const GURL& url, 137 void ChromeURLDataManager::URLToRequest(const GURL& url,
136 std::string* source_name, 138 std::string* source_name,
137 std::string* path) { 139 std::string* path) {
138 #ifdef CHROME_PERSONALIZATION 140 #ifdef CHROME_PERSONALIZATION
139 DCHECK(url.SchemeIs(kChromeURLScheme) || 141 DCHECK(url.SchemeIs(kChromeURLScheme) ||
140 url.SchemeIs(kPersonalizationScheme)); 142 url.SchemeIs(kPersonalizationScheme) ||
143 url.SchemeIs(chrome::kPrintScheme));
141 #else 144 #else
142 DCHECK(url.SchemeIs(kChromeURLScheme)); 145 DCHECK(url.SchemeIs(kChromeURLScheme) || url.SchemeIs(chrome::kPrintScheme));
143 #endif 146 #endif
144 147
145 if (!url.is_valid()) { 148 if (!url.is_valid()) {
146 NOTREACHED(); 149 NOTREACHED();
147 return; 150 return;
148 } 151 }
149 152
150 // Our input looks like: chrome://source_name/extra_bits?foo . 153 // Our input looks like: chrome://source_name/extra_bits?foo .
151 // So the url's "host" is our source, and everything after the host is 154 // So the url's "host" is our source, and everything after the host is
152 // the path. 155 // the path. For print:url schemes, we assume its always print.
153 source_name->assign(url.host()); 156 if (url.SchemeIs(chrome::kPrintScheme))
157 source_name->assign(chrome::kPrintScheme);
158 else
159 source_name->assign(url.host());
154 160
155 const std::string& spec = url.possibly_invalid_spec(); 161 const std::string& spec = url.possibly_invalid_spec();
156 const url_parse::Parsed& parsed = url.parsed_for_possibly_invalid_spec(); 162 const url_parse::Parsed& parsed = url.parsed_for_possibly_invalid_spec();
157 int offset = parsed.CountCharactersBefore(url_parse::Parsed::PATH, false); 163 int offset = parsed.CountCharactersBefore(url_parse::Parsed::PATH, false);
158 ++offset; // Skip the slash at the beginning of the path. 164
165 // We need to skip the slash at the beginning of the path for non print urls.
166 if (!url.SchemeIs(chrome::kPrintScheme))
167 ++offset;
168
159 if (offset < static_cast<int>(spec.size())) 169 if (offset < static_cast<int>(spec.size()))
160 path->assign(spec.substr(offset)); 170 path->assign(spec.substr(offset));
161 } 171 }
162 172
163 // static 173 // static
164 bool ChromeURLDataManager::URLToFilePath(const GURL& url, 174 bool ChromeURLDataManager::URLToFilePath(const GURL& url,
165 std::wstring* file_path) { 175 std::wstring* file_path) {
166 // Parse the URL into a request for a source and path. 176 // Parse the URL into a request for a source and path.
167 std::string source_name; 177 std::string source_name;
168 std::string relative_path; 178 std::string relative_path;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 net::ERR_INVALID_URL)); 391 net::ERR_INVALID_URL));
382 } 392 }
383 } 393 }
384 394
385 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request, 395 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request,
386 const FilePath& path) 396 const FilePath& path)
387 : URLRequestFileJob(request, path) { 397 : URLRequestFileJob(request, path) {
388 } 398 }
389 399
390 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } 400 URLRequestChromeFileJob::~URLRequestChromeFileJob() { }
OLDNEW
« no previous file with comments | « chrome/browser/child_process_security_policy.cc ('k') | chrome/browser/dom_ui/dom_ui_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698