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

Side by Side Diff: chrome/browser/url_fixer_upper.cc

Issue 16511: If the URL text has no scheme, and starts with ftp., then ... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/url_fixer_upper_unittest.cc » ('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 <algorithm> 5 #include <algorithm>
6 #include <windows.h> 6 #include <windows.h>
7 7
8 #include "chrome/browser/url_fixer_upper.h" 8 #include "chrome/browser/url_fixer_upper.h"
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // We need to fix up the segmentation for "www.example.com:/". For this 280 // We need to fix up the segmentation for "www.example.com:/". For this
281 // case, we guess that schemes with a "." are not actually schemes. 281 // case, we guess that schemes with a "." are not actually schemes.
282 (scheme.find(L".") != wstring::npos) || 282 (scheme.find(L".") != wstring::npos) ||
283 // We need to fix up the segmentation for "www:123/". For this case, we 283 // We need to fix up the segmentation for "www:123/". For this case, we
284 // will add an HTTP scheme later and make the URL parser happy. 284 // will add an HTTP scheme later and make the URL parser happy.
285 // TODO(pkasting): Maybe we should try to use GURL's parser for this? 285 // TODO(pkasting): Maybe we should try to use GURL's parser for this?
286 HasPort(text, parts->scheme, scheme))) 286 HasPort(text, parts->scheme, scheme)))
287 parts->scheme.reset(); 287 parts->scheme.reset();
288 } 288 }
289 289
290 // Check to see if we've found a scheme we liked. 290 // When we couldn't find a scheme in the input, we need to pick one. Normally
291 int scheme_end; 291 // we choose http, but if the URL starts with "ftp.", we match other browsers
292 if (parts->scheme.is_valid()) { 292 // and choose ftp.
293 // Remember the end of the scheme. 293 if (!parts->scheme.is_valid())
294 scheme_end = parts->scheme.end(); 294 scheme.assign(StartsWith(text, L"ftp.", false) ? L"ftp" : L"http");
295 } else {
296 // Having been unable to extract a scheme, we default to HTTP.
297 scheme.assign(L"http");
298 scheme_end = 0;
299 }
300 295
301 // Cannonicalize the scheme. 296 // Cannonicalize the scheme.
302 StringToLowerASCII(&scheme); 297 StringToLowerASCII(&scheme);
303 298
304 // Not segmenting file schemes or nonstandard schemes. 299 // Not segmenting file schemes or nonstandard schemes.
305 if ((scheme == L"file") || 300 if ((scheme == L"file") ||
306 !url_util::IsStandard(scheme.c_str(), static_cast<int>(scheme.length()), 301 !url_util::IsStandard(scheme.c_str(), static_cast<int>(scheme.length()),
307 url_parse::Component(0, static_cast<int>(scheme.length())))) 302 url_parse::Component(0, static_cast<int>(scheme.length()))))
308 return scheme; 303 return scheme;
309 304
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 GURL file_url = net::FilePathToFileURL(full_path); 430 GURL file_url = net::FilePathToFileURL(full_path);
436 if (file_url.is_valid()) 431 if (file_url.is_valid())
437 return gfx::ElideUrl(file_url, ChromeFont(), 0, std::wstring()); 432 return gfx::ElideUrl(file_url, ChromeFont(), 0, std::wstring());
438 // Invalid files fall through to regular processing. 433 // Invalid files fall through to regular processing.
439 } 434 }
440 435
441 // Fall back on regular fixup for this input. 436 // Fall back on regular fixup for this input.
442 return FixupURL(text, L""); 437 return FixupURL(text, L"");
443 } 438 }
444 439
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/url_fixer_upper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698