Title: [133425] trunk/Source/WebKit2
Revision
133425
Author
[email protected]
Date
2012-11-04 14:26:02 -0800 (Sun, 04 Nov 2012)

Log Message

Expose security origin to BundleFrame
https://bugs.webkit.org/show_bug.cgi?id=101139
<rdar://problem/12629900>

Reviewed by Darin Adler.

Create a WebSecurityOrigin instance, sharing the security origin instance
that comes directly from the frame's document. We can do this because the
WK2 API only retrieves information about the origin, and because those
results are returned as copies. The security origin holds no references
that could lead to a retain cycle, avoiding the possibility that the
injected bundle accidentally keeps something alive.

* Shared/API/c/WKSharedAPICast.h:
(WebKit::toCopiedAPI): Create copied API for WebCore::SecurityOrigin
instances.
* Shared/WebSecurityOrigin.h:
(WebKit::WebSecurityOrigin::create): Add a new create() function that
takes a PassRefPtr to a WebCore SecurityOrigin instance.
(WebKit::WebSecurityOrigin::createFromString): Refactor to use new create()
function.
(WebKit::WebSecurityOrigin::createFromDatabaseIdentifier): Refactor to
use new create() function.
(WebKit::WebSecurityOrigin::create): Refactor to use new create()
function.
* WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
(WKBundleFrameCopySecurityOrigin): Add function to retrieve the security
origin as a WK2 API object.
* WebProcess/InjectedBundle/API/c/WKBundleFrame.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (133424 => 133425)


--- trunk/Source/WebKit2/ChangeLog	2012-11-04 17:27:45 UTC (rev 133424)
+++ trunk/Source/WebKit2/ChangeLog	2012-11-04 22:26:02 UTC (rev 133425)
@@ -1,3 +1,35 @@
+2012-11-04  Jon Lee  <[email protected]>
+
+        Expose security origin to BundleFrame
+        https://bugs.webkit.org/show_bug.cgi?id=101139
+        <rdar://problem/12629900>
+
+        Reviewed by Darin Adler.
+
+        Create a WebSecurityOrigin instance, sharing the security origin instance
+        that comes directly from the frame's document. We can do this because the
+        WK2 API only retrieves information about the origin, and because those
+        results are returned as copies. The security origin holds no references
+        that could lead to a retain cycle, avoiding the possibility that the
+        injected bundle accidentally keeps something alive.
+
+        * Shared/API/c/WKSharedAPICast.h:
+        (WebKit::toCopiedAPI): Create copied API for WebCore::SecurityOrigin
+        instances.
+        * Shared/WebSecurityOrigin.h:
+        (WebKit::WebSecurityOrigin::create): Add a new create() function that
+        takes a PassRefPtr to a WebCore SecurityOrigin instance.
+        (WebKit::WebSecurityOrigin::createFromString): Refactor to use new create()
+        function.
+        (WebKit::WebSecurityOrigin::createFromDatabaseIdentifier): Refactor to
+        use new create() function.
+        (WebKit::WebSecurityOrigin::create): Refactor to use new create()
+        function.
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
+        (WKBundleFrameCopySecurityOrigin): Add function to retrieve the security
+        origin as a WK2 API object.
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
+
 2012-11-02  Kenneth Rohde Christiansen  <[email protected]>
 
         [EFL] Unify transforms in WK2

Modified: trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h (133424 => 133425)


--- trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h	2012-11-04 17:27:45 UTC (rev 133424)
+++ trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h	2012-11-04 22:26:02 UTC (rev 133425)
@@ -39,6 +39,7 @@
 #include "WebEvent.h"
 #include "WebFindOptions.h"
 #include "WebNumber.h"
+#include "WebSecurityOrigin.h"
 #include "WebString.h"
 #include "WebURL.h"
 #include "WebURLRequest.h"
@@ -48,6 +49,7 @@
 #include <WebCore/FrameLoaderTypes.h>
 #include <WebCore/IntRect.h>
 #include <WebCore/LayoutMilestones.h>
+#include <WebCore/SecurityOrigin.h>
 #include <WebCore/UserContentTypes.h>
 #include <WebCore/UserScriptTypes.h>
 #include <wtf/TypeTraits.h>
@@ -197,6 +199,13 @@
     return ProxyingRefPtr<WebURLResponse>(WebURLResponse::create(response));
 }
 
+inline WKSecurityOriginRef toCopiedAPI(WebCore::SecurityOrigin* origin)
+{
+    if (!origin)
+        return 0;
+    return toAPI(WebSecurityOrigin::create(origin).leakRef());
+}
+
 /* Geometry conversions */
 
 inline WebCore::FloatRect toFloatRect(const WKRect& wkRect)

Modified: trunk/Source/WebKit2/Shared/WebSecurityOrigin.h (133424 => 133425)


--- trunk/Source/WebKit2/Shared/WebSecurityOrigin.h	2012-11-04 17:27:45 UTC (rev 133424)
+++ trunk/Source/WebKit2/Shared/WebSecurityOrigin.h	2012-11-04 22:26:02 UTC (rev 133425)
@@ -38,26 +38,24 @@
 
     static PassRefPtr<WebSecurityOrigin> createFromString(const String& string)
     {
-        RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::createFromString(string);
-        if (!securityOrigin)
-            return 0;
-        return adoptRef(new WebSecurityOrigin(securityOrigin.release()));
+        return create(WebCore::SecurityOrigin::createFromString(string));
     }
 
     static PassRefPtr<WebSecurityOrigin> createFromDatabaseIdentifier(const String& identifier)
     {
-        RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::createFromDatabaseIdentifier(identifier);
-        if (!securityOrigin)
-            return 0;
-        return adoptRef(new WebSecurityOrigin(securityOrigin.release()));
+        return create(WebCore::SecurityOrigin::createFromDatabaseIdentifier(identifier));
     }
 
     static PassRefPtr<WebSecurityOrigin> create(const String& protocol, const String& host, int port)
     {
-        RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::create(protocol, host, port);
+        return create(WebCore::SecurityOrigin::create(protocol, host, port));
+    }
+
+    static PassRefPtr<WebSecurityOrigin> create(PassRefPtr<WebCore::SecurityOrigin> securityOrigin)
+    {
         if (!securityOrigin)
             return 0;
-        return adoptRef(new WebSecurityOrigin(securityOrigin.release()));
+        return adoptRef(new WebSecurityOrigin(securityOrigin));
     }
 
     const String protocol() const { return m_securityOrigin->protocol(); }

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp (133424 => 133425)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp	2012-11-04 17:27:45 UTC (rev 133424)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp	2012-11-04 22:26:02 UTC (rev 133425)
@@ -32,6 +32,7 @@
 #include "WKBundleAPICast.h"
 #include "WKData.h"
 #include "WebFrame.h"
+#include "WebSecurityOrigin.h"
 #include <WebCore/Frame.h>
 #include <WebCore/FrameView.h>
 
@@ -286,3 +287,12 @@
 {
     return toAPI(toImpl(frameRef)->hitTest(toIntPoint(point)).leakRef());
 }
+
+WKSecurityOriginRef WKBundleFrameCopySecurityOrigin(WKBundleFrameRef frameRef)
+{
+    Frame* coreFrame = toImpl(frameRef)->coreFrame();
+    if (!coreFrame)
+        return 0;
+
+    return toCopiedAPI(coreFrame->document()->securityOrigin());
+}

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h (133424 => 133425)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h	2012-11-04 17:27:45 UTC (rev 133424)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h	2012-11-04 22:26:02 UTC (rev 133425)
@@ -44,6 +44,7 @@
 WK_EXPORT WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frame);
 WK_EXPORT WKURLRef WKBundleFrameCopyURL(WKBundleFrameRef frame);
 WK_EXPORT WKURLRef WKBundleFrameCopyProvisionalURL(WKBundleFrameRef frame);
+WK_EXPORT WKSecurityOriginRef WKBundleFrameCopySecurityOrigin(WKBundleFrameRef frame);
 
 WK_EXPORT WKFrameLoadState WKBundleFrameGetFrameLoadState(WKBundleFrameRef frame); 
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to