OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifdef WIN32 | 5 #ifdef WIN32 |
6 #include <windows.h> | 6 #include <windows.h> |
7 #else | 7 #else |
8 #include <pthread.h> | 8 #include <pthread.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 url_canon::Replacements<char> replacements; | 313 url_canon::Replacements<char> replacements; |
314 replacements.ClearUsername(); | 314 replacements.ClearUsername(); |
315 replacements.ClearPassword(); | 315 replacements.ClearPassword(); |
316 replacements.ClearPath(); | 316 replacements.ClearPath(); |
317 replacements.ClearQuery(); | 317 replacements.ClearQuery(); |
318 replacements.ClearRef(); | 318 replacements.ClearRef(); |
319 | 319 |
320 return ReplaceComponents(replacements); | 320 return ReplaceComponents(replacements); |
321 } | 321 } |
322 | 322 |
| 323 GURL GURL::GetAsReferrer() const { |
| 324 if (!is_valid_ || |
| 325 (!has_ref() && !has_username() && !has_password())) |
| 326 return GURL(*this); |
| 327 |
| 328 url_canon::Replacements<char> replacements; |
| 329 replacements.ClearRef(); |
| 330 replacements.ClearUsername(); |
| 331 replacements.ClearPassword(); |
| 332 return ReplaceComponents(replacements); |
| 333 } |
| 334 |
323 GURL GURL::GetWithEmptyPath() const { | 335 GURL GURL::GetWithEmptyPath() const { |
324 // This doesn't make sense for invalid or nonstandard URLs, so return | 336 // This doesn't make sense for invalid or nonstandard URLs, so return |
325 // the empty URL. | 337 // the empty URL. |
326 if (!is_valid_ || !IsStandard()) | 338 if (!is_valid_ || !IsStandard()) |
327 return GURL(); | 339 return GURL(); |
328 | 340 |
329 // We could optimize this since we know that the URL is canonical, and we are | 341 // We could optimize this since we know that the URL is canonical, and we are |
330 // appending a canonical path, so avoiding re-parsing. | 342 // appending a canonical path, so avoiding re-parsing. |
331 GURL other(*this); | 343 GURL other(*this); |
332 if (parsed_.path.len == 0) | 344 if (parsed_.path.len == 0) |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 void GURL::Swap(GURL* other) { | 521 void GURL::Swap(GURL* other) { |
510 spec_.swap(other->spec_); | 522 spec_.swap(other->spec_); |
511 std::swap(is_valid_, other->is_valid_); | 523 std::swap(is_valid_, other->is_valid_); |
512 std::swap(parsed_, other->parsed_); | 524 std::swap(parsed_, other->parsed_); |
513 inner_url_.swap(other->inner_url_); | 525 inner_url_.swap(other->inner_url_); |
514 } | 526 } |
515 | 527 |
516 std::ostream& operator<<(std::ostream& out, const GURL& url) { | 528 std::ostream& operator<<(std::ostream& out, const GURL& url) { |
517 return out << url.possibly_invalid_spec(); | 529 return out << url.possibly_invalid_spec(); |
518 } | 530 } |
OLD | NEW |