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

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

Issue 2716583003: Rename Origin.unique() to opaque().
Patch Set: Mac fixes Created 3 years, 9 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) : m_private(0) { 131 WebSecurityOrigin(const url::Origin& origin) : m_private(0) {
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 void assign(WebSecurityOriginPrivate*); 154 void assign(WebSecurityOriginPrivate*);
154 WebSecurityOriginPrivate* m_private; 155 WebSecurityOriginPrivate* m_private;
155 }; 156 };
156 157
157 } // namespace blink 158 } // namespace blink
158 159
159 #endif 160 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698