| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
| (...skipping 3692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3703 String Document::cookie(ExceptionState& exceptionState) const | 3703 String Document::cookie(ExceptionState& exceptionState) const |
| 3704 { | 3704 { |
| 3705 if (settings() && !settings()->cookieEnabled()) | 3705 if (settings() && !settings()->cookieEnabled()) |
| 3706 return String(); | 3706 return String(); |
| 3707 | 3707 |
| 3708 // FIXME: The HTML5 DOM spec states that this attribute can raise an | 3708 // FIXME: The HTML5 DOM spec states that this attribute can raise an |
| 3709 // InvalidStateError exception on getting if the Document has no | 3709 // InvalidStateError exception on getting if the Document has no |
| 3710 // browsing context. | 3710 // browsing context. |
| 3711 | 3711 |
| 3712 if (!securityOrigin()->canAccessCookies()) { | 3712 if (!securityOrigin()->canAccessCookies()) { |
| 3713 String accessDeniedMessage = "Access to 'cookie' is denied for this docu
ment."; | |
| 3714 if (isSandboxed(SandboxOrigin)) | 3713 if (isSandboxed(SandboxOrigin)) |
| 3715 exceptionState.throwSecurityError(accessDeniedMessage + " The docume
nt is sandboxed and lacks the 'allow-same-origin' flag."); | 3714 exceptionState.throwSecurityError("The document is sandboxed and lac
ks the 'allow-same-origin' flag."); |
| 3716 else if (url().protocolIs("data")) | 3715 else if (url().protocolIs("data")) |
| 3717 exceptionState.throwSecurityError(accessDeniedMessage + " Cookies ar
e disabled inside 'data:' URLs."); | 3716 exceptionState.throwSecurityError("Cookies are disabled inside 'data
:' URLs."); |
| 3718 else | 3717 else |
| 3719 exceptionState.throwSecurityError(accessDeniedMessage); | 3718 exceptionState.throwSecurityError("Access is denied for this documen
t."); |
| 3720 return String(); | 3719 return String(); |
| 3721 } | 3720 } |
| 3722 | 3721 |
| 3723 KURL cookieURL = this->cookieURL(); | 3722 KURL cookieURL = this->cookieURL(); |
| 3724 if (cookieURL.isEmpty()) | 3723 if (cookieURL.isEmpty()) |
| 3725 return String(); | 3724 return String(); |
| 3726 | 3725 |
| 3727 return cookies(this, cookieURL); | 3726 return cookies(this, cookieURL); |
| 3728 } | 3727 } |
| 3729 | 3728 |
| 3730 void Document::setCookie(const String& value, ExceptionState& exceptionState) | 3729 void Document::setCookie(const String& value, ExceptionState& exceptionState) |
| 3731 { | 3730 { |
| 3732 if (settings() && !settings()->cookieEnabled()) | 3731 if (settings() && !settings()->cookieEnabled()) |
| 3733 return; | 3732 return; |
| 3734 | 3733 |
| 3735 // FIXME: The HTML5 DOM spec states that this attribute can raise an | 3734 // FIXME: The HTML5 DOM spec states that this attribute can raise an |
| 3736 // InvalidStateError exception on setting if the Document has no | 3735 // InvalidStateError exception on setting if the Document has no |
| 3737 // browsing context. | 3736 // browsing context. |
| 3738 | 3737 |
| 3739 if (!securityOrigin()->canAccessCookies()) { | 3738 if (!securityOrigin()->canAccessCookies()) { |
| 3740 String accessDeniedMessage = "Access to 'cookie' is denied for this docu
ment."; | |
| 3741 if (isSandboxed(SandboxOrigin)) | 3739 if (isSandboxed(SandboxOrigin)) |
| 3742 exceptionState.throwSecurityError(accessDeniedMessage + " The docume
nt is sandboxed and lacks the 'allow-same-origin' flag."); | 3740 exceptionState.throwSecurityError("The document is sandboxed and lac
ks the 'allow-same-origin' flag."); |
| 3743 else if (url().protocolIs("data")) | 3741 else if (url().protocolIs("data")) |
| 3744 exceptionState.throwSecurityError(accessDeniedMessage + " Cookies ar
e disabled inside 'data:' URLs."); | 3742 exceptionState.throwSecurityError("Cookies are disabled inside 'data
:' URLs."); |
| 3745 else | 3743 else |
| 3746 exceptionState.throwSecurityError(accessDeniedMessage); | 3744 exceptionState.throwSecurityError("Access is denied for this documen
t."); |
| 3747 return; | 3745 return; |
| 3748 } | 3746 } |
| 3749 | 3747 |
| 3750 KURL cookieURL = this->cookieURL(); | 3748 KURL cookieURL = this->cookieURL(); |
| 3751 if (cookieURL.isEmpty()) | 3749 if (cookieURL.isEmpty()) |
| 3752 return; | 3750 return; |
| 3753 | 3751 |
| 3754 setCookies(this, cookieURL, value); | 3752 setCookies(this, cookieURL, value); |
| 3755 } | 3753 } |
| 3756 | 3754 |
| 3757 AtomicString Document::referrer() const | 3755 AtomicString Document::referrer() const |
| 3758 { | 3756 { |
| 3759 if (loader()) | 3757 if (loader()) |
| 3760 return loader()->request().httpReferrer(); | 3758 return loader()->request().httpReferrer(); |
| 3761 return nullAtom; | 3759 return nullAtom; |
| 3762 } | 3760 } |
| 3763 | 3761 |
| 3764 String Document::domain() const | 3762 String Document::domain() const |
| 3765 { | 3763 { |
| 3766 return securityOrigin()->domain(); | 3764 return securityOrigin()->domain(); |
| 3767 } | 3765 } |
| 3768 | 3766 |
| 3769 void Document::setDomain(const String& newDomain, ExceptionState& exceptionState
) | 3767 void Document::setDomain(const String& newDomain, ExceptionState& exceptionState
) |
| 3770 { | 3768 { |
| 3771 if (isSandboxed(SandboxDocumentDomain)) { | 3769 if (isSandboxed(SandboxDocumentDomain)) { |
| 3772 exceptionState.throwSecurityError(ExceptionMessages::failedToSet("domain
", "Document", "assignment is forbidden for sandboxed iframes.")); | 3770 exceptionState.throwSecurityError("Assignment is forbidden for sandboxed
iframes."); |
| 3773 return; | 3771 return; |
| 3774 } | 3772 } |
| 3775 | 3773 |
| 3776 if (SchemeRegistry::isDomainRelaxationForbiddenForURLScheme(securityOrigin()
->protocol())) { | 3774 if (SchemeRegistry::isDomainRelaxationForbiddenForURLScheme(securityOrigin()
->protocol())) { |
| 3777 exceptionState.throwSecurityError(ExceptionMessages::failedToSet("domain
", "Document", "assignment is forbidden for the '" + securityOrigin()->protocol(
) + "' scheme.")); | 3775 exceptionState.throwSecurityError("Assignment is forbidden for the '" +
securityOrigin()->protocol() + "' scheme."); |
| 3778 return; | 3776 return; |
| 3779 } | 3777 } |
| 3780 | 3778 |
| 3781 if (newDomain.isEmpty()) { | 3779 if (newDomain.isEmpty()) { |
| 3782 String exceptionMessage = ExceptionMessages::failedToSet("domain", "Docu
ment", "'" + newDomain + "' is an empty domain."); | 3780 exceptionState.throwSecurityError("'" + newDomain + "' is an empty domai
n."); |
| 3783 exceptionState.throwSecurityError(exceptionMessage); | |
| 3784 return; | 3781 return; |
| 3785 } | 3782 } |
| 3786 | 3783 |
| 3787 OriginAccessEntry::IPAddressSetting ipAddressSetting = settings() && setting
s()->treatIPAddressAsDomain() ? OriginAccessEntry::TreatIPAddressAsDomain : Orig
inAccessEntry::TreatIPAddressAsIPAddress; | 3784 OriginAccessEntry::IPAddressSetting ipAddressSetting = settings() && setting
s()->treatIPAddressAsDomain() ? OriginAccessEntry::TreatIPAddressAsDomain : Orig
inAccessEntry::TreatIPAddressAsIPAddress; |
| 3788 OriginAccessEntry accessEntry(securityOrigin()->protocol(), newDomain, Origi
nAccessEntry::AllowSubdomains, ipAddressSetting); | 3785 OriginAccessEntry accessEntry(securityOrigin()->protocol(), newDomain, Origi
nAccessEntry::AllowSubdomains, ipAddressSetting); |
| 3789 OriginAccessEntry::MatchResult result = accessEntry.matchesOrigin(*securityO
rigin()); | 3786 OriginAccessEntry::MatchResult result = accessEntry.matchesOrigin(*securityO
rigin()); |
| 3790 if (result == OriginAccessEntry::DoesNotMatchOrigin) { | 3787 if (result == OriginAccessEntry::DoesNotMatchOrigin) { |
| 3791 String exceptionMessage = ExceptionMessages::failedToSet("domain", "Docu
ment", "'" + newDomain + "' is not a suffix of '" + domain() + "'."); | 3788 exceptionState.throwSecurityError("'" + newDomain + "' is not a suffix o
f '" + domain() + "'."); |
| 3792 exceptionState.throwSecurityError(exceptionMessage); | |
| 3793 return; | 3789 return; |
| 3794 } | 3790 } |
| 3795 | 3791 |
| 3796 if (result == OriginAccessEntry::MatchesOriginButIsPublicSuffix) { | 3792 if (result == OriginAccessEntry::MatchesOriginButIsPublicSuffix) { |
| 3797 String exceptionMessage = ExceptionMessages::failedToSet("domain", "Docu
ment", "'" + newDomain + "' is a top-level domain."); | 3793 exceptionState.throwSecurityError("'" + newDomain + "' is a top-level do
main."); |
| 3798 exceptionState.throwSecurityError(exceptionMessage); | |
| 3799 return; | 3794 return; |
| 3800 } | 3795 } |
| 3801 | 3796 |
| 3802 securityOrigin()->setDomainFromDOM(newDomain); | 3797 securityOrigin()->setDomainFromDOM(newDomain); |
| 3803 if (m_frame) | 3798 if (m_frame) |
| 3804 m_frame->script().updateSecurityOrigin(); | 3799 m_frame->script().updateSecurityOrigin(); |
| 3805 } | 3800 } |
| 3806 | 3801 |
| 3807 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified | 3802 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified |
| 3808 String Document::lastModified() const | 3803 String Document::lastModified() const |
| (...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5234 } | 5229 } |
| 5235 | 5230 |
| 5236 FastTextAutosizer* Document::fastTextAutosizer() | 5231 FastTextAutosizer* Document::fastTextAutosizer() |
| 5237 { | 5232 { |
| 5238 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable
d()) | 5233 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable
d()) |
| 5239 m_fastTextAutosizer = FastTextAutosizer::create(this); | 5234 m_fastTextAutosizer = FastTextAutosizer::create(this); |
| 5240 return m_fastTextAutosizer.get(); | 5235 return m_fastTextAutosizer.get(); |
| 5241 } | 5236 } |
| 5242 | 5237 |
| 5243 } // namespace WebCore | 5238 } // namespace WebCore |
| OLD | NEW |