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

Side by Side Diff: third_party/WebKit/public/platform/WebSecurityOrigin.h

Issue 2716583003: Rename Origin.unique() to opaque().
Patch Set: Update new uses post-rebase Created 3 years, 4 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 BLINK_PLATFORM_EXPORT WebString Host() const; 71 BLINK_PLATFORM_EXPORT WebString Host() const;
72 BLINK_PLATFORM_EXPORT unsigned short Port() const; 72 BLINK_PLATFORM_EXPORT unsigned short Port() const;
73 73
74 // |Port()| will return 0 if the port is the default for an origin. This 74 // |Port()| will return 0 if the port is the default for an origin. This
75 // method instead returns the effective port, even if it is the default port 75 // method instead returns the effective port, even if it is the default port
76 // (e.g. "http" => 80). 76 // (e.g. "http" => 80).
77 BLINK_PLATFORM_EXPORT unsigned short EffectivePort() const; 77 BLINK_PLATFORM_EXPORT unsigned short EffectivePort() const;
78 78
79 BLINK_PLATFORM_EXPORT WebString Suborigin() const; 79 BLINK_PLATFORM_EXPORT WebString Suborigin() const;
80 80
81 // A unique WebSecurityOrigin is the least privileged WebSecurityOrigin. 81 // An opaque WebSecurityOrigin is the least privileged WebSecurityOrigin.
82 // TODO: Rename to IsOpaque
82 BLINK_PLATFORM_EXPORT bool IsUnique() const; 83 BLINK_PLATFORM_EXPORT bool IsUnique() const;
83 84
84 // Returns true if this WebSecurityOrigin can script objects in the given 85 // Returns true if this WebSecurityOrigin can script objects in the given
85 // SecurityOrigin. For example, call this function before allowing 86 // SecurityOrigin. For example, call this function before allowing
86 // script from one security origin to read or write objects from 87 // script from one security origin to read or write objects from
87 // another SecurityOrigin. 88 // another SecurityOrigin.
88 BLINK_PLATFORM_EXPORT bool CanAccess(const WebSecurityOrigin&) const; 89 BLINK_PLATFORM_EXPORT bool CanAccess(const WebSecurityOrigin&) const;
89 90
90 // Returns true if this WebSecurityOrigin can read content retrieved from 91 // Returns true if this WebSecurityOrigin can read content retrieved from
91 // the given URL. For example, call this function before allowing script 92 // the given URL. For example, call this function before allowing script
(...skipping 29 matching lines...) Expand all
121 // ('document.domain', for instance). We'll need to fix that for OOPI-enabled 122 // ('document.domain', for instance). We'll need to fix that for OOPI-enabled
122 // embedders, https://crbug.com/490074. 123 // embedders, https://crbug.com/490074.
123 operator url::Origin() const { 124 operator url::Origin() const {
124 return IsUnique() ? url::Origin() 125 return IsUnique() ? url::Origin()
125 : url::Origin::CreateFromNormalizedTupleWithSuborigin( 126 : url::Origin::CreateFromNormalizedTupleWithSuborigin(
126 Protocol().Ascii(), Host().Ascii(), EffectivePort(), 127 Protocol().Ascii(), Host().Ascii(), EffectivePort(),
127 Suborigin().Ascii()); 128 Suborigin().Ascii());
128 } 129 }
129 130
130 WebSecurityOrigin(const url::Origin& origin) { 131 WebSecurityOrigin(const url::Origin& origin) {
131 if (origin.unique()) { 132 if (origin.opaque()) {
132 Assign(WebSecurityOrigin::CreateUnique()); 133 Assign(WebSecurityOrigin::CreateUnique());
133 return; 134 return;
134 } 135 }
135 136
136 // TODO(mkwst): This might open up issues by double-canonicalizing the host. 137 // TODO(mkwst): This might open up issues by double-canonicalizing the host.
137 Assign(WebSecurityOrigin::CreateFromTupleWithSuborigin( 138 Assign(WebSecurityOrigin::CreateFromTupleWithSuborigin(
138 WebString::FromUTF8(origin.scheme()), 139 WebString::FromUTF8(origin.scheme()),
139 WebString::FromUTF8(origin.host()), origin.port(), 140 WebString::FromUTF8(origin.host()), origin.port(),
140 WebString::FromUTF8(origin.suborigin()))); 141 WebString::FromUTF8(origin.suborigin())));
141 } 142 }
142 #endif 143 #endif
143 144
144 private: 145 private:
145 // Present only to facilitate conversion from 'url::Origin'; this constructor 146 // Present only to facilitate conversion from 'url::Origin'; this constructor
146 // shouldn't be used anywhere else. 147 // shouldn't be used anywhere else.
147 BLINK_PLATFORM_EXPORT static WebSecurityOrigin CreateFromTupleWithSuborigin( 148 BLINK_PLATFORM_EXPORT static WebSecurityOrigin CreateFromTupleWithSuborigin(
148 const WebString& protocol, 149 const WebString& protocol,
149 const WebString& host, 150 const WebString& host,
150 int port, 151 int port,
151 const WebString& suborigin); 152 const WebString& suborigin);
152 153
153 WebPrivatePtr<SecurityOrigin> private_; 154 WebPrivatePtr<SecurityOrigin> private_;
154 }; 155 };
155 156
156 } // namespace blink 157 } // namespace blink
157 158
158 #endif 159 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/mojo/SecurityOriginStructTraits.h ('k') | url/mojo/origin.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698