| 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 4846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4857 | 4857 |
| 4858 m_useSecureKeyboardEntryWhenActive = usesSecureKeyboard; | 4858 m_useSecureKeyboardEntryWhenActive = usesSecureKeyboard; |
| 4859 m_frame->selection().updateSecureKeyboardEntryIfActive(); | 4859 m_frame->selection().updateSecureKeyboardEntryIfActive(); |
| 4860 } | 4860 } |
| 4861 | 4861 |
| 4862 bool Document::useSecureKeyboardEntryWhenActive() const | 4862 bool Document::useSecureKeyboardEntryWhenActive() const |
| 4863 { | 4863 { |
| 4864 return m_useSecureKeyboardEntryWhenActive; | 4864 return m_useSecureKeyboardEntryWhenActive; |
| 4865 } | 4865 } |
| 4866 | 4866 |
| 4867 void Document::initSecurityContext() | |
| 4868 { | |
| 4869 initSecurityContext(DocumentInit(m_url, m_frame, contextDocument(), m_import
sController)); | |
| 4870 } | |
| 4871 | |
| 4872 void Document::initSecurityContext(const DocumentInit& initializer) | 4867 void Document::initSecurityContext(const DocumentInit& initializer) |
| 4873 { | 4868 { |
| 4874 if (haveInitializedSecurityOrigin()) { | 4869 if (haveInitializedSecurityOrigin()) { |
| 4875 ASSERT(securityOrigin()); | 4870 ASSERT(securityOrigin()); |
| 4876 return; | 4871 return; |
| 4877 } | 4872 } |
| 4878 | 4873 |
| 4879 if (initializer.isHostedInReservedIPRange()) | 4874 if (initializer.isHostedInReservedIPRange()) |
| 4880 setHostedInReservedIPRange(); | 4875 setHostedInReservedIPRange(); |
| 4881 | 4876 |
| 4882 if (!initializer.hasSecurityContext()) { | 4877 if (!initializer.hasSecurityContext()) { |
| 4883 // No source for a security context. | 4878 // No source for a security context. |
| 4884 // This can occur via document.implementation.createDocument(). | 4879 // This can occur via document.implementation.createDocument(). |
| 4885 m_cookieURL = KURL(ParsedURLString, emptyString()); | 4880 m_cookieURL = KURL(ParsedURLString, emptyString()); |
| 4886 setSecurityOrigin(SecurityOrigin::createUnique()); | 4881 setSecurityOrigin(SecurityOrigin::createUnique()); |
| 4887 initContentSecurityPolicy(); | 4882 initContentSecurityPolicy(); |
| 4888 return; | 4883 return; |
| 4889 } | 4884 } |
| 4890 | 4885 |
| 4891 // In the common case, create the security context from the currently | 4886 // In the common case, create the security context from the currently |
| 4892 // loading URL with a fresh content security policy. | 4887 // loading URL with a fresh content security policy. |
| 4893 m_cookieURL = m_url; | |
| 4894 enforceSandboxFlags(initializer.sandboxFlags()); | 4888 enforceSandboxFlags(initializer.sandboxFlags()); |
| 4895 if (initializer.shouldEnforceStrictMixedContentChecking()) | 4889 if (initializer.shouldEnforceStrictMixedContentChecking()) |
| 4896 enforceStrictMixedContentChecking(); | 4890 enforceStrictMixedContentChecking(); |
| 4897 setInsecureRequestsPolicy(initializer.insecureRequestsPolicy()); | 4891 setInsecureRequestsPolicy(initializer.insecureRequestsPolicy()); |
| 4898 if (initializer.insecureNavigationsToUpgrade()) { | 4892 if (initializer.insecureNavigationsToUpgrade()) { |
| 4899 for (auto toUpgrade : *initializer.insecureNavigationsToUpgrade()) | 4893 for (auto toUpgrade : *initializer.insecureNavigationsToUpgrade()) |
| 4900 addInsecureNavigationUpgrade(toUpgrade); | 4894 addInsecureNavigationUpgrade(toUpgrade); |
| 4901 } | 4895 } |
| 4902 setSecurityOrigin(isSandboxed(SandboxOrigin) ? SecurityOrigin::createUnique(
) : SecurityOrigin::create(m_url)); | 4896 |
| 4897 if (isSandboxed(SandboxOrigin)) { |
| 4898 m_cookieURL = m_url; |
| 4899 setSecurityOrigin(SecurityOrigin::createUnique()); |
| 4900 // If we're supposed to inherit our security origin from our owner, |
| 4901 // but we're also sandboxed, the only thing we inherit is the ability |
| 4902 // to load local resources. This lets about:blank iframes in file:// |
| 4903 // URL documents load images and other resources from the file system. |
| 4904 if (initializer.owner() && initializer.owner()->securityOrigin()->canLoa
dLocalResources()) |
| 4905 securityOrigin()->grantLoadLocalResources(); |
| 4906 } else if (initializer.owner()) { |
| 4907 m_cookieURL = initializer.owner()->cookieURL(); |
| 4908 // We alias the SecurityOrigins to match Firefox, see Bug 15313 |
| 4909 // https://bugs.webkit.org/show_bug.cgi?id=15313 |
| 4910 setSecurityOrigin(initializer.owner()->securityOrigin()); |
| 4911 } else { |
| 4912 m_cookieURL = m_url; |
| 4913 setSecurityOrigin(SecurityOrigin::create(m_url)); |
| 4914 } |
| 4903 | 4915 |
| 4904 if (importsController()) { | 4916 if (importsController()) { |
| 4905 // If this document is an HTML import, grab a reference to it's master d
ocument's Content | 4917 // If this document is an HTML import, grab a reference to it's master d
ocument's Content |
| 4906 // Security Policy. We don't call 'initContentSecurityPolicy' in this ca
se, as we can't | 4918 // Security Policy. We don't call 'initContentSecurityPolicy' in this ca
se, as we can't |
| 4907 // rebind the master document's policy object: its ExecutionContext need
s to remain tied | 4919 // rebind the master document's policy object: its ExecutionContext need
s to remain tied |
| 4908 // to the master document. | 4920 // to the master document. |
| 4909 setContentSecurityPolicy(importsController()->master()->contentSecurityP
olicy()); | 4921 setContentSecurityPolicy(importsController()->master()->contentSecurityP
olicy()); |
| 4910 } else { | 4922 } else { |
| 4911 initContentSecurityPolicy(); | 4923 initContentSecurityPolicy(); |
| 4912 } | 4924 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4924 // Some clients do not want local URLs to have access to other l
ocal URLs. | 4936 // Some clients do not want local URLs to have access to other l
ocal URLs. |
| 4925 securityOrigin()->blockLocalAccessFromLocalOrigin(); | 4937 securityOrigin()->blockLocalAccessFromLocalOrigin(); |
| 4926 } | 4938 } |
| 4927 } | 4939 } |
| 4928 } | 4940 } |
| 4929 | 4941 |
| 4930 if (initializer.shouldTreatURLAsSrcdocDocument()) { | 4942 if (initializer.shouldTreatURLAsSrcdocDocument()) { |
| 4931 m_isSrcdocDocument = true; | 4943 m_isSrcdocDocument = true; |
| 4932 setBaseURLOverride(initializer.parentBaseURL()); | 4944 setBaseURLOverride(initializer.parentBaseURL()); |
| 4933 } | 4945 } |
| 4934 | |
| 4935 if (!shouldInheritSecurityOriginFromOwner(m_url)) | |
| 4936 return; | |
| 4937 | |
| 4938 // If we do not obtain a meaningful origin from the URL, then we try to | |
| 4939 // find one via the frame hierarchy. | |
| 4940 | |
| 4941 if (!initializer.owner()) { | |
| 4942 didFailToInitializeSecurityOrigin(); | |
| 4943 return; | |
| 4944 } | |
| 4945 | |
| 4946 if (isSandboxed(SandboxOrigin)) { | |
| 4947 // If we're supposed to inherit our security origin from our owner, | |
| 4948 // but we're also sandboxed, the only thing we inherit is the ability | |
| 4949 // to load local resources. This lets about:blank iframes in file:// | |
| 4950 // URL documents load images and other resources from the file system. | |
| 4951 if (initializer.owner()->securityOrigin()->canLoadLocalResources()) | |
| 4952 securityOrigin()->grantLoadLocalResources(); | |
| 4953 return; | |
| 4954 } | |
| 4955 | |
| 4956 m_cookieURL = initializer.owner()->cookieURL(); | |
| 4957 // We alias the SecurityOrigins to match Firefox, see Bug 15313 | |
| 4958 // https://bugs.webkit.org/show_bug.cgi?id=15313 | |
| 4959 setSecurityOrigin(initializer.owner()->securityOrigin()); | |
| 4960 } | 4946 } |
| 4961 | 4947 |
| 4962 void Document::initContentSecurityPolicy(PassRefPtrWillBeRawPtr<ContentSecurityP
olicy> csp) | 4948 void Document::initContentSecurityPolicy(PassRefPtrWillBeRawPtr<ContentSecurityP
olicy> csp) |
| 4963 { | 4949 { |
| 4964 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create()); | 4950 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create()); |
| 4965 if (m_frame && m_frame->tree().parent() && m_frame->tree().parent()->isLocal
Frame()) { | 4951 if (m_frame && m_frame->tree().parent() && m_frame->tree().parent()->isLocal
Frame()) { |
| 4966 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent()
)->document()->contentSecurityPolicy(); | 4952 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent()
)->document()->contentSecurityPolicy(); |
| 4967 if (shouldInheritSecurityOriginFromOwner(m_url)) { | 4953 if (shouldInheritSecurityOriginFromOwner(m_url)) { |
| 4968 contentSecurityPolicy()->copyStateFrom(parentCSP); | 4954 contentSecurityPolicy()->copyStateFrom(parentCSP); |
| 4969 } else if (isPluginDocument()) { | 4955 } else if (isPluginDocument()) { |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5948 #ifndef NDEBUG | 5934 #ifndef NDEBUG |
| 5949 using namespace blink; | 5935 using namespace blink; |
| 5950 void showLiveDocumentInstances() | 5936 void showLiveDocumentInstances() |
| 5951 { | 5937 { |
| 5952 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5938 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
| 5953 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5939 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 5954 for (Document* document : set) | 5940 for (Document* document : set) |
| 5955 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5941 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
| 5956 } | 5942 } |
| 5957 #endif | 5943 #endif |
| OLD | NEW |