| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 class SecurityOrigin; | 39 class SecurityOrigin; |
| 40 | 40 |
| 41 class PLATFORM_EXPORT OriginAccessEntry { | 41 class PLATFORM_EXPORT OriginAccessEntry { |
| 42 public: | 42 public: |
| 43 enum SubdomainSetting { | 43 enum SubdomainSetting { |
| 44 AllowSubdomains, | 44 AllowSubdomains, |
| 45 DisallowSubdomains | 45 DisallowSubdomains |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 // Note that 'TreatIPAddressAsDomain' MUST only be used for testing, and doe
s not work for IPv6 addresses. It does the | |
| 49 // bare minimum necessary to support 'document.domain' layout test expectati
ons, and should not be relied upon for either | |
| 50 // robustness or sanity. | |
| 51 // | |
| 52 // TODO(mkwst): Remove this enum once we rewrite the 'document.domain' layou
t tests to use '*.example.test' rather than | |
| 53 // raw IP addresses. | |
| 54 enum IPAddressSetting { | 48 enum IPAddressSetting { |
| 55 TreatIPAddressAsDomain, | 49 TreatIPAddressAsDomain, |
| 56 TreatIPAddressAsIPAddress | 50 TreatIPAddressAsIPAddress |
| 57 }; | 51 }; |
| 58 | 52 |
| 59 enum MatchResult { | 53 enum MatchResult { |
| 60 MatchesOrigin, | 54 MatchesOrigin, |
| 61 MatchesOriginButIsPublicSuffix, | 55 MatchesOriginButIsPublicSuffix, |
| 62 DoesNotMatchOrigin | 56 DoesNotMatchOrigin |
| 63 }; | 57 }; |
| 64 | 58 |
| 65 // If host is empty string and SubdomainSetting is AllowSubdomains, the entr
y will match all domains in the specified protocol. | 59 // If host is empty string and SubdomainSetting is AllowSubdomains, the entr
y will match all domains in the specified protocol. |
| 66 // IPv6 addresses must include brackets (e.g. '[2001:db8:85a3::8a2e:370:7334
]', not '2001:db8:85a3::8a2e:370:7334'). | |
| 67 OriginAccessEntry(const String& protocol, const String& host, SubdomainSetti
ng, IPAddressSetting); | 60 OriginAccessEntry(const String& protocol, const String& host, SubdomainSetti
ng, IPAddressSetting); |
| 68 MatchResult matchesOrigin(const SecurityOrigin&) const; | 61 MatchResult matchesOrigin(const SecurityOrigin&) const; |
| 69 | 62 |
| 70 const String& protocol() const { return m_protocol; } | 63 const String& protocol() const { return m_protocol; } |
| 71 const String& host() const { return m_host; } | 64 const String& host() const { return m_host; } |
| 72 SubdomainSetting subdomainSettings() const { return m_subdomainSettings; } | 65 SubdomainSetting subdomainSettings() const { return m_subdomainSettings; } |
| 73 IPAddressSetting ipAddressSettings() const { return m_ipAddressSettings; } | 66 IPAddressSetting ipAddressSettings() const { return m_ipAddressSettings; } |
| 74 bool hostIsIPAddress() const { return m_hostIsIPAddress; } | |
| 75 | 67 |
| 76 private: | 68 private: |
| 77 String m_protocol; | 69 String m_protocol; |
| 78 String m_host; | 70 String m_host; |
| 79 SubdomainSetting m_subdomainSettings; | 71 SubdomainSetting m_subdomainSettings; |
| 80 IPAddressSetting m_ipAddressSettings; | 72 IPAddressSetting m_ipAddressSettings; |
| 81 bool m_hostIsIPAddress; | 73 bool m_hostIsIPAddress; |
| 82 bool m_hostIsPublicSuffix; | 74 bool m_hostIsPublicSuffix; |
| 83 }; | 75 }; |
| 84 | 76 |
| 85 PLATFORM_EXPORT inline bool operator==(const OriginAccessEntry& a, const OriginA
ccessEntry& b) | 77 PLATFORM_EXPORT inline bool operator==(const OriginAccessEntry& a, const OriginA
ccessEntry& b) |
| 86 { | 78 { |
| 87 return equalIgnoringCase(a.protocol(), b.protocol()) | 79 return equalIgnoringCase(a.protocol(), b.protocol()) |
| 88 && equalIgnoringCase(a.host(), b.host()) | 80 && equalIgnoringCase(a.host(), b.host()) |
| 89 && a.subdomainSettings() == b.subdomainSettings() | 81 && a.subdomainSettings() == b.subdomainSettings() |
| 90 && a.ipAddressSettings() == b.ipAddressSettings(); | 82 && a.ipAddressSettings() == b.ipAddressSettings(); |
| 91 } | 83 } |
| 92 | 84 |
| 93 PLATFORM_EXPORT inline bool operator!=(const OriginAccessEntry& a, const OriginA
ccessEntry& b) | 85 PLATFORM_EXPORT inline bool operator!=(const OriginAccessEntry& a, const OriginA
ccessEntry& b) |
| 94 { | 86 { |
| 95 return !(a == b); | 87 return !(a == b); |
| 96 } | 88 } |
| 97 | 89 |
| 98 } // namespace blink | 90 } // namespace blink |
| 99 | 91 |
| 100 #endif // OriginAccessEntry_h | 92 #endif // OriginAccessEntry_h |
| OLD | NEW |