Add a basic configuration object for WKView
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Jan 2015 02:07:34 +0000 (02:07 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Jan 2015 02:07:34 +0000 (02:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140559

Reviewed by Anders Carlsson.

Source/WebKit2:

- Adds WKPageConfigurationRef (backed by API::PageConfiguration). WKWebView configuration
  is not yet bridged to this, but that will happen soon. For now, it has a few basic
  configuration options.
- Adds WKUserContentControllerRef as C-SPI version of WKUserContentController.
- Adds WKUserScriptRef as C-SPI version of WKUserScript.

* Shared/API/APIObject.h:
* Shared/API/c/WKBase.h:
* Shared/API/c/WKSharedAPICast.h:
(WebKit::toWKUserScriptInjectionTime):
* UIProcess/API/APIPageConfiguration.cpp: Added.
(API::PageConfiguration::PageConfiguration):
(API::PageConfiguration::~PageConfiguration):
(API::PageConfiguration::processPool):
(API::PageConfiguration::setProcessPool):
(API::PageConfiguration::userContentController):
(API::PageConfiguration::setUserContentController):
(API::PageConfiguration::pageGroup):
(API::PageConfiguration::setPageGroup):
(API::PageConfiguration::preferences):
(API::PageConfiguration::setPreferences):
(API::PageConfiguration::relatedPage):
(API::PageConfiguration::setRelatedPage):
(API::PageConfiguration::webPageConfiguration):
* UIProcess/API/APIPageConfiguration.h: Added.
(API::PageConfiguration::create):
* UIProcess/API/APIUserScript.cpp: Added.
(API::generateIdentifier):
(API::UserScript::generateUniqueURL):
* UIProcess/API/APIUserScript.h:
* UIProcess/API/C/WKAPICast.h:
* UIProcess/API/C/WKPageConfigurationRef.cpp: Added.
(WKPageConfigurationGetTypeID):
(WKPageConfigurationCreate):
(WKPageConfigurationGetContext):
(WKPageConfigurationSetContext):
(WKPageConfigurationGetPageGroup):
(WKPageConfigurationSetPageGroup):
(WKPageConfigurationGetUserContentController):
(WKPageConfigurationSetUserContentController):
(WKPageConfigurationGetPreferences):
(WKPageConfigurationSetPreferences):
(WKPageConfigurationGetRelatedPage):
(WKPageConfigurationSetRelatedPage):
* UIProcess/API/C/WKPageConfigurationRef.h: Added.
* UIProcess/API/C/WKUserContentControllerRef.cpp: Added.
(WKUserContentControllerGetTypeID):
(WKUserContentControllerCreate):
(WKUserContentControllerCopyUserScripts):
(WKUserContentControllerAddUserScript):
(WKUserContentControllerRemoveAllUserScripts):
* UIProcess/API/C/WKUserContentControllerRef.h: Added.
* UIProcess/API/C/WKUserScriptRef.cpp: Added.
(WKUserScriptGetTypeID):
(WKUserScriptCreateWithSource):
(WKUserScriptCopySource):
(WKUserScriptGetInjectionTime):
(WKUserScriptGetMainFrameOnly):
* UIProcess/API/C/WKUserScriptRef.h: Added.
* UIProcess/API/C/WebKit2_C.h:
* UIProcess/API/Cocoa/WKUserScript.mm:
(-[WKUserScript initWithSource:injectionTime:forMainFrameOnly:]):
(generateIdentifier): Deleted.
* UIProcess/API/Cocoa/WKViewPrivate.h:
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(LazyInitialized::get):
(LazyInitialized::set):
(LazyInitialized::peek):
* UIProcess/API/mac/WKView.mm:
(-[WKView initWithFrame:configurationRef:]):
* UIProcess/UserContent/WebUserContentControllerProxy.h:
(WebKit::WebUserContentControllerProxy::create):
* WebKit2.xcodeproj/project.pbxproj:

Tools:

Add tests for WKPageConfigurationRef.

* TestWebKitAPI/PlatformWebView.h:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/WKPageConfiguration.cpp: Added.
(TestWebKitAPI::TEST):
(TestWebKitAPI::didFinishLoadForFrame):
(TestWebKitAPI::setPageLoaderClient):
* TestWebKitAPI/mac/PlatformWebViewMac.mm:
(TestWebKitAPI::PlatformWebView::initialize):
(TestWebKitAPI::PlatformWebView::PlatformWebView):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178618 268f45cc-cd09-0410-ab3c-d52691b4dbfc

29 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/APIArray.cpp
Source/WebKit2/Shared/API/APIArray.h
Source/WebKit2/Shared/API/APIObject.h
Source/WebKit2/Shared/API/c/WKBase.h
Source/WebKit2/Shared/API/c/WKSharedAPICast.h
Source/WebKit2/UIProcess/API/APIPageConfiguration.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/APIPageConfiguration.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/APIUserScript.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/APIUserScript.h
Source/WebKit2/UIProcess/API/C/WKAPICast.h
Source/WebKit2/UIProcess/API/C/WKPageConfigurationRef.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKPageConfigurationRef.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKUserContentControllerRef.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKUserContentControllerRef.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKUserScriptRef.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKUserScriptRef.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WebKit2_C.h
Source/WebKit2/UIProcess/API/Cocoa/WKUserScript.mm
Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/TestWebKitAPI/PlatformWebView.h
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/WKPageConfiguration.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm

index f69fa0b..09c6b72 100644 (file)
@@ -1,3 +1,84 @@
+2015-01-16  Sam Weinig  <sam@webkit.org>
+
+        Add a basic configuration object for WKView
+        https://bugs.webkit.org/show_bug.cgi?id=140559
+
+        Reviewed by Anders Carlsson.
+
+        - Adds WKPageConfigurationRef (backed by API::PageConfiguration). WKWebView configuration
+          is not yet bridged to this, but that will happen soon. For now, it has a few basic
+          configuration options.
+        - Adds WKUserContentControllerRef as C-SPI version of WKUserContentController.
+        - Adds WKUserScriptRef as C-SPI version of WKUserScript.
+
+        * Shared/API/APIObject.h:
+        * Shared/API/c/WKBase.h:
+        * Shared/API/c/WKSharedAPICast.h:
+        (WebKit::toWKUserScriptInjectionTime):
+        * UIProcess/API/APIPageConfiguration.cpp: Added.
+        (API::PageConfiguration::PageConfiguration):
+        (API::PageConfiguration::~PageConfiguration):
+        (API::PageConfiguration::processPool):
+        (API::PageConfiguration::setProcessPool):
+        (API::PageConfiguration::userContentController):
+        (API::PageConfiguration::setUserContentController):
+        (API::PageConfiguration::pageGroup):
+        (API::PageConfiguration::setPageGroup):
+        (API::PageConfiguration::preferences):
+        (API::PageConfiguration::setPreferences):
+        (API::PageConfiguration::relatedPage):
+        (API::PageConfiguration::setRelatedPage):
+        (API::PageConfiguration::webPageConfiguration):
+        * UIProcess/API/APIPageConfiguration.h: Added.
+        (API::PageConfiguration::create):
+        * UIProcess/API/APIUserScript.cpp: Added.
+        (API::generateIdentifier):
+        (API::UserScript::generateUniqueURL):
+        * UIProcess/API/APIUserScript.h:
+        * UIProcess/API/C/WKAPICast.h:
+        * UIProcess/API/C/WKPageConfigurationRef.cpp: Added.
+        (WKPageConfigurationGetTypeID):
+        (WKPageConfigurationCreate):
+        (WKPageConfigurationGetContext):
+        (WKPageConfigurationSetContext):
+        (WKPageConfigurationGetPageGroup):
+        (WKPageConfigurationSetPageGroup):
+        (WKPageConfigurationGetUserContentController):
+        (WKPageConfigurationSetUserContentController):
+        (WKPageConfigurationGetPreferences):
+        (WKPageConfigurationSetPreferences):
+        (WKPageConfigurationGetRelatedPage):
+        (WKPageConfigurationSetRelatedPage):
+        * UIProcess/API/C/WKPageConfigurationRef.h: Added.
+        * UIProcess/API/C/WKUserContentControllerRef.cpp: Added.
+        (WKUserContentControllerGetTypeID):
+        (WKUserContentControllerCreate):
+        (WKUserContentControllerCopyUserScripts):
+        (WKUserContentControllerAddUserScript):
+        (WKUserContentControllerRemoveAllUserScripts):
+        * UIProcess/API/C/WKUserContentControllerRef.h: Added.
+        * UIProcess/API/C/WKUserScriptRef.cpp: Added.
+        (WKUserScriptGetTypeID):
+        (WKUserScriptCreateWithSource):
+        (WKUserScriptCopySource):
+        (WKUserScriptGetInjectionTime):
+        (WKUserScriptGetMainFrameOnly):
+        * UIProcess/API/C/WKUserScriptRef.h: Added.
+        * UIProcess/API/C/WebKit2_C.h:
+        * UIProcess/API/Cocoa/WKUserScript.mm:
+        (-[WKUserScript initWithSource:injectionTime:forMainFrameOnly:]):
+        (generateIdentifier): Deleted.
+        * UIProcess/API/Cocoa/WKViewPrivate.h:
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (LazyInitialized::get):
+        (LazyInitialized::set):
+        (LazyInitialized::peek):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView initWithFrame:configurationRef:]):
+        * UIProcess/UserContent/WebUserContentControllerProxy.h:
+        (WebKit::WebUserContentControllerProxy::create):
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2015-01-16  Anders Carlsson  <andersca@apple.com>
 
         Pass the connection along to WebProcessLifetimeTracker
index d37ae8e..bcb3ea9 100644 (file)
@@ -37,7 +37,7 @@ PassRefPtr<Array> Array::create()
 
 PassRefPtr<Array> Array::create(Vector<RefPtr<Object>> elements)
 {
-    return adoptRef(new Array(WTF::move(elements)));
+    return adoptRef(*new Array(WTF::move(elements)));
 }
 
 PassRefPtr<Array> Array::createStringArray(const Vector<WTF::String>& strings)
@@ -65,6 +65,19 @@ Vector<WTF::String> Array::toStringVector()
     return patternsVector;
 }
 
+Ref<API::Array> Array::copy()
+{
+    size_t size = this->size();
+    if (!size)
+        return *Array::create();
+
+    Vector<RefPtr<Object>> elements;
+    elements.reserveInitialCapacity(size);
+    for (const auto& entry : this->elements())
+        elements.uncheckedAppend(entry);
+    return *Array::create(elements);
+}
+
 Array::Array(Vector<RefPtr<Object>> elements)
     : m_elements(WTF::move(elements))
 {
index b6c373a..09d44d9 100644 (file)
@@ -55,6 +55,7 @@ public:
     static PassRefPtr<Array> create(Vector<RefPtr<Object>> elements);
     static PassRefPtr<Array> createStringArray(const Vector<WTF::String>&);
     Vector<WTF::String> toStringVector();
+    Ref<Array> copy();
 
     virtual ~Array();
 
@@ -82,6 +83,7 @@ public:
         );
     }
 
+
 private:
     explicit Array(Vector<RefPtr<Object>> elements);
 
index 0729ee1..bc4c078 100644 (file)
@@ -128,6 +128,7 @@ public:
         OpenPanelResultListener,
         OriginDataManager,
         Page,
+        PageConfiguration,
         PageGroup,
         ProcessPool,
         ProcessPoolConfiguration,
index 11ec548..c5e3d09 100644 (file)
@@ -120,6 +120,7 @@ typedef const struct OpaqueWKOpenPanelParameters* WKOpenPanelParametersRef;
 typedef const struct OpaqueWKOpenPanelResultListener* WKOpenPanelResultListenerRef;
 typedef const struct OpaqueWKOriginDataManager* WKOriginDataManagerRef;
 typedef const struct OpaqueWKPage* WKPageRef;
+typedef const struct OpaqueWKPageConfiguration* WKPageConfigurationRef;
 typedef const struct OpaqueWKPageGroup* WKPageGroupRef;
 typedef const struct OpaqueWKPluginSiteDataManager* WKPluginSiteDataManagerRef;
 typedef const struct OpaqueWKPreferences* WKPreferencesRef;
@@ -127,7 +128,9 @@ typedef const struct OpaqueWKProtectionSpace* WKProtectionSpaceRef;
 typedef const struct OpaqueWKTextChecker* WKTextCheckerRef;
 typedef const struct OpaqueWKSession* WKSessionRef;
 typedef const struct OpaqueWKSessionState* WKSessionStateRef;
+typedef const struct OpaqueWKUserContentController* WKUserContentControllerRef;
 typedef const struct OpaqueWKUserMediaPermissionRequest* WKUserMediaPermissionRequestRef;
+typedef const struct OpaqueWKUserScript* WKUserScriptRef;
 typedef const struct OpaqueWKVibration* WKVibrationRef;
 typedef const struct OpaqueWKViewportAttributes* WKViewportAttributesRef;
 
index 7bc9fa8..877c839 100644 (file)
@@ -973,6 +973,19 @@ inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(_WKUserScriptI
     return WebCore::InjectAtDocumentStart;
 }
 
+inline _WKUserScriptInjectionTime toWKUserScriptInjectionTime(WebCore::UserScriptInjectionTime injectedTime)
+{
+    switch (injectedTime) {
+    case WebCore::InjectAtDocumentStart:
+        return kWKInjectAtDocumentStart;
+    case WebCore::InjectAtDocumentEnd:
+        return kWKInjectAtDocumentEnd;
+    }
+
+    ASSERT_NOT_REACHED();
+    return kWKInjectAtDocumentStart;
+}
+
 inline WebCore::UserContentInjectedFrames toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames)
 {
     switch (wkInjectedFrames) {
diff --git a/Source/WebKit2/UIProcess/API/APIPageConfiguration.cpp b/Source/WebKit2/UIProcess/API/APIPageConfiguration.cpp
new file mode 100644 (file)
index 0000000..8e4f031
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "APIPageConfiguration.h"
+
+#include "APIProcessPoolConfiguration.h"
+#include "WebPageGroup.h"
+#include "WebPageProxy.h"
+#include "WebPreferences.h"
+#include "WebProcessPool.h"
+#include "WebUserContentControllerProxy.h"
+
+using namespace WebKit;
+
+namespace API {
+
+PageConfiguration::PageConfiguration()
+{
+}
+
+PageConfiguration::~PageConfiguration()
+{
+}
+
+WebProcessPool* PageConfiguration::processPool()
+{
+    return m_processPool.get();
+}
+
+void PageConfiguration::setProcessPool(WebProcessPool* processPool)
+{
+    m_processPool = processPool;
+}
+
+WebUserContentControllerProxy* PageConfiguration::userContentController()
+{
+    return m_userContentController.get();
+}
+
+void PageConfiguration::setUserContentController(WebUserContentControllerProxy* userContentController)
+{
+    m_userContentController = userContentController;
+}
+
+WebPageGroup* PageConfiguration::pageGroup()
+{
+    return m_pageGroup.get();
+}
+
+void PageConfiguration::setPageGroup(WebPageGroup* pageGroup)
+{
+    m_pageGroup = pageGroup;
+}
+
+WebPreferences* PageConfiguration::preferences()
+{
+    return m_preferences.get();
+}
+
+void PageConfiguration::setPreferences(WebPreferences* preferences)
+{
+    m_preferences = preferences;
+}
+
+WebPageProxy* PageConfiguration::relatedPage()
+{
+    return m_relatedPage.get();
+}
+
+void PageConfiguration::setRelatedPage(WebPageProxy* relatedPage)
+{
+    m_relatedPage = relatedPage;
+}
+
+WebKit::WebPageConfiguration PageConfiguration::webPageConfiguration()
+{
+    WebKit::WebPageConfiguration configuration;
+
+    configuration.userContentController = userContentController();
+    configuration.pageGroup = pageGroup();
+    configuration.preferences = preferences();
+    configuration.relatedPage = relatedPage();
+
+    return configuration;
+}
+
+} // namespace API
diff --git a/Source/WebKit2/UIProcess/API/APIPageConfiguration.h b/Source/WebKit2/UIProcess/API/APIPageConfiguration.h
new file mode 100644 (file)
index 0000000..2685375
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef APIPageConfiguration_h
+#define APIPageConfiguration_h
+
+#include "APIObject.h"
+#include <wtf/GetPtr.h>
+
+namespace WebKit {
+struct WebPageConfiguration;
+class WebUserContentControllerProxy;
+class WebProcessPool;
+class WebPageGroup;
+class WebPreferences;
+class WebPageProxy;
+}
+
+namespace API {
+
+class PageConfiguration : public ObjectImpl<Object::Type::PageConfiguration> {
+public:
+    static Ref<PageConfiguration> create()
+    {
+        return adoptRef(*new PageConfiguration);
+    }
+    virtual ~PageConfiguration();
+
+    // FIXME: The configuration properties should return their default values
+    // rather than nullptr.
+    
+    WebKit::WebProcessPool* processPool();
+    void setProcessPool(WebKit::WebProcessPool*);
+
+    WebKit::WebUserContentControllerProxy* userContentController();
+    void setUserContentController(WebKit::WebUserContentControllerProxy*);
+
+    WebKit::WebPageGroup* pageGroup();
+    void setPageGroup(WebKit::WebPageGroup*);
+
+    WebKit::WebPreferences* preferences();
+    void setPreferences(WebKit::WebPreferences*);
+
+    WebKit::WebPageProxy* relatedPage();
+    void setRelatedPage(WebKit::WebPageProxy*);
+
+    WebKit::WebPageConfiguration webPageConfiguration();
+
+private:
+    PageConfiguration();
+
+    RefPtr<WebKit::WebProcessPool> m_processPool;
+    RefPtr<WebKit::WebUserContentControllerProxy> m_userContentController;
+    RefPtr<WebKit::WebPageGroup> m_pageGroup;
+    RefPtr<WebKit::WebPreferences> m_preferences;
+    RefPtr<WebKit::WebPageProxy> m_relatedPage;
+};
+
+} // namespace API
+
+
+#endif // APIPageConfiguration_h
diff --git a/Source/WebKit2/UIProcess/API/APIUserScript.cpp b/Source/WebKit2/UIProcess/API/APIUserScript.cpp
new file mode 100644 (file)
index 0000000..c6894c5
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "APIUserScript.h"
+
+#include <wtf/text/StringBuilder.h>
+
+namespace API {
+
+static uint64_t generateIdentifier()
+{
+    static uint64_t identifier;
+
+    return ++identifier;
+}
+
+WebCore::URL UserScript::generateUniqueURL()
+{
+    StringBuilder urlStringBuilder;
+    urlStringBuilder.append("user-script:");
+    urlStringBuilder.appendNumber(generateIdentifier());
+    return WebCore::URL { WebCore::URL { }, urlStringBuilder.toString() };
+}
+
+
+} // namespace API
index 6ff2329..9766fed 100644 (file)
@@ -33,6 +33,13 @@ namespace API {
 
 class UserScript final : public ObjectImpl<Object::Type::UserScript> {
 public:
+    static WebCore::URL generateUniqueURL();
+
+    static RefPtr<UserScript> create(WebCore::UserScript userScript)
+    {
+        return adoptRef(new UserScript(userScript));
+    }
+
     UserScript(WebCore::UserScript userScript)
         : m_userScript(userScript)
     {
index 25b0a62..74aff96 100644 (file)
 
 namespace API {
 class NavigationData;
+class PageConfiguration;
 class ProcessPoolConfiguration;
 class SessionState;
+class UserScript;
 }
 
 namespace WebKit {
@@ -69,7 +71,6 @@ class WebBackForwardList;
 class WebBackForwardListItem;
 class WebBatteryManagerProxy;
 class WebBatteryStatus;
-class WebResourceCacheManagerProxy;
 class WebColorPickerResultListenerProxy;
 class WebCookieManagerProxy;
 class WebCredential;
@@ -86,8 +87,8 @@ class WebInspectorProxy;
 class WebKeyValueStorageManager;
 class WebMediaCacheManagerProxy;
 class WebNotification;
-class WebNotificationProvider;
 class WebNotificationManagerProxy;
+class WebNotificationProvider;
 class WebOpenPanelParameters;
 class WebOpenPanelResultListenerProxy;
 class WebOriginDataManagerProxy;
@@ -99,7 +100,9 @@ class WebProcessPool;
 class WebProtectionSpace;
 class WebRenderLayer;
 class WebRenderObject;
+class WebResourceCacheManagerProxy;
 class WebTextChecker;
+class WebUserContentControllerProxy;
 class WebVibrationProxy;
 class WebViewportAttributes;
 
@@ -139,6 +142,7 @@ WK_ADD_API_MAPPING(WKOpenPanelParametersRef, WebOpenPanelParameters)
 WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy)
 WK_ADD_API_MAPPING(WKOriginDataManagerRef, WebOriginDataManagerProxy)
 WK_ADD_API_MAPPING(WKPageGroupRef, WebPageGroup)
+WK_ADD_API_MAPPING(WKPageConfigurationRef, API::PageConfiguration)
 WK_ADD_API_MAPPING(WKPageRef, WebPageProxy)
 WK_ADD_API_MAPPING(WKPluginSiteDataManagerRef, WebPluginSiteDataManager)
 WK_ADD_API_MAPPING(WKPreferencesRef, WebPreferences)
@@ -147,7 +151,9 @@ WK_ADD_API_MAPPING(WKRenderLayerRef, WebRenderLayer)
 WK_ADD_API_MAPPING(WKRenderObjectRef, WebRenderObject)
 WK_ADD_API_MAPPING(WKSessionStateRef, API::SessionState)
 WK_ADD_API_MAPPING(WKTextCheckerRef, WebTextChecker)
+WK_ADD_API_MAPPING(WKUserContentControllerRef, WebUserContentControllerProxy)
 WK_ADD_API_MAPPING(WKUserMediaPermissionRequestRef, UserMediaPermissionRequestProxy)
+WK_ADD_API_MAPPING(WKUserScriptRef, API::UserScript)
 WK_ADD_API_MAPPING(WKVibrationRef, WebVibrationProxy)
 WK_ADD_API_MAPPING(WKViewportAttributesRef, WebViewportAttributes)
 WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy)
diff --git a/Source/WebKit2/UIProcess/API/C/WKPageConfigurationRef.cpp b/Source/WebKit2/UIProcess/API/C/WKPageConfigurationRef.cpp
new file mode 100644 (file)
index 0000000..4b9ada5
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WKPageConfigurationRef.h"
+
+#include "APIPageConfiguration.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKPageConfigurationGetTypeID()
+{
+    return toAPI(API::PageConfiguration::APIType);
+}
+
+WKPageConfigurationRef WKPageConfigurationCreate()
+{
+    return toAPI(&API::PageConfiguration::create().leakRef());
+}
+
+WKContextRef WKPageConfigurationGetContext(WKPageConfigurationRef configuration)
+{
+    return toAPI(toImpl(configuration)->processPool());
+}
+
+void WKPageConfigurationSetContext(WKPageConfigurationRef configuration, WKContextRef context)
+{
+    toImpl(configuration)->setProcessPool(toImpl(context));
+}
+
+WKPageGroupRef WKPageConfigurationGetPageGroup(WKPageConfigurationRef configuration)
+{
+    return toAPI(toImpl(configuration)->pageGroup());
+}
+
+void WKPageConfigurationSetPageGroup(WKPageConfigurationRef configuration, WKPageGroupRef pageGroup)
+{
+    toImpl(configuration)->setPageGroup(toImpl(pageGroup));
+}
+
+WKUserContentControllerRef WKPageConfigurationGetUserContentController(WKPageConfigurationRef configuration)
+{
+    return toAPI(toImpl(configuration)->userContentController());
+}
+
+void WKPageConfigurationSetUserContentController(WKPageConfigurationRef configuration, WKUserContentControllerRef userContentController)
+{
+    toImpl(configuration)->setUserContentController(toImpl(userContentController));
+}
+
+WKPreferencesRef WKPageConfigurationGetPreferences(WKPageConfigurationRef configuration)
+{
+    return toAPI(toImpl(configuration)->preferences());
+}
+
+void WKPageConfigurationSetPreferences(WKPageConfigurationRef configuration, WKPreferencesRef preferences)
+{
+    toImpl(configuration)->setPreferences(toImpl(preferences));
+}
+
+WKPageRef WKPageConfigurationGetRelatedPage(WKPageConfigurationRef configuration)
+{
+    return toAPI(toImpl(configuration)->relatedPage());
+}
+
+void WKPageConfigurationSetRelatedPage(WKPageConfigurationRef configuration, WKPageRef relatedPage)
+{
+    toImpl(configuration)->setRelatedPage(toImpl(relatedPage));
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKPageConfigurationRef.h b/Source/WebKit2/UIProcess/API/C/WKPageConfigurationRef.h
new file mode 100644 (file)
index 0000000..bf7be65
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WKPageConfigurationRef_h
+#define WKPageConfigurationRef_h
+
+#include <WebKit/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKPageConfigurationGetTypeID();
+
+WK_EXPORT WKPageConfigurationRef WKPageConfigurationCreate();
+
+WK_EXPORT WKContextRef WKPageConfigurationGetContext(WKPageConfigurationRef configuration);
+WK_EXPORT void WKPageConfigurationSetContext(WKPageConfigurationRef configuration, WKContextRef context);
+
+WK_EXPORT WKPageGroupRef WKPageConfigurationGetPageGroup(WKPageConfigurationRef configuration);
+WK_EXPORT void WKPageConfigurationSetPageGroup(WKPageConfigurationRef configuration, WKPageGroupRef pageGroup);
+
+WK_EXPORT WKUserContentControllerRef WKPageConfigurationGetUserContentController(WKPageConfigurationRef configuration);
+WK_EXPORT void WKPageConfigurationSetUserContentController(WKPageConfigurationRef configuration, WKUserContentControllerRef userContentController);
+
+WK_EXPORT WKPreferencesRef WKPageConfigurationGetPreferences(WKPageConfigurationRef configuration);
+WK_EXPORT void WKPageConfigurationSetPreferences(WKPageConfigurationRef configuration, WKPreferencesRef preferences);
+
+WK_EXPORT WKPageRef WKPageConfigurationGetRelatedPage(WKPageConfigurationRef configuration);
+WK_EXPORT void WKPageConfigurationSetRelatedPage(WKPageConfigurationRef configuration, WKPageRef relatedPage);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKPageConfigurationRef_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKUserContentControllerRef.cpp b/Source/WebKit2/UIProcess/API/C/WKUserContentControllerRef.cpp
new file mode 100644 (file)
index 0000000..1c240cb
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WKUserContentControllerRef.h"
+
+#include "WKAPICast.h"
+#include "WebUserContentControllerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKUserContentControllerGetTypeID()
+{
+    return toAPI(WebUserContentControllerProxy::APIType);
+}
+
+WKUserContentControllerRef WKUserContentControllerCreate()
+{
+    return toAPI(&WebUserContentControllerProxy::create().leakRef());
+}
+
+WKArrayRef WKUserContentControllerCopyUserScripts(WKUserContentControllerRef userContentControllerRef)
+{
+    Ref<API::Array> userScripts = toImpl(userContentControllerRef)->userScripts().copy();
+    return toAPI(&userScripts.leakRef());
+}
+
+void WKUserContentControllerAddUserScript(WKUserContentControllerRef userContentControllerRef, WKUserScriptRef userScriptRef)
+{
+    toImpl(userContentControllerRef)->addUserScript(*toImpl(userScriptRef));
+}
+
+void WKUserContentControllerRemoveAllUserScripts(WKUserContentControllerRef userContentControllerRef)
+{
+    toImpl(userContentControllerRef)->removeAllUserScripts();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKUserContentControllerRef.h b/Source/WebKit2/UIProcess/API/C/WKUserContentControllerRef.h
new file mode 100644 (file)
index 0000000..e72a098
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WKUserContentControllerRef_h
+#define WKUserContentControllerRef_h
+
+#include <WebKit/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKUserContentControllerGetTypeID();
+
+WK_EXPORT WKUserContentControllerRef WKUserContentControllerCreate();
+
+WK_EXPORT WKArrayRef WKUserContentControllerCopyUserScripts(WKUserContentControllerRef userContentController);
+WK_EXPORT void WKUserContentControllerAddUserScript(WKUserContentControllerRef userContentController, WKUserScriptRef userScript);
+WK_EXPORT void WKUserContentControllerRemoveAllUserScripts(WKUserContentControllerRef userContentController);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKUserContentControllerRef_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKUserScriptRef.cpp b/Source/WebKit2/UIProcess/API/C/WKUserScriptRef.cpp
new file mode 100644 (file)
index 0000000..f873ef0
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WKUserScriptRef.h"
+
+#include "APIUserScript.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKUserScriptGetTypeID()
+{
+    return toAPI(API::UserScript::APIType);
+}
+
+WKUserScriptRef WKUserScriptCreateWithSource(WKStringRef sourceRef, _WKUserScriptInjectionTime injectionTime, bool forMainFrameOnly)
+{
+    return toAPI(API::UserScript::create(WebCore::UserScript { toWTFString(sourceRef), API::UserScript::generateUniqueURL(), { }, { }, toUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames }).leakRef());
+}
+
+WKStringRef WKUserScriptCopySource(WKUserScriptRef userScriptRef)
+{
+    return toCopiedAPI(toImpl(userScriptRef)->userScript().source());
+}
+
+_WKUserScriptInjectionTime WKUserScriptGetInjectionTime(WKUserScriptRef userScriptRef)
+{
+    return toWKUserScriptInjectionTime(toImpl(userScriptRef)->userScript().injectionTime());
+}
+
+bool WKUserScriptGetMainFrameOnly(WKUserScriptRef userScriptRef)
+{
+    return toImpl(userScriptRef)->userScript().injectedFrames() == WebCore::InjectInTopFrameOnly;
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKUserScriptRef.h b/Source/WebKit2/UIProcess/API/C/WKUserScriptRef.h
new file mode 100644 (file)
index 0000000..610f9fb
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WKUserScriptRef_h
+#define WKUserScriptRef_h
+
+#include <WebKit/WKBase.h>
+#include <WebKit/WKUserScriptInjectionTime.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKUserScriptGetTypeID();
+
+WK_EXPORT WKUserScriptRef WKUserScriptCreateWithSource(WKStringRef source, _WKUserScriptInjectionTime injectionTime, bool forMainFrameOnly);
+
+WK_EXPORT WKStringRef WKUserScriptCopySource(WKUserScriptRef userScript);
+WK_EXPORT _WKUserScriptInjectionTime WKUserScriptGetInjectionTime(WKUserScriptRef userScript);
+WK_EXPORT bool WKUserScriptGetMainFrameOnly(WKUserScriptRef userScript);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKUserScriptRef_h */
index e32bacf..2e7aa3b 100644 (file)
 #include <WebKit/WKOpenPanelParameters.h>
 #include <WebKit/WKOpenPanelResultListener.h>
 #include <WebKit/WKPage.h>
+#include <WebKit/WKPageConfigurationRef.h>
 #include <WebKit/WKPageGroup.h>
 #include <WebKit/WKPreferencesRef.h>
 #include <WebKit/WKString.h>
 #include <WebKit/WKURL.h>
 #include <WebKit/WKURLRequest.h>
 #include <WebKit/WKURLResponse.h>
+#include <WebKit/WKUserContentControllerRef.h>
 #include <WebKit/WKUserMediaPermissionRequest.h>
+#include <WebKit/WKUserScriptRef.h>
 
 #if defined(__OBJC__) && __OBJC__
 #import <WebKit/WKView.h>
index 194bbcf..4c2716c 100644 (file)
 
 #if WK_API_ENABLED
 
-#import <wtf/text/StringBuilder.h>
-
 @implementation WKUserScript
 
-static uint64_t generateIdentifier()
-{
-    static uint64_t identifier;
-
-    return ++identifier;
-}
-
 - (instancetype)initWithSource:(NSString *)source injectionTime:(WKUserScriptInjectionTime)injectionTime forMainFrameOnly:(BOOL)forMainFrameOnly
 {
     if (!(self = [super init]))
         return nil;
 
-    StringBuilder urlStringBuilder;
-    urlStringBuilder.append("user-script:");
-    urlStringBuilder.appendNumber(generateIdentifier());
-    WebCore::URL url { WebCore::URL { }, urlStringBuilder.toString() };
-
-    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), url, { }, { }, API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames });
+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), { }, { }, API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames });
 
     return self;
 }
index 4df7cb6..49e6364 100644 (file)
@@ -40,6 +40,7 @@
 #else
 - (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef;
 - (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef relatedToPage:(WKPageRef)relatedPage;
+- (id)initWithFrame:(NSRect)frame configurationRef:(WKPageConfigurationRef)configuration;
 #endif
 
 #if TARGET_OS_IPHONE
index 5255037..7416662 100644 (file)
@@ -28,6 +28,7 @@
 
 #if WK_API_ENABLED
 
+#import "APIPageConfiguration.h"
 #import "WKPreferences.h"
 #import "WKProcessPool.h"
 #import "WKUserContentController.h"
 
 template<typename T> class LazyInitialized {
 public:
+    typedef typename WTF::GetPtrHelper<T>::PtrType PtrType;
+
     template<typename F>
-    T* get(F&& f)
+    PtrType get(F&& f)
     {
         if (!m_isInitialized) {
             m_value = f();
@@ -54,38 +57,38 @@ public:
         return m_value.get();
     }
 
-    void set(T* t)
+    void set(PtrType t)
     {
         m_value = t;
         m_isInitialized = true;
     }
 
-    void set(RetainPtr<T>&& t)
+    void set(T&& t)
     {
         m_value = WTF::move(t);
         m_isInitialized = true;
     }
 
-    T* peek()
+    PtrType peek()
     {
         return m_value.get();
     }
 
 private:
     bool m_isInitialized = false;
-    RetainPtr<T> m_value;
+    T m_value;
 };
 
 @implementation WKWebViewConfiguration {
-    LazyInitialized<WKProcessPool> _processPool;
-    LazyInitialized<WKPreferences> _preferences;
-    LazyInitialized<WKUserContentController> _userContentController;
-    LazyInitialized<_WKVisitedLinkProvider> _visitedLinkProvider;
-    LazyInitialized<_WKWebsiteDataStore> _websiteDataStore;
+    LazyInitialized<RetainPtr<WKProcessPool>> _processPool;
+    LazyInitialized<RetainPtr<WKPreferences>> _preferences;
+    LazyInitialized<RetainPtr<WKUserContentController>> _userContentController;
+    LazyInitialized<RetainPtr<_WKVisitedLinkProvider>> _visitedLinkProvider;
+    LazyInitialized<RetainPtr<_WKWebsiteDataStore>> _websiteDataStore;
     WebKit::WeakObjCPtr<WKWebView> _relatedWebView;
     WebKit::WeakObjCPtr<WKWebView> _alternateWebViewForNavigationGestures;
     RetainPtr<NSString> _groupIdentifier;
-    LazyInitialized<NSString> _applicationNameForUserAgent;
+    LazyInitialized<RetainPtr<NSString>> _applicationNameForUserAgent;
 
 #if PLATFORM(IOS)
     LazyInitialized<WKWebViewContentProviderRegistry> _contentProviderRegistry;
index 66671d9..7da345e 100644 (file)
@@ -34,6 +34,7 @@
 #endif
 
 #import "APILegacyContextHistoryClient.h"
+#import "APIPageConfiguration.h"
 #import "ActionMenuHitTestResult.h"
 #import "AttributedString.h"
 #import "ColorSpaceData.h"
@@ -3795,6 +3796,14 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path)
     return [self initWithFrame:frame processPool:*toImpl(contextRef) configuration:webPageConfiguration webView:nil];
 }
 
+- (id)initWithFrame:(NSRect)frame configurationRef:(WKPageConfigurationRef)configuration
+{
+    auto& processPool = *toImpl(configuration)->processPool();
+    auto webPageConfiguration = toImpl(configuration)->webPageConfiguration();
+
+    return [self initWithFrame:frame processPool:processPool configuration:webPageConfiguration webView:nil];
+}
+
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
 - (BOOL)wantsUpdateLayer
 {
index 6ab6aaa..332aec9 100644 (file)
@@ -57,6 +57,10 @@ class WebScriptMessageHandler;
 
 class WebUserContentControllerProxy : public API::ObjectImpl<API::Object::Type::UserContentController>, private IPC::MessageReceiver {
 public:
+    static Ref<WebUserContentControllerProxy> create()
+    { 
+        return adoptRef(*new WebUserContentControllerProxy);
+    } 
     explicit WebUserContentControllerProxy();
     ~WebUserContentControllerProxy();
 
index fcddeeb..8760403 100644 (file)
                7C85FD7F19341665000177C4 /* WebPreferencesKeys.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C85FD7D19341665000177C4 /* WebPreferencesKeys.cpp */; };
                7C85FD8019341665000177C4 /* WebPreferencesKeys.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C85FD7E19341665000177C4 /* WebPreferencesKeys.h */; };
                7C89D2941A67122F003A5FDE /* APIUserScript.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C89D2921A67122F003A5FDE /* APIUserScript.h */; };
+               7C89D2971A6753B2003A5FDE /* APIPageConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C89D2951A6753B2003A5FDE /* APIPageConfiguration.cpp */; };
+               7C89D2981A6753B2003A5FDE /* APIPageConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C89D2961A6753B2003A5FDE /* APIPageConfiguration.h */; };
+               7C89D29B1A67837B003A5FDE /* WKPageConfigurationRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C89D2991A67837B003A5FDE /* WKPageConfigurationRef.cpp */; };
+               7C89D29C1A67837B003A5FDE /* WKPageConfigurationRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C89D29A1A67837B003A5FDE /* WKPageConfigurationRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7C89D29F1A678554003A5FDE /* WKUserContentControllerRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C89D29D1A678554003A5FDE /* WKUserContentControllerRef.cpp */; };
+               7C89D2A01A678554003A5FDE /* WKUserContentControllerRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C89D29E1A678554003A5FDE /* WKUserContentControllerRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7C89D2A31A678875003A5FDE /* WKUserScriptRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C89D2A11A678875003A5FDE /* WKUserScriptRef.cpp */; };
+               7C89D2A41A678875003A5FDE /* WKUserScriptRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C89D2A21A678875003A5FDE /* WKUserScriptRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7C89D2A61A6789EA003A5FDE /* APIUserScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C89D2A51A6789EA003A5FDE /* APIUserScript.cpp */; };
                7C8EB11718DB6A19007917C2 /* WKPreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C8EB11618DB6A19007917C2 /* WKPreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C9D1537184584DA009D3918 /* WKBrowsingContextGroupInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9D1536184584DA009D3918 /* WKBrowsingContextGroupInternal.h */; };
                7CA254EB182993CE00FC8A41 /* WKBrowsingContextPolicyDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CA254EA182993CE00FC8A41 /* WKBrowsingContextPolicyDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C85FD7D19341665000177C4 /* WebPreferencesKeys.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPreferencesKeys.cpp; sourceTree = "<group>"; };
                7C85FD7E19341665000177C4 /* WebPreferencesKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPreferencesKeys.h; sourceTree = "<group>"; };
                7C89D2921A67122F003A5FDE /* APIUserScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIUserScript.h; sourceTree = "<group>"; };
+               7C89D2951A6753B2003A5FDE /* APIPageConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIPageConfiguration.cpp; sourceTree = "<group>"; };
+               7C89D2961A6753B2003A5FDE /* APIPageConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIPageConfiguration.h; sourceTree = "<group>"; };
+               7C89D2991A67837B003A5FDE /* WKPageConfigurationRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKPageConfigurationRef.cpp; sourceTree = "<group>"; };
+               7C89D29A1A67837B003A5FDE /* WKPageConfigurationRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageConfigurationRef.h; sourceTree = "<group>"; };
+               7C89D29D1A678554003A5FDE /* WKUserContentControllerRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKUserContentControllerRef.cpp; sourceTree = "<group>"; };
+               7C89D29E1A678554003A5FDE /* WKUserContentControllerRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserContentControllerRef.h; sourceTree = "<group>"; };
+               7C89D2A11A678875003A5FDE /* WKUserScriptRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKUserScriptRef.cpp; sourceTree = "<group>"; };
+               7C89D2A21A678875003A5FDE /* WKUserScriptRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserScriptRef.h; sourceTree = "<group>"; };
+               7C89D2A51A6789EA003A5FDE /* APIUserScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIUserScript.cpp; sourceTree = "<group>"; };
                7C8EB11618DB6A19007917C2 /* WKPreferencesPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPreferencesPrivate.h; sourceTree = "<group>"; };
                7C9D1536184584DA009D3918 /* WKBrowsingContextGroupInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextGroupInternal.h; sourceTree = "<group>"; };
                7CA254EA182993CE00FC8A41 /* WKBrowsingContextPolicyDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextPolicyDelegate.h; sourceTree = "<group>"; };
                                7CD3A4811A5D02FA009623B8 /* APINavigation.h */,
                                BCF69FA11176D01400471A52 /* APINavigationData.cpp */,
                                BCF69FA01176D01400471A52 /* APINavigationData.h */,
+                               7C89D2951A6753B2003A5FDE /* APIPageConfiguration.cpp */,
+                               7C89D2961A6753B2003A5FDE /* APIPageConfiguration.h */,
                                1AFDD3141891B54000153970 /* APIPolicyClient.h */,
                                7CE4D21D1A4914CA00C7F152 /* APIProcessPoolConfiguration.cpp */,
                                7CE4D21E1A4914CA00C7F152 /* APIProcessPoolConfiguration.h */,
                                1AFDE65F1954E9B100C48FFA /* APISessionState.cpp */,
                                1AFDE6601954E9B100C48FFA /* APISessionState.h */,
                                1A4D664718A2D91A00D82E21 /* APIUIClient.h */,
+                               7C89D2A51A6789EA003A5FDE /* APIUserScript.cpp */,
                                7C89D2921A67122F003A5FDE /* APIUserScript.h */,
                                1A3635A71A3144A300ED6197 /* APIWebsiteDataStore.cpp */,
                                1A3635A81A3144A300ED6197 /* APIWebsiteDataStore.h */,
                                755422BA18062B9C0046F6A8 /* WKOriginDataManager.h */,
                                BCD597D4112B56DC00EC8C23 /* WKPage.cpp */,
                                BCD597D5112B56DC00EC8C23 /* WKPage.h */,
+                               7C89D2991A67837B003A5FDE /* WKPageConfigurationRef.cpp */,
+                               7C89D29A1A67837B003A5FDE /* WKPageConfigurationRef.h */,
                                1AB8A1F718400BB800E9AE69 /* WKPageContextMenuClient.h */,
                                8372DB241A674C8F00C697C5 /* WKPageDiagnosticLoggingClient.h */,
                                1AB8A1F318400B8F00E9AE69 /* WKPageFindClient.h */,
                                1ADE46B11954EC61000F7985 /* WKSessionStateRef.h */,
                                4A410F3519AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.cpp */,
                                4A410F3619AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.h */,
+                               7C89D29D1A678554003A5FDE /* WKUserContentControllerRef.cpp */,
+                               7C89D29E1A678554003A5FDE /* WKUserContentControllerRef.h */,
+                               7C89D2A11A678875003A5FDE /* WKUserScriptRef.cpp */,
+                               7C89D2A21A678875003A5FDE /* WKUserScriptRef.h */,
                        );
                        path = C;
                        sourceTree = "<group>";
                                BC204EEF11C83EC8008F3375 /* WKBundle.h in Headers */,
                                BC204EF011C83EC8008F3375 /* WKBundleAPICast.h in Headers */,
                                935EEB9F127761AC003322B8 /* WKBundleBackForwardList.h in Headers */,
+                               7C89D2A41A678875003A5FDE /* WKUserScriptRef.h in Headers */,
                                935EEB9B1277617C003322B8 /* WKBundleBackForwardListItem.h in Headers */,
                                51EFC1CF1524E62500C9A938 /* WKBundleDOMWindowExtension.h in Headers */,
                                BCD25F1711D6BDE100169B0E /* WKBundleFrame.h in Headers */,
                                1AB474D8184D43FD0051B622 /* WKBundlePageLoaderClient.h in Headers */,
                                ED82A7F2128C6FAF004477B3 /* WKBundlePageOverlay.h in Headers */,
                                1AB474EA184D45130051B622 /* WKBundlePagePolicyClient.h in Headers */,
+                               7C89D29C1A67837B003A5FDE /* WKPageConfigurationRef.h in Headers */,
                                BC1B419811D41D570011E8DD /* WKBundlePagePrivate.h in Headers */,
                                1AB474DA184D44250051B622 /* WKBundlePageResourceLoadClient.h in Headers */,
                                1AB474DE184D44590051B622 /* WKBundlePageUIClient.h in Headers */,
                                BC017D0B16260FF4007054F5 /* WKDOMInternals.h in Headers */,
                                BC017D0D16260FF4007054F5 /* WKDOMNode.h in Headers */,
                                BC5D24C216CD706D007D5461 /* WKDOMNodePrivate.h in Headers */,
+                               7C89D2981A6753B2003A5FDE /* APIPageConfiguration.h in Headers */,
                                BC39C4361626366F008BC689 /* WKDOMRange.h in Headers */,
                                BC5D24C516CD7088007D5461 /* WKDOMRangePrivate.h in Headers */,
                                293EBEAB1627D9C9005F89F1 /* WKDOMText.h in Headers */,
                                1A9E329F1822FEDD00F5D04C /* WKRemoteObjectCoder.h in Headers */,
                                37948409150C4B9700E52CE9 /* WKRenderLayer.h in Headers */,
                                37608823150414F700FC82C7 /* WKRenderObject.h in Headers */,
+                               7C89D2A01A678554003A5FDE /* WKUserContentControllerRef.h in Headers */,
                                3336763B130C99DC006C9DE2 /* WKResourceCacheManager.h in Headers */,
                                BC8A501511765F5600757573 /* WKRetainPtr.h in Headers */,
                                1A7E377918E4A4FE003D0FFF /* WKScriptMessage.h in Headers */,
                                1AFDE65D1954E8D500C48FFA /* LegacySessionStateCoding.cpp in Sources */,
                                1A1D8BA11731A36300141DA4 /* LocalStorageDatabase.cpp in Sources */,
                                1A8C728C1738477C000A6554 /* LocalStorageDatabaseTracker.cpp in Sources */,
+                               7C89D29B1A67837B003A5FDE /* WKPageConfigurationRef.cpp in Sources */,
                                51A7F2F5125BF8D4008AEB1D /* Logging.cpp in Sources */,
                                5160BFE113381DF900918999 /* LoggingFoundation.mm in Sources */,
                                1A24B5F211F531E800C38269 /* MachUtilities.cpp in Sources */,
                                51A9E1051315CCFC009E7031 /* WebKeyValueStorageManager.cpp in Sources */,
                                1A6280F31919982A006AD9F9 /* WebKit.m in Sources */,
                                BC9BA5041697C45300E44616 /* WebKit2Initialize.cpp in Sources */,
+                               7C89D29F1A678554003A5FDE /* WKUserContentControllerRef.cpp in Sources */,
                                33D3A3C1133960B000709BE4 /* WebMediaCacheManager.cpp in Sources */,
                                33D3A3C81339617900709BE4 /* WebMediaCacheManagerMessageReceiver.cpp in Sources */,
                                33D3A3BA1339606200709BE4 /* WebMediaCacheManagerProxy.cpp in Sources */,
                                1AF4592E19464B2000F9D4A2 /* WKError.mm in Sources */,
                                BCFD548B132D82680055D816 /* WKErrorCF.cpp in Sources */,
                                BC4075FB124FF0270068F20A /* WKErrorRef.cpp in Sources */,
+                               7C89D2A31A678875003A5FDE /* WKUserScriptRef.cpp in Sources */,
                                A58B6F0918FCA733008CBA53 /* WKFileUploadPanel.mm in Sources */,
+                               7C89D2971A6753B2003A5FDE /* APIPageConfiguration.cpp in Sources */,
                                C54256B618BEC18C00DE4179 /* WKFormInputControl.mm in Sources */,
                                C54256B918BEC18C00DE4179 /* WKFormPopover.mm in Sources */,
                                C57193BE18C14A44002D0F12 /* WKFormSelectControl.mm in Sources */,
                                1A158419189044F50017616C /* WKProcessPool.mm in Sources */,
                                512F58FB12A88A5400629530 /* WKProtectionSpace.cpp in Sources */,
                                1AD01BCC1905D54900C9C45F /* WKReloadFrameErrorRecoveryAttempter.mm in Sources */,
+                               7C89D2A61A6789EA003A5FDE /* APIUserScript.cpp in Sources */,
                                1A9E329A1822E1CC00F5D04C /* WKRemoteObject.mm in Sources */,
                                1AFA4B8B1A65A1D0006C4AB4 /* WebProcessLifetimeTracker.cpp in Sources */,
                                1A9E329E1822FEDD00F5D04C /* WKRemoteObjectCoder.mm in Sources */,
index d9dd804..eb00e1a 100644 (file)
@@ -1,3 +1,22 @@
+2015-01-16  Sam Weinig  <sam@webkit.org>
+
+        Add a basic configuration object for WKView
+        https://bugs.webkit.org/show_bug.cgi?id=140559
+
+        Reviewed by Anders Carlsson.
+
+        Add tests for WKPageConfigurationRef.
+
+        * TestWebKitAPI/PlatformWebView.h:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/WKPageConfiguration.cpp: Added.
+        (TestWebKitAPI::TEST):
+        (TestWebKitAPI::didFinishLoadForFrame):
+        (TestWebKitAPI::setPageLoaderClient):
+        * TestWebKitAPI/mac/PlatformWebViewMac.mm:
+        (TestWebKitAPI::PlatformWebView::initialize):
+        (TestWebKitAPI::PlatformWebView::PlatformWebView):
+
 2015-01-16  Myles C. Maxfield  <mmaxfield@apple.com>
 
         WeakPtr functions crash when created with default constructor
index eda247d..1f65814 100644 (file)
@@ -56,6 +56,7 @@ namespace TestWebKitAPI {
 
 class PlatformWebView {
 public:
+    explicit PlatformWebView(WKPageConfigurationRef);
     explicit PlatformWebView(WKContextRef, WKPageGroupRef = 0);
     explicit PlatformWebView(WKPageRef relatedPage);
 #if PLATFORM(MAC)
@@ -74,6 +75,10 @@ public:
     void simulateMouseMove(unsigned x, unsigned y);
 
 private:
+#if PLATFORM(MAC)
+    void initialize(WKPageConfigurationRef, Class wkViewSubclass);
+#endif
+
     PlatformWKView m_view;
     PlatformWindow m_window;
 };
index 700122a..9a8080c 100644 (file)
@@ -55,6 +55,7 @@
                7673499D1930C5BB00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7673499A1930182E00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp */; };
                76E182DD1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76E182DC1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp */; };
                76E182DF154767E600F1FADD /* auto-submitting-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 76E182DE15475A8300F1FADD /* auto-submitting-form.html */; };
+               7C89D2AC1A69B80D003A5FDE /* WKPageConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C89D2AA1A69B80D003A5FDE /* WKPageConfiguration.cpp */; };
                7C9ED98B17A19F4B00E4DC33 /* attributedStringStrikethrough.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7C9ED98A17A19D0600E4DC33 /* attributedStringStrikethrough.html */; };
                7CCE7EA41A4119F300447C4C /* InstanceMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = C08587FF13FEC3A6001EF4E5 /* InstanceMethodSwizzler.mm */; };
                7CCE7EA51A411A0800447C4C /* JavaScriptTestMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C081224013FC172400DC39AE /* JavaScriptTestMac.mm */; };
                7C6BBD8A19CEA54300C1F5E0 /* Counters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Counters.h; sourceTree = "<group>"; };
                7C6BBD8B19CEA63000C1F5E0 /* Counters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Counters.cpp; sourceTree = "<group>"; };
                7C74D42D188228F300E5ED57 /* StringView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringView.cpp; sourceTree = "<group>"; };
+               7C89D2AA1A69B80D003A5FDE /* WKPageConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKPageConfiguration.cpp; sourceTree = "<group>"; };
                7C8DDAA91735DE1D00EA5AC0 /* CloseThenTerminate.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CloseThenTerminate.cpp; sourceTree = "<group>"; };
                7C9ED98A17A19D0600E4DC33 /* attributedStringStrikethrough.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = attributedStringStrikethrough.html; sourceTree = "<group>"; };
                7CBBA07619BB8A9100BBF025 /* OSObjectPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSObjectPtr.cpp; sourceTree = "<group>"; };
                                76E182D91547550100F1FADD /* WillSendSubmitEvent.cpp */,
                                76E182DC1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp */,
                                A1FDFD2E19C288BB005148A4 /* WKImageCreateCGImageCrash.cpp */,
+                               7C89D2AA1A69B80D003A5FDE /* WKPageConfiguration.cpp */,
                                51E93016156B13E1004C99DF /* WKPageGetScaleFactorNotZero.cpp */,
                                524BBC9C19DF377A002F1AF1 /* WKPageIsPlayingAudio.cpp */,
                                BC7B619A1299FE9E00D174A4 /* WKPreferences.cpp */,
                                7CCE7EFF1A411AE600447C4C /* LoadCanceledNoServerRedirectCallback.cpp in Sources */,
                                7CCE7F001A411AE600447C4C /* LoadPageOnCrash.cpp in Sources */,
                                7CCE7F3A1A411B8E00447C4C /* MathExtras.cpp in Sources */,
+                               7C89D2AC1A69B80D003A5FDE /* WKPageConfiguration.cpp in Sources */,
                                7CCE7F391A411B8E00447C4C /* MD5.cpp in Sources */,
                                7CCE7F3B1A411B8E00447C4C /* MediaTime.cpp in Sources */,
                                7CCE7EB21A411A5100447C4C /* MemoryCacheAddImageToCacheIOS.mm in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/WKPageConfiguration.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/WKPageConfiguration.cpp
new file mode 100644 (file)
index 0000000..b5b8509
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+
+namespace TestWebKitAPI {
+
+TEST(WebKit2, WKPageConfigurationEmpty)
+{
+    WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
+
+    ASSERT_NULL(WKPageConfigurationGetContext(configuration.get()));
+    ASSERT_NULL(WKPageConfigurationGetUserContentController(configuration.get()));
+    ASSERT_NULL(WKPageConfigurationGetPageGroup(configuration.get()));
+    ASSERT_NULL(WKPageConfigurationGetPreferences(configuration.get()));
+    ASSERT_NULL(WKPageConfigurationGetRelatedPage(configuration.get()));
+}
+
+static bool didFinishLoad;
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
+{
+    didFinishLoad = true;
+}
+
+static void setPageLoaderClient(WKPageRef page)
+{
+    WKPageLoaderClientV0 loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+
+    loaderClient.base.version = 0;
+    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+
+    WKPageSetPageLoaderClient(page, &loaderClient.base);
+}
+
+TEST(WebKit2, WKPageConfigurationBasic)
+{
+    WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
+    WKRetainPtr<WKContextRef> context = adoptWK(WKContextCreate());
+    WKPageConfigurationSetContext(configuration.get(), context.get());
+    
+    PlatformWebView webView(configuration.get());
+    setPageLoaderClient(webView.page());
+
+    WKRetainPtr<WKURLRef> url = adoptWK(Util::createURLForResource("simple", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+
+    Util::run(&didFinishLoad);
+}
+
+} // namespace TestWebKitAPI
+
+#endif
index b6586dd..0bcbb14 100644 (file)
@@ -26,8 +26,9 @@
 #import "config.h"
 #import "PlatformWebView.h"
 
-#import <WebKit/WKViewPrivate.h>
 #import <Carbon/Carbon.h>
+#import <WebKit/WKRetainPtr.h>
+#import <WebKit/WKViewPrivate.h>
 
 @interface ActiveOffscreenWindow : NSWindow
 @end
 
 namespace TestWebKitAPI {
 
-PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
-    : PlatformWebView(contextRef, pageGroupRef, [WKView class])
-{
-}
-
-PlatformWebView::PlatformWebView(WKPageRef relatedPage)
+void PlatformWebView::initialize(WKPageConfigurationRef configuration, Class wkViewSubclass)
 {
     NSRect rect = NSMakeRect(0, 0, 800, 600);
-    m_view = [[WKView alloc] initWithFrame:rect contextRef:WKPageGetContext(relatedPage) pageGroupRef:WKPageGetPageGroup(relatedPage) relatedToPage:relatedPage];
+    m_view = [[wkViewSubclass alloc] initWithFrame:rect configurationRef:configuration];
     [m_view setWindowOcclusionDetectionEnabled:NO];
 
     NSRect windowRect = NSOffsetRect(rect, -10000, [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
@@ -65,19 +61,40 @@ PlatformWebView::PlatformWebView(WKPageRef relatedPage)
     [m_window setReleasedWhenClosed:NO];
 }
 
-PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, Class wkViewSubclass)
+PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration)
 {
-    NSRect rect = NSMakeRect(0, 0, 800, 600);
-    m_view = [[wkViewSubclass alloc] initWithFrame:rect contextRef:contextRef pageGroupRef:pageGroupRef];
-    [m_view setWindowOcclusionDetectionEnabled:NO];
+    initialize(configuration, [WKView class]);
+}
 
-    NSRect windowRect = NSOffsetRect(rect, -10000, [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
-    m_window = [[ActiveOffscreenWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
-    [m_window setColorSpace:[[NSScreen mainScreen] colorSpace]];
-    [[m_window contentView] addSubview:m_view];
-    [m_window orderBack:nil];
-    [m_window setAutodisplay:NO];
-    [m_window setReleasedWhenClosed:NO];
+PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+{
+    WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
+    
+    WKPageConfigurationSetContext(configuration.get(), contextRef);
+    WKPageConfigurationSetPageGroup(configuration.get(), pageGroupRef);
+    
+    initialize(configuration.get(), [WKView class]);
+}
+
+PlatformWebView::PlatformWebView(WKPageRef relatedPage)
+{
+    WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
+    
+    WKPageConfigurationSetContext(configuration.get(), WKPageGetContext(relatedPage));
+    WKPageConfigurationSetPageGroup(configuration.get(), WKPageGetPageGroup(relatedPage));
+    WKPageConfigurationSetRelatedPage(configuration.get(), relatedPage);
+
+    initialize(configuration.get(), [WKView class]);
+}
+
+PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, Class wkViewSubclass)
+{
+    WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
+    
+    WKPageConfigurationSetContext(configuration.get(), contextRef);
+    WKPageConfigurationSetPageGroup(configuration.get(), pageGroupRef);
+    
+    initialize(configuration.get(), wkViewSubclass);
 }
 
 PlatformWebView::~PlatformWebView()