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