Title: [100117] trunk/Source/WebCore
Revision
100117
Author
[email protected]
Date
2011-11-14 02:26:49 -0800 (Mon, 14 Nov 2011)

Log Message

SecurityContext should track whether the SecurityOrigin has been initialized
https://bugs.webkit.org/show_bug.cgi?id=72250

Reviewed by Eric Seidel.

This patch is another step towards https://bugs.webkit.org/show_bug.cgi?id=71745.

One of the things we use "empty" SecurityOrigins for is detecting
whether a Document's SecurityOrigin has been initialized.  In this
patch, we track that state directly on SecurityContext (which is a base
class of Document), moving us closer to removing the concept of an
empty SecurityOrigin.

* dom/Document.cpp:
(WebCore::Document::initSecurityContext):
* dom/SecurityContext.cpp:
(WebCore::SecurityContext::SecurityContext):
(WebCore::SecurityContext::setSecurityOrigin):
* dom/SecurityContext.h:
(WebCore::SecurityContext::didFailToInitializeSecurityOrigin):
(WebCore::SecurityContext::haveInitializedSecurityOrigin):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (100116 => 100117)


--- trunk/Source/WebCore/ChangeLog	2011-11-14 10:00:08 UTC (rev 100116)
+++ trunk/Source/WebCore/ChangeLog	2011-11-14 10:26:49 UTC (rev 100117)
@@ -1,3 +1,27 @@
+2011-11-14  Adam Barth  <[email protected]>
+
+        SecurityContext should track whether the SecurityOrigin has been initialized
+        https://bugs.webkit.org/show_bug.cgi?id=72250
+
+        Reviewed by Eric Seidel.
+
+        This patch is another step towards https://bugs.webkit.org/show_bug.cgi?id=71745.
+
+        One of the things we use "empty" SecurityOrigins for is detecting
+        whether a Document's SecurityOrigin has been initialized.  In this
+        patch, we track that state directly on SecurityContext (which is a base
+        class of Document), moving us closer to removing the concept of an
+        empty SecurityOrigin.
+
+        * dom/Document.cpp:
+        (WebCore::Document::initSecurityContext):
+        * dom/SecurityContext.cpp:
+        (WebCore::SecurityContext::SecurityContext):
+        (WebCore::SecurityContext::setSecurityOrigin):
+        * dom/SecurityContext.h:
+        (WebCore::SecurityContext::didFailToInitializeSecurityOrigin):
+        (WebCore::SecurityContext::haveInitializedSecurityOrigin):
+
 2011-11-14  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix make distcheck build.

Modified: trunk/Source/WebCore/dom/Document.cpp (100116 => 100117)


--- trunk/Source/WebCore/dom/Document.cpp	2011-11-14 10:00:08 UTC (rev 100116)
+++ trunk/Source/WebCore/dom/Document.cpp	2011-11-14 10:26:49 UTC (rev 100117)
@@ -4392,8 +4392,10 @@
 
 void Document::initSecurityContext()
 {
-    if (securityOrigin() && !securityOrigin()->isEmpty())
-        return; // m_securityOrigin has already been initialized.
+    if (haveInitializedSecurityOrigin()) {
+        ASSERT(securityOrigin());
+        return;
+    }
 
     if (!m_frame) {
         // No source for a security context.
@@ -4450,8 +4452,10 @@
     if (!ownerFrame)
         ownerFrame = m_frame->loader()->opener();
 
-    if (!ownerFrame)
+    if (!ownerFrame) {
+        didFailToInitializeSecurityOrigin();
         return;
+    }
 
     m_cookieURL = ownerFrame->document()->cookieURL();
     // We alias the SecurityOrigins to match Firefox, see Bug 15313

Modified: trunk/Source/WebCore/dom/SecurityContext.cpp (100116 => 100117)


--- trunk/Source/WebCore/dom/SecurityContext.cpp	2011-11-14 10:00:08 UTC (rev 100116)
+++ trunk/Source/WebCore/dom/SecurityContext.cpp	2011-11-14 10:26:49 UTC (rev 100117)
@@ -34,7 +34,8 @@
 namespace WebCore {
 
 SecurityContext::SecurityContext()
-    : m_sandboxFlags(SandboxNone)
+    : m_haveInitializedSecurityOrigin(false)
+    , m_sandboxFlags(SandboxNone)
 {
 }
 
@@ -45,6 +46,7 @@
 void SecurityContext::setSecurityOrigin(PassRefPtr<SecurityOrigin> securityOrigin)
 {
     m_securityOrigin = securityOrigin;
+    m_haveInitializedSecurityOrigin = true;
 }
 
 void SecurityContext::setContentSecurityPolicy(PassRefPtr<ContentSecurityPolicy> contentSecurityPolicy)

Modified: trunk/Source/WebCore/dom/SecurityContext.h (100116 => 100117)


--- trunk/Source/WebCore/dom/SecurityContext.h	2011-11-14 10:00:08 UTC (rev 100116)
+++ trunk/Source/WebCore/dom/SecurityContext.h	2011-11-14 10:26:49 UTC (rev 100117)
@@ -74,7 +74,11 @@
     void setSecurityOrigin(PassRefPtr<SecurityOrigin>);
     void setContentSecurityPolicy(PassRefPtr<ContentSecurityPolicy>);
 
+    void didFailToInitializeSecurityOrigin() { m_haveInitializedSecurityOrigin = false; }
+    bool haveInitializedSecurityOrigin() const { return m_haveInitializedSecurityOrigin; }
+
 private:
+    bool m_haveInitializedSecurityOrigin;
     SandboxFlags m_sandboxFlags;
     RefPtr<SecurityOrigin> m_securityOrigin;
     RefPtr<ContentSecurityPolicy> m_contentSecurityPolicy;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to