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

Side by Side Diff: third_party/WebKit/Source/platform/weborigin/SecurityOrigin.cpp

Issue 2846303002: Replace ASSERT with DCHECK in platform/ (Closed)
Patch Set: rebase Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 186 }
187 187
188 if (ShouldUseInnerURL(url)) 188 if (ShouldUseInnerURL(url))
189 return AdoptRef(new SecurityOrigin(ExtractInnerURL(url))); 189 return AdoptRef(new SecurityOrigin(ExtractInnerURL(url)));
190 190
191 return AdoptRef(new SecurityOrigin(url)); 191 return AdoptRef(new SecurityOrigin(url));
192 } 192 }
193 193
194 PassRefPtr<SecurityOrigin> SecurityOrigin::CreateUnique() { 194 PassRefPtr<SecurityOrigin> SecurityOrigin::CreateUnique() {
195 RefPtr<SecurityOrigin> origin = AdoptRef(new SecurityOrigin()); 195 RefPtr<SecurityOrigin> origin = AdoptRef(new SecurityOrigin());
196 ASSERT(origin->IsUnique()); 196 DCHECK(origin->IsUnique());
197 return origin.Release(); 197 return origin.Release();
198 } 198 }
199 199
200 PassRefPtr<SecurityOrigin> SecurityOrigin::IsolatedCopy() const { 200 PassRefPtr<SecurityOrigin> SecurityOrigin::IsolatedCopy() const {
201 return AdoptRef(new SecurityOrigin(this)); 201 return AdoptRef(new SecurityOrigin(this));
202 } 202 }
203 203
204 void SecurityOrigin::SetDomainFromDOM(const String& new_domain) { 204 void SecurityOrigin::SetDomainFromDOM(const String& new_domain) {
205 domain_was_set_in_dom_ = true; 205 domain_was_set_in_dom_ = true;
206 domain_ = new_domain; 206 domain_ = new_domain;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // obtain the privilege by injecting script into the documents that have 362 // obtain the privilege by injecting script into the documents that have
363 // been granted the privilege. 363 // been granted the privilege.
364 can_load_local_resources_ = true; 364 can_load_local_resources_ = true;
365 } 365 }
366 366
367 void SecurityOrigin::GrantUniversalAccess() { 367 void SecurityOrigin::GrantUniversalAccess() {
368 universal_access_ = true; 368 universal_access_ = true;
369 } 369 }
370 370
371 void SecurityOrigin::AddSuborigin(const Suborigin& suborigin) { 371 void SecurityOrigin::AddSuborigin(const Suborigin& suborigin) {
372 ASSERT(RuntimeEnabledFeatures::suboriginsEnabled()); 372 DCHECK(RuntimeEnabledFeatures::suboriginsEnabled());
373 // Changing suborigins midstream is bad. Very bad. It should not happen. 373 // Changing suborigins midstream is bad. Very bad. It should not happen.
374 // This is, in fact, one of the very basic invariants that makes 374 // This is, in fact, one of the very basic invariants that makes
375 // suborigins an effective security tool. 375 // suborigins an effective security tool.
376 RELEASE_ASSERT(suborigin_.GetName().IsNull() || 376 RELEASE_ASSERT(suborigin_.GetName().IsNull() ||
377 (suborigin_.GetName() == suborigin.GetName())); 377 (suborigin_.GetName() == suborigin.GetName()));
378 suborigin_.SetTo(suborigin); 378 suborigin_.SetTo(suborigin);
379 } 379 }
380 380
381 void SecurityOrigin::BlockLocalAccessFromLocalOrigin() { 381 void SecurityOrigin::BlockLocalAccessFromLocalOrigin() {
382 ASSERT(IsLocal()); 382 DCHECK(IsLocal());
383 block_local_access_from_local_origin_ = true; 383 block_local_access_from_local_origin_ = true;
384 } 384 }
385 385
386 bool SecurityOrigin::IsLocal() const { 386 bool SecurityOrigin::IsLocal() const {
387 return SchemeRegistry::ShouldTreatURLSchemeAsLocal(protocol_); 387 return SchemeRegistry::ShouldTreatURLSchemeAsLocal(protocol_);
388 } 388 }
389 389
390 bool SecurityOrigin::IsLocalhost() const { 390 bool SecurityOrigin::IsLocalhost() const {
391 // Note: net::isLocalhost has looser checks which allow uppercase hosts, as 391 // Note: net::isLocalhost has looser checks which allow uppercase hosts, as
392 // well as hosts like "a.localhost". The net code is also less optimized and 392 // well as hosts like "a.localhost". The net code is also less optimized and
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 return IsSameSchemeHostPort(other) && same_suborigins; 568 return IsSameSchemeHostPort(other) && same_suborigins;
569 } 569 }
570 570
571 bool SecurityOrigin::AreSameSchemeHostPort(const KURL& a, const KURL& b) { 571 bool SecurityOrigin::AreSameSchemeHostPort(const KURL& a, const KURL& b) {
572 RefPtr<SecurityOrigin> origin_a = SecurityOrigin::Create(a); 572 RefPtr<SecurityOrigin> origin_a = SecurityOrigin::Create(a);
573 RefPtr<SecurityOrigin> origin_b = SecurityOrigin::Create(b); 573 RefPtr<SecurityOrigin> origin_b = SecurityOrigin::Create(b);
574 return origin_b->IsSameSchemeHostPort(origin_a.Get()); 574 return origin_b->IsSameSchemeHostPort(origin_a.Get());
575 } 575 }
576 576
577 const KURL& SecurityOrigin::UrlWithUniqueSecurityOrigin() { 577 const KURL& SecurityOrigin::UrlWithUniqueSecurityOrigin() {
578 ASSERT(IsMainThread()); 578 DCHECK(IsMainThread());
579 DEFINE_STATIC_LOCAL(const KURL, unique_security_origin_url, 579 DEFINE_STATIC_LOCAL(const KURL, unique_security_origin_url,
580 (kParsedURLString, "data:,")); 580 (kParsedURLString, "data:,"));
581 return unique_security_origin_url; 581 return unique_security_origin_url;
582 } 582 }
583 583
584 std::unique_ptr<SecurityOrigin::PrivilegeData> 584 std::unique_ptr<SecurityOrigin::PrivilegeData>
585 SecurityOrigin::CreatePrivilegeData() const { 585 SecurityOrigin::CreatePrivilegeData() const {
586 std::unique_ptr<PrivilegeData> privilege_data = 586 std::unique_ptr<PrivilegeData> privilege_data =
587 WTF::WrapUnique(new PrivilegeData); 587 WTF::WrapUnique(new PrivilegeData);
588 privilege_data->universal_access_ = universal_access_; 588 privilege_data->universal_access_ = universal_access_;
(...skipping 28 matching lines...) Expand all
617 &canon_output, &out_host); 617 &canon_output, &out_host);
618 } else { 618 } else {
619 *success = url::CanonicalizeHost(host.Characters16(), 619 *success = url::CanonicalizeHost(host.Characters16(),
620 url::Component(0, host.length()), 620 url::Component(0, host.length()),
621 &canon_output, &out_host); 621 &canon_output, &out_host);
622 } 622 }
623 return String::FromUTF8(canon_output.data(), canon_output.length()); 623 return String::FromUTF8(canon_output.data(), canon_output.length());
624 } 624 }
625 625
626 } // namespace blink 626 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698