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

Side by Side Diff: Source/platform/weborigin/OriginAccessEntry.cpp

Issue 54053006: Move weborigin/ under platform/ so that it may someday call platform APIs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "weborigin/OriginAccessEntry.h" 32 #include "platform/weborigin/OriginAccessEntry.h"
33 33
34 #include "weborigin/SecurityOrigin.h" 34 #include "public/platform/Platform.h"
35 #include "public/platform/WebPublicSuffixList.h"
36 #include "public/platform/WebString.h"
37 #include "platform/weborigin/SecurityOrigin.h"
38 #include "wtf/text/WTFString.h"
35 39
36 namespace WebCore { 40 namespace WebCore {
37 41
38 OriginAccessEntry::OriginAccessEntry(const String& protocol, const String& host, SubdomainSetting subdomainSetting, IPAddressSetting ipAddressSetting) 42 OriginAccessEntry::OriginAccessEntry(const String& protocol, const String& host, SubdomainSetting subdomainSetting, IPAddressSetting ipAddressSetting)
39 : m_protocol(protocol.lower()) 43 : m_protocol(protocol.lower())
40 , m_host(host.lower()) 44 , m_host(host.lower())
41 , m_subdomainSettings(subdomainSetting) 45 , m_subdomainSettings(subdomainSetting)
42 , m_ipAddressSettings(ipAddressSetting) 46 , m_ipAddressSettings(ipAddressSetting)
43 { 47 {
44 ASSERT(subdomainSetting == AllowSubdomains || subdomainSetting == DisallowSu bdomains); 48 ASSERT(subdomainSetting == AllowSubdomains || subdomainSetting == DisallowSu bdomains);
(...skipping 19 matching lines...) Expand all
64 return true; 68 return true;
65 69
66 // Otherwise we can only match if we're matching subdomains. 70 // Otherwise we can only match if we're matching subdomains.
67 if (m_subdomainSettings == DisallowSubdomains) 71 if (m_subdomainSettings == DisallowSubdomains)
68 return false; 72 return false;
69 73
70 // Don't try to do subdomain matching on IP addresses. 74 // Don't try to do subdomain matching on IP addresses.
71 if (m_hostIsIPAddress && m_ipAddressSettings == TreatIPAddressAsIPAddress) 75 if (m_hostIsIPAddress && m_ipAddressSettings == TreatIPAddressAsIPAddress)
72 return false; 76 return false;
73 77
78 // Don't allow top-level domains, either with or without an additional dot.
79 if (WebKit::WebPublicSuffixList* suffixList = WebKit::Platform::current()->p ublicSuffixList()) {
80 if (origin.host().length() <= suffixList->getPublicSuffixLength(origin.h ost()) + 1)
81 return false;
82 }
83
74 // Match subdomains. 84 // Match subdomains.
75 if (origin.host().length() > m_host.length() && origin.host()[origin.host(). length() - m_host.length() - 1] == '.' && origin.host().endsWith(m_host)) 85 if (origin.host().length() > m_host.length() && origin.host()[origin.host(). length() - m_host.length() - 1] == '.' && origin.host().endsWith(m_host))
76 return true; 86 return true;
77 87
78 return false; 88 return false;
79 } 89 }
80 90
81 } // namespace WebCore 91 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698