| OLD | NEW |
| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 BLINK_PLATFORM_EXPORT WebString protocol() const; | 70 BLINK_PLATFORM_EXPORT WebString protocol() const; |
| 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; |
| 80 |
| 79 // A unique WebSecurityOrigin is the least privileged WebSecurityOrigin. | 81 // A unique WebSecurityOrigin is the least privileged WebSecurityOrigin. |
| 80 BLINK_PLATFORM_EXPORT bool isUnique() const; | 82 BLINK_PLATFORM_EXPORT bool isUnique() const; |
| 81 | 83 |
| 82 // Returns true if this WebSecurityOrigin can script objects in the given | 84 // Returns true if this WebSecurityOrigin can script objects in the given |
| 83 // SecurityOrigin. For example, call this function before allowing | 85 // SecurityOrigin. For example, call this function before allowing |
| 84 // script from one security origin to read or write objects from | 86 // script from one security origin to read or write objects from |
| 85 // another SecurityOrigin. | 87 // another SecurityOrigin. |
| 86 BLINK_PLATFORM_EXPORT bool canAccess(const WebSecurityOrigin&) const; | 88 BLINK_PLATFORM_EXPORT bool canAccess(const WebSecurityOrigin&) const; |
| 87 | 89 |
| 88 // Returns true if this WebSecurityOrigin can read content retrieved from | 90 // Returns true if this WebSecurityOrigin can read content retrieved from |
| (...skipping 24 matching lines...) Expand all Loading... |
| 113 BLINK_PLATFORM_EXPORT WebSecurityOrigin& operator=( | 115 BLINK_PLATFORM_EXPORT WebSecurityOrigin& operator=( |
| 114 WTF::PassRefPtr<SecurityOrigin>); | 116 WTF::PassRefPtr<SecurityOrigin>); |
| 115 BLINK_PLATFORM_EXPORT operator WTF::PassRefPtr<SecurityOrigin>() const; | 117 BLINK_PLATFORM_EXPORT operator WTF::PassRefPtr<SecurityOrigin>() const; |
| 116 BLINK_PLATFORM_EXPORT SecurityOrigin* get() const; | 118 BLINK_PLATFORM_EXPORT SecurityOrigin* get() const; |
| 117 #else | 119 #else |
| 118 // TODO(mkwst): A number of properties don't survive a round-trip | 120 // TODO(mkwst): A number of properties don't survive a round-trip |
| 119 // ('document.domain', for instance). We'll need to fix that for OOPI-enabled | 121 // ('document.domain', for instance). We'll need to fix that for OOPI-enabled |
| 120 // embedders, https://crbug.com/490074. | 122 // embedders, https://crbug.com/490074. |
| 121 operator url::Origin() const { | 123 operator url::Origin() const { |
| 122 return isUnique() ? url::Origin() | 124 return isUnique() ? url::Origin() |
| 123 : url::Origin::CreateFromNormalizedTuple( | 125 : url::Origin::CreateFromNormalizedTupleWithSuborigin( |
| 124 protocol().utf8(), host().utf8(), effectivePort()); | 126 protocol().utf8(), host().utf8(), effectivePort(), |
| 127 suborigin().utf8()); |
| 125 } | 128 } |
| 126 | 129 |
| 127 WebSecurityOrigin(const url::Origin& origin) : m_private(0) { | 130 WebSecurityOrigin(const url::Origin& origin) : m_private(0) { |
| 128 if (origin.unique()) { | 131 if (origin.unique()) { |
| 129 assign(WebSecurityOrigin::createUnique()); | 132 assign(WebSecurityOrigin::createUnique()); |
| 130 return; | 133 return; |
| 131 } | 134 } |
| 132 | 135 |
| 133 // TODO(mkwst): This might open up issues by double-canonicalizing the host. | 136 // TODO(mkwst): This might open up issues by double-canonicalizing the host. |
| 134 assign(WebSecurityOrigin::createFromTuple( | 137 assign(WebSecurityOrigin::createFromTupleWithSuborigin( |
| 135 WebString::fromUTF8(origin.scheme()), | 138 WebString::fromUTF8(origin.scheme()), |
| 136 WebString::fromUTF8(origin.host()), origin.port())); | 139 WebString::fromUTF8(origin.host()), origin.port(), |
| 140 WebString::fromUTF8(origin.suborigin()))); |
| 137 } | 141 } |
| 138 #endif | 142 #endif |
| 139 | 143 |
| 140 private: | 144 private: |
| 141 // Present only to facilitate conversion from 'url::Origin'; this constructor | 145 // Present only to facilitate conversion from 'url::Origin'; this constructor |
| 142 // shouldn't be used anywhere else. | 146 // shouldn't be used anywhere else. |
| 143 BLINK_PLATFORM_EXPORT static WebSecurityOrigin | 147 BLINK_PLATFORM_EXPORT static WebSecurityOrigin createFromTupleWithSuborigin( |
| 144 createFromTuple(const WebString& protocol, const WebString& host, int port); | 148 const WebString& protocol, |
| 149 const WebString& host, |
| 150 int port, |
| 151 const WebString& suborigin); |
| 145 | 152 |
| 146 void assign(WebSecurityOriginPrivate*); | 153 void assign(WebSecurityOriginPrivate*); |
| 147 WebSecurityOriginPrivate* m_private; | 154 WebSecurityOriginPrivate* m_private; |
| 148 }; | 155 }; |
| 149 | 156 |
| 150 } // namespace blink | 157 } // namespace blink |
| 151 | 158 |
| 152 #endif | 159 #endif |
| OLD | NEW |