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. |
48 enum IPAddressSetting { | 54 enum IPAddressSetting { |
49 TreatIPAddressAsDomain, | 55 TreatIPAddressAsDomain, |
50 TreatIPAddressAsIPAddress | 56 TreatIPAddressAsIPAddress |
51 }; | 57 }; |
52 | 58 |
53 enum MatchResult { | 59 enum MatchResult { |
54 MatchesOrigin, | 60 MatchesOrigin, |
55 MatchesOriginButIsPublicSuffix, | 61 MatchesOriginButIsPublicSuffix, |
56 DoesNotMatchOrigin | 62 DoesNotMatchOrigin |
57 }; | 63 }; |
58 | 64 |
59 // If host is empty string and SubdomainSetting is AllowSubdomains, the entr
y will match all domains in the specified protocol. | 65 // 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'). |
60 OriginAccessEntry(const String& protocol, const String& host, SubdomainSetti
ng, IPAddressSetting); | 67 OriginAccessEntry(const String& protocol, const String& host, SubdomainSetti
ng, IPAddressSetting); |
61 MatchResult matchesOrigin(const SecurityOrigin&) const; | 68 MatchResult matchesOrigin(const SecurityOrigin&) const; |
62 | 69 |
63 const String& protocol() const { return m_protocol; } | 70 const String& protocol() const { return m_protocol; } |
64 const String& host() const { return m_host; } | 71 const String& host() const { return m_host; } |
65 SubdomainSetting subdomainSettings() const { return m_subdomainSettings; } | 72 SubdomainSetting subdomainSettings() const { return m_subdomainSettings; } |
66 IPAddressSetting ipAddressSettings() const { return m_ipAddressSettings; } | 73 IPAddressSetting ipAddressSettings() const { return m_ipAddressSettings; } |
| 74 bool hostIsIPAddress() const { return m_hostIsIPAddress; } |
67 | 75 |
68 private: | 76 private: |
69 String m_protocol; | 77 String m_protocol; |
70 String m_host; | 78 String m_host; |
71 SubdomainSetting m_subdomainSettings; | 79 SubdomainSetting m_subdomainSettings; |
72 IPAddressSetting m_ipAddressSettings; | 80 IPAddressSetting m_ipAddressSettings; |
73 bool m_hostIsIPAddress; | 81 bool m_hostIsIPAddress; |
74 bool m_hostIsPublicSuffix; | 82 bool m_hostIsPublicSuffix; |
75 }; | 83 }; |
76 | 84 |
77 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) |
78 { | 86 { |
79 return equalIgnoringCase(a.protocol(), b.protocol()) | 87 return equalIgnoringCase(a.protocol(), b.protocol()) |
80 && equalIgnoringCase(a.host(), b.host()) | 88 && equalIgnoringCase(a.host(), b.host()) |
81 && a.subdomainSettings() == b.subdomainSettings() | 89 && a.subdomainSettings() == b.subdomainSettings() |
82 && a.ipAddressSettings() == b.ipAddressSettings(); | 90 && a.ipAddressSettings() == b.ipAddressSettings(); |
83 } | 91 } |
84 | 92 |
85 PLATFORM_EXPORT inline bool operator!=(const OriginAccessEntry& a, const OriginA
ccessEntry& b) | 93 PLATFORM_EXPORT inline bool operator!=(const OriginAccessEntry& a, const OriginA
ccessEntry& b) |
86 { | 94 { |
87 return !(a == b); | 95 return !(a == b); |
88 } | 96 } |
89 | 97 |
90 } // namespace blink | 98 } // namespace blink |
91 | 99 |
92 #endif // OriginAccessEntry_h | 100 #endif // OriginAccessEntry_h |
OLD | NEW |