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

Side by Side Diff: url/gurl.cc

Issue 1049533002: Add IsOriginSecure and GURL::SchemeUsesTLS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Be even more precise in comments. Created 5 years, 8 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
OLDNEW
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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 if (!is_valid_ || spec_.empty()) 451 if (!is_valid_ || spec_.empty())
452 return false; 452 return false;
453 453
454 url::RawCanonOutputT<char, 128> ignored_output; 454 url::RawCanonOutputT<char, 128> ignored_output;
455 url::CanonHostInfo host_info; 455 url::CanonHostInfo host_info;
456 url::CanonicalizeIPAddress(spec_.c_str(), parsed_.host, &ignored_output, 456 url::CanonicalizeIPAddress(spec_.c_str(), parsed_.host, &ignored_output,
457 &host_info); 457 &host_info);
458 return host_info.IsIPAddress(); 458 return host_info.IsIPAddress();
459 } 459 }
460 460
461 bool GURL::HostIsLocal() const {
462 if (!is_valid_ || spec_.empty())
463 return false;
464
465 if (HostNoBrackets() == "localhost")
466 return true;
467
468 url::RawCanonOutputT<char, 128> ignored;
469 url::CanonHostInfo host_info;
470 url::CanonicalizeIPAddress(spec_.c_str(), parsed_.host, &ignored, &host_info);
471
472 static const unsigned char v4_localhost = 0x7F;
473 if (host_info.family == url::CanonHostInfo::IPV4)
474 return host_info.address[0] == v4_localhost;
475
476 static const unsigned char v6_localhost[] =
477 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
478 if (host_info.family == url::CanonHostInfo::IPV6)
479 return memcmp(host_info.address, v6_localhost, sizeof(v6_localhost)) == 0;
480
481 return false;
482 }
483
461 #ifdef WIN32 484 #ifdef WIN32
462 485
463 const GURL& GURL::EmptyGURL() { 486 const GURL& GURL::EmptyGURL() {
464 // Avoid static object construction/destruction on startup/shutdown. 487 // Avoid static object construction/destruction on startup/shutdown.
465 if (!empty_gurl) { 488 if (!empty_gurl) {
466 // Create the string. Be careful that we don't break in the case that this 489 // Create the string. Be careful that we don't break in the case that this
467 // is being called from multiple threads. 490 // is being called from multiple threads.
468 GURL* new_empty_gurl = new GURL; 491 GURL* new_empty_gurl = new GURL;
469 if (InterlockedCompareExchangePointer( 492 if (InterlockedCompareExchangePointer(
470 reinterpret_cast<PVOID*>(&empty_gurl), new_empty_gurl, NULL)) { 493 reinterpret_cast<PVOID*>(&empty_gurl), new_empty_gurl, NULL)) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 void GURL::Swap(GURL* other) { 563 void GURL::Swap(GURL* other) {
541 spec_.swap(other->spec_); 564 spec_.swap(other->spec_);
542 std::swap(is_valid_, other->is_valid_); 565 std::swap(is_valid_, other->is_valid_);
543 std::swap(parsed_, other->parsed_); 566 std::swap(parsed_, other->parsed_);
544 inner_url_.swap(other->inner_url_); 567 inner_url_.swap(other->inner_url_);
545 } 568 }
546 569
547 std::ostream& operator<<(std::ostream& out, const GURL& url) { 570 std::ostream& operator<<(std::ostream& out, const GURL& url) {
548 return out << url.possibly_invalid_spec(); 571 return out << url.possibly_invalid_spec();
549 } 572 }
OLDNEW
« url/gurl.h ('K') | « url/gurl.h ('k') | url/gurl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698