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

Side by Side Diff: content/common/origin_util.cc

Issue 2716583003: Rename Origin.unique() to opaque().
Patch Set: Mac fixes Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/public/common/origin_util.h" 5 #include "content/public/common/origin_util.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "content/common/url_schemes.h" 10 #include "content/common/url_schemes.h"
11 #include "net/base/url_util.h" 11 #include "net/base/url_util.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 #include "url/url_util.h" 13 #include "url/url_util.h"
14 14
15 namespace { 15 namespace {
16 16
17 // This function partially reflects the result from SecurityOrigin::isUnique, 17 // This function partially reflects the result from SecurityOrigin::isOpaque,
18 // not its actual implementation. It takes into account how 18 // not its actual implementation. It takes into account how
19 // SecurityOrigin::create might return unique origins for URLs whose schemes are 19 // SecurityOrigin::create might return opaque origins for URLs whose schemes are
20 // included in SchemeRegistry::shouldTreatURLSchemeAsNoAccess. 20 // included in SchemeRegistry::shouldTreatURLSchemeAsNoAccess.
21 bool IsOriginUnique(const url::Origin& origin) { 21 bool IsOriginOpaque(const url::Origin& origin) {
22 return origin.unique() || 22 return origin.opaque() ||
23 base::ContainsValue(url::GetNoAccessSchemes(), origin.scheme()); 23 base::ContainsValue(url::GetNoAccessSchemes(), origin.scheme());
24 } 24 }
25 25
26 } // namespace 26 } // namespace
27 27
28 namespace content { 28 namespace content {
29 29
30 bool IsOriginSecure(const GURL& url) { 30 bool IsOriginSecure(const GURL& url) {
31 if (url.SchemeIsCryptographic() || url.SchemeIsFile()) 31 if (url.SchemeIsCryptographic() || url.SchemeIsFile())
32 return true; 32 return true;
(...skipping 21 matching lines...) Expand all
54 return true; 54 return true;
55 55
56 if (base::ContainsValue(GetServiceWorkerSchemes(), url.scheme())) { 56 if (base::ContainsValue(GetServiceWorkerSchemes(), url.scheme())) {
57 return true; 57 return true;
58 } 58 }
59 59
60 return false; 60 return false;
61 } 61 }
62 62
63 bool IsOriginWhiteListedTrustworthy(const url::Origin& origin) { 63 bool IsOriginWhiteListedTrustworthy(const url::Origin& origin) {
64 if (IsOriginUnique(origin)) 64 if (IsOriginOpaque(origin))
65 return false; 65 return false;
66 66
67 return base::ContainsValue(GetSecureOrigins(), 67 return base::ContainsValue(GetSecureOrigins(),
68 origin.GetURL().HostNoBrackets()); 68 origin.GetURL().HostNoBrackets());
69 } 69 }
70 70
71 bool IsPotentiallyTrustworthyOrigin(const url::Origin& origin) { 71 bool IsPotentiallyTrustworthyOrigin(const url::Origin& origin) {
72 // Note: Considering this mirrors SecurityOrigin::isPotentiallyTrustworthy, it 72 // Note: Considering this mirrors SecurityOrigin::isPotentiallyTrustworthy, it
73 // assumes m_isUniqueOriginPotentiallyTrustworthy is set to false. This 73 // assumes m_isUniqueOriginPotentiallyTrustworthy is set to false. This
74 // implementation follows Blink's default behavior but in the renderer it can 74 // implementation follows Blink's default behavior but in the renderer it can
75 // be changed per instance by calls to 75 // be changed per instance by calls to
76 // SecurityOrigin::setUniqueOriginIsPotentiallyTrustworthy. 76 // SecurityOrigin::setUniqueOriginIsPotentiallyTrustworthy.
77 if (IsOriginUnique(origin)) 77 if (IsOriginOpaque(origin))
78 return false; 78 return false;
79 79
80 if (base::ContainsValue(url::GetSecureSchemes(), origin.scheme()) || 80 if (base::ContainsValue(url::GetSecureSchemes(), origin.scheme()) ||
81 base::ContainsValue(url::GetLocalSchemes(), origin.scheme()) || 81 base::ContainsValue(url::GetLocalSchemes(), origin.scheme()) ||
82 net::IsLocalhost(origin.GetURL().HostNoBrackets())) { 82 net::IsLocalhost(origin.GetURL().HostNoBrackets())) {
83 return true; 83 return true;
84 } 84 }
85 85
86 if (IsOriginWhiteListedTrustworthy(origin)) 86 if (IsOriginWhiteListedTrustworthy(origin))
87 return true; 87 return true;
88 88
89 return false; 89 return false;
90 } 90 }
91 91
92 } // namespace content 92 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698