Chromium Code Reviews| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 | 64 |
| 65 BLINK_PLATFORM_EXPORT void reset(); | 65 BLINK_PLATFORM_EXPORT void reset(); |
| 66 BLINK_PLATFORM_EXPORT void assign(const WebSecurityOrigin&); | 66 BLINK_PLATFORM_EXPORT void assign(const WebSecurityOrigin&); |
| 67 | 67 |
| 68 bool isNull() const { return !m_private; } | 68 bool isNull() const { return !m_private; } |
| 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 metho d | 74 // |port()| will return 0 if the port is the default for an origin. This |
| 75 // 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 // A unique WebSecurityOrigin is the least privileged WebSecurityOrigin. | 79 // A unique WebSecurityOrigin is the least privileged WebSecurityOrigin. |
| 80 BLINK_PLATFORM_EXPORT bool isUnique() const; | 80 BLINK_PLATFORM_EXPORT bool isUnique() const; |
| 81 | 81 |
| 82 // Returns true if this WebSecurityOrigin can script objects in the given | 82 // Returns true if this WebSecurityOrigin can script objects in the given |
| 83 // SecurityOrigin. For example, call this function before allowing | 83 // SecurityOrigin. For example, call this function before allowing |
| 84 // script from one security origin to read or write objects from | 84 // script from one security origin to read or write objects from |
| 85 // another SecurityOrigin. | 85 // another SecurityOrigin. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 108 // Allows this WebSecurityOrigin access to local resources. | 108 // Allows this WebSecurityOrigin access to local resources. |
| 109 BLINK_PLATFORM_EXPORT void grantLoadLocalResources() const; | 109 BLINK_PLATFORM_EXPORT void grantLoadLocalResources() const; |
| 110 | 110 |
| 111 #if INSIDE_BLINK | 111 #if INSIDE_BLINK |
| 112 BLINK_PLATFORM_EXPORT WebSecurityOrigin(WTF::PassRefPtr<SecurityOrigin>); | 112 BLINK_PLATFORM_EXPORT WebSecurityOrigin(WTF::PassRefPtr<SecurityOrigin>); |
| 113 BLINK_PLATFORM_EXPORT WebSecurityOrigin& operator=( | 113 BLINK_PLATFORM_EXPORT WebSecurityOrigin& operator=( |
| 114 WTF::PassRefPtr<SecurityOrigin>); | 114 WTF::PassRefPtr<SecurityOrigin>); |
| 115 BLINK_PLATFORM_EXPORT operator WTF::PassRefPtr<SecurityOrigin>() const; | 115 BLINK_PLATFORM_EXPORT operator WTF::PassRefPtr<SecurityOrigin>() const; |
| 116 BLINK_PLATFORM_EXPORT SecurityOrigin* get() const; | 116 BLINK_PLATFORM_EXPORT SecurityOrigin* get() const; |
| 117 #else | 117 #else |
| 118 // TODO(mkwst): A number of properties don't survive a round-trip ('document.d omain', for instance). | 118 // TODO(mkwst): A number of properties don't survive a round-trip |
| 119 // We'll need to fix that for OOPI-enabled embedders: https://crbug.com/490074 . | 119 // ('document.domain', for instance). |
| 120 // We'll need to fix that for OOPI-enabled embedders, // https://crbug.com/490 074. | |
|
dcheng
2016/10/03 18:11:48
Nit: merge this into previous line (this is all pa
Nico
2016/10/03 21:53:19
Done.
| |
| 120 operator url::Origin() const { | 121 operator url::Origin() const { |
| 121 return isUnique() ? url::Origin() | 122 return isUnique() ? url::Origin() |
| 122 : url::Origin::UnsafelyCreateOriginWithoutNormalization( | 123 : url::Origin::UnsafelyCreateOriginWithoutNormalization( |
| 123 protocol().utf8(), host().utf8(), effectivePort()); | 124 protocol().utf8(), host().utf8(), effectivePort()); |
| 124 } | 125 } |
| 125 | 126 |
| 126 WebSecurityOrigin(const url::Origin& origin) : m_private(0) { | 127 WebSecurityOrigin(const url::Origin& origin) : m_private(0) { |
| 127 if (origin.unique()) { | 128 if (origin.unique()) { |
| 128 assign(WebSecurityOrigin::createUnique()); | 129 assign(WebSecurityOrigin::createUnique()); |
| 129 return; | 130 return; |
| 130 } | 131 } |
| 131 | 132 |
| 132 // TODO(mkwst): This might open up issues by double-canonicalizing the host. | 133 // TODO(mkwst): This might open up issues by double-canonicalizing the host. |
| 133 assign(WebSecurityOrigin::createFromTuple( | 134 assign(WebSecurityOrigin::createFromTuple( |
| 134 WebString::fromUTF8(origin.scheme()), | 135 WebString::fromUTF8(origin.scheme()), |
| 135 WebString::fromUTF8(origin.host()), origin.port())); | 136 WebString::fromUTF8(origin.host()), origin.port())); |
| 136 } | 137 } |
| 137 #endif | 138 #endif |
| 138 | 139 |
| 139 private: | 140 private: |
| 140 // Present only to facilitate conversion from 'url::Origin'; this constructor shouldn't be used anywhere else. | 141 // Present only to facilitate conversion from 'url::Origin'; this constructor |
| 142 // shouldn't be used anywhere else. | |
| 141 BLINK_PLATFORM_EXPORT static WebSecurityOrigin | 143 BLINK_PLATFORM_EXPORT static WebSecurityOrigin |
| 142 createFromTuple(const WebString& protocol, const WebString& host, int port); | 144 createFromTuple(const WebString& protocol, const WebString& host, int port); |
| 143 | 145 |
| 144 void assign(WebSecurityOriginPrivate*); | 146 void assign(WebSecurityOriginPrivate*); |
| 145 WebSecurityOriginPrivate* m_private; | 147 WebSecurityOriginPrivate* m_private; |
| 146 }; | 148 }; |
| 147 | 149 |
| 148 } // namespace blink | 150 } // namespace blink |
| 149 | 151 |
| 150 #endif | 152 #endif |
| OLD | NEW |