diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-20 21:53:03 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-20 21:53:03 +0200 |
commit | 171053e5e2efcdc6854d8b3a0d06934fb309e53d (patch) | |
tree | c85f2b00cea9c5b648ad9945be3155d29d96395f /Source/WebKit2/UIProcess | |
parent | 0b3dc81d9701aea106543b49bde511a5697cdd6e (diff) | |
download | qtwebkit-171053e5e2efcdc6854d8b3a0d06934fb309e53d.tar.gz |
Imported WebKit commit f35955d976484e57fd83612794aefd58fdaa6337 (http://svn.webkit.org/repository/webkit/trunk@129155)
New snapshot with prospective build fix
Diffstat (limited to 'Source/WebKit2/UIProcess')
11 files changed, 205 insertions, 17 deletions
diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index 100633962..ef2ce603f 100644 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -285,10 +285,7 @@ void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, Fin void PageClientImpl::handleDownloadRequest(DownloadProxy* download) { Ewk_Download_Job* ewkDownload = ewk_download_job_new(download, m_viewWidget); - // For now we only support one default context, but once we support - // multiple contexts, we will need to retrieve the context from the - // view. - ewk_context_download_job_add(ewk_context_default_get(), ewkDownload); + ewk_context_download_job_add(ewk_view_context_get(m_viewWidget), ewkDownload); ewk_download_job_unref(ewkDownload); } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp index e23f6b005..b34ff77df 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp @@ -28,15 +28,18 @@ #include "WKNumber.h" #include "WKRetainPtr.h" #include "WKString.h" +#include "WebContext.h" #include "ewk_context_download_client_private.h" #include "ewk_context_private.h" #include "ewk_context_request_manager_client_private.h" #include "ewk_cookie_manager_private.h" #include "ewk_download_job.h" #include "ewk_download_job_private.h" +#include <WebCore/FileSystem.h> #include <wtf/HashMap.h> #include <wtf/text/WTFString.h> +using namespace WebCore; using namespace WebKit; struct _Ewk_Url_Scheme_Handler { @@ -57,6 +60,7 @@ struct _Ewk_Url_Scheme_Handler { typedef HashMap<String, _Ewk_Url_Scheme_Handler> URLSchemeHandlerMap; struct _Ewk_Context { + unsigned __ref; /**< the reference count of the object */ WKRetainPtr<WKContextRef> context; Ewk_Cookie_Manager* cookieManager; @@ -72,7 +76,8 @@ struct _Ewk_Context { URLSchemeHandlerMap urlSchemeHandlers; _Ewk_Context(WKRetainPtr<WKContextRef> contextRef) - : context(contextRef) + : __ref(1) + , context(contextRef) , cookieManager(0) , requestManager(WKContextGetSoupRequestManager(contextRef.get())) { @@ -112,6 +117,25 @@ struct _Ewk_Context { } }; +Ewk_Context* ewk_context_ref(Ewk_Context* ewkContext) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0); + ++ewkContext->__ref; + + return ewkContext; +} + +void ewk_context_unref(Ewk_Context* ewkContext) +{ + EINA_SAFETY_ON_NULL_RETURN(ewkContext); + EINA_SAFETY_ON_FALSE_RETURN(ewkContext->__ref > 0); + + if (--ewkContext->__ref) + return; + + delete ewkContext; +} + Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext) { EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0); @@ -215,6 +239,22 @@ Ewk_Context* ewk_context_default_get() return &defaultContext; } +Ewk_Context* ewk_context_new() +{ + return new Ewk_Context(adoptWK(WKContextCreate())); +} + +Ewk_Context* ewk_context_new_with_injected_bundle_path(const char* path) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(path, 0); + + WKRetainPtr<WKStringRef> pathRef(AdoptWK, WKStringCreateWithUTF8CString(path)); + if (!fileExists(toImpl(pathRef.get())->string())) + return 0; + + return new Ewk_Context(adoptWK(WKContextCreateWithInjectedBundlePath(pathRef.get()))); +} + Eina_Bool ewk_context_uri_scheme_register(Ewk_Context* ewkContext, const char* scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData) { EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.h b/Source/WebKit2/UIProcess/API/efl/ewk_context.h index 5e4d34262..e6e9e0c7b 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.h @@ -22,8 +22,16 @@ * @brief Describes the context API. * * @note ewk_context encapsulates all pages related to specific use of WebKit. - * All pages in this context share the same visited link set, - * local storage set, and preferences. + * + * Applications have the option of creating a context different than the default one + * and use it for a group of pages. All pages in the same context share the same + * preferences, visited link set, local storage, etc. + * + * A process model can be specified per context. The default one is the shared model + * where the web-engine process is shared among the pages in the context. The second + * model allows each page to use a separate web-engine process. This latter model is + * currently not supported by WebKit2/EFL. + * */ #ifndef ewk_context_h @@ -61,11 +69,58 @@ typedef void (*Ewk_Vibration_Client_Vibrate_Cb)(uint64_t vibration_time, void *u typedef void (*Ewk_Vibration_Client_Vibration_Cancel_Cb)(void *user_data); /** + * Increases the reference count of the given object. + * + * @param context context object to increase the reference count + * + * @return Ewk_Context object on success or @c NULL on failure + */ +EAPI Ewk_Context *ewk_context_ref(Ewk_Context *context); + +/** + * Decreases the reference count of the given object, possibly freeing it. + * + * When the reference count it's reached 0, the Ewk_Context is freed. + * + * @param context context object to decrease the reference count + */ +EAPI void ewk_context_unref(Ewk_Context *context); + +/** * Gets default Ewk_Context instance. * + * The returned Ewk_Context object @b should not be unref'ed if application + * does not call ewk_context_ref() for that. + * * @return Ewk_Context object. */ -EAPI Ewk_Context *ewk_context_default_get(); +EAPI Ewk_Context *ewk_context_default_get(void); + +/** + * Creates a new Ewk_Context. + * + * The returned Ewk_Context object @b should be unref'ed after use. + * + * @return Ewk_Context object on success or @c NULL on failure + * + * @see ewk_context_unref + * @see ewk_context_new_with_injected_bundle_path + */ +EAPI Ewk_Context *ewk_context_new(void); + +/** + * Creates a new Ewk_Context. + * + * The returned Ewk_Context object @b should be unref'ed after use. + * + * @param path path of injected bundle library + * + * @return Ewk_Context object on success or @c NULL on failure + * + * @see ewk_context_unref + * @see ewk_context_new + */ +EAPI Ewk_Context *ewk_context_new_with_injected_bundle_path(const char *path); /** * Gets the cookie manager instance for this @a context. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index bbbfc18c1..0eab8b540 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -100,6 +100,7 @@ struct _Ewk_View_Private_Data { OwnPtr<Ewk_Settings> settings; bool areMouseEventsEnabled; WKColorPickerResultListenerRef colorPickerResultListener; + Ewk_Context* context; WebPopupMenuProxyEfl* popupMenuProxy; Eina_List* popupMenuItems; @@ -119,6 +120,7 @@ struct _Ewk_View_Private_Data { , backForwardList(0) , areMouseEventsEnabled(false) , colorPickerResultListener(0) + , context(0) , popupMenuProxy(0) , popupMenuItems(0) #ifdef HAVE_ECORE_X @@ -384,6 +386,7 @@ static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingR static void _ewk_view_priv_del(Ewk_View_Private_Data* priv) { + ewk_context_unref(priv->context); delete priv; } @@ -714,6 +717,7 @@ static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKP priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageProxy->backForwardList())); priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get()))))); + priv->context = ewk_context_ref(context); #if USE(COORDINATED_GRAPHICS) priv->viewportHandler = EflViewportHandler::create(ewkView); @@ -798,6 +802,14 @@ Evas_Object* ewk_view_add(Evas* canvas) return ewk_view_add_with_context(canvas, ewk_context_default_get()); } +Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + + return priv->context; +} + /** * @internal * The uri of view was changed by the frame loader. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.h b/Source/WebKit2/UIProcess/API/efl/ewk_view.h index 13b8daf0b..314975196 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.h @@ -319,6 +319,15 @@ EAPI Evas_Object *ewk_view_add(Evas *e); EAPI Evas_Object *ewk_view_add_with_context(Evas *e, Ewk_Context *context); /** + * Gets the Ewk_Context of this view. + * + * @param o the view object to get the Ewk_Context + * + * @return the Ewk_Context of this view or @c NULL on failure + */ +EAPI Ewk_Context *ewk_view_context_get(const Evas_Object *o); + +/** * Asks the object to load the given URI. * * @param o view object to load @a URI diff --git a/Source/WebKit2/UIProcess/API/efl/tests/InjectedBundle/injected_bundle_sample.cpp b/Source/WebKit2/UIProcess/API/efl/tests/InjectedBundle/injected_bundle_sample.cpp new file mode 100644 index 000000000..55f0f190c --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/InjectedBundle/injected_bundle_sample.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * + * 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 <WebKit2/WKBundleInitialize.h> + +#ifdef __cplusplus +extern "C" { +#endif + +void WKBundleInitialize(WKBundleRef bundle, WKTypeRef initializationUserData) +{ +} + +#ifdef __cplusplus +} +#endif diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp index 814f8c2cb..cd3c55d5f 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp @@ -43,6 +43,11 @@ const char* EWK2UnitTestEnvironment::defaultTheme() const return TEST_THEME_DIR"/default.edj"; } +const char* EWK2UnitTestEnvironment::injectedBundleSample() const +{ + return TEST_RESOURCES_DIR "/libewk2UnitTestInjectedBundleSample.so"; +} + CString EWK2UnitTestEnvironment::urlForResource(const char* resource) { return makeString("file://"TEST_RESOURCES_DIR"/", resource).utf8(); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h index fb3a309f8..4255b01b4 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h @@ -32,6 +32,7 @@ public: bool useX11Window() const { return m_useX11Window; } const char* defaultTestPageUrl() const; const char* defaultTheme() const; + const char* injectedBundleSample() const; CString urlForResource(const char* resource); CString pathForResource(const char* resource); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp index b5ce2ee57..82ded55da 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 Intel Corporation. All rights reserved. + * Copyright (C) 2012 Samsung Electronics * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -46,9 +47,10 @@ TEST_F(EWK2UnitTestBase, ewk_context_default_get) TEST_F(EWK2UnitTestBase, ewk_context_cookie_manager_get) { - Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get()); + Ewk_Context* context = ewk_view_context_get(webView()); + Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(context); ASSERT_TRUE(cookieManager); - ASSERT_EQ(cookieManager, ewk_context_cookie_manager_get(ewk_context_default_get())); + ASSERT_EQ(cookieManager, ewk_context_cookie_manager_get(context)); } static void schemeRequestCallback(Ewk_Url_Scheme_Request* request, void* userData) @@ -64,7 +66,7 @@ static void schemeRequestCallback(Ewk_Url_Scheme_Request* request, void* userDat TEST_F(EWK2UnitTestBase, ewk_context_uri_scheme_register) { - ewk_context_uri_scheme_register(ewk_context_default_get(), "fooscheme", schemeRequestCallback, 0); + ewk_context_uri_scheme_register(ewk_view_context_get(webView()), "fooscheme", schemeRequestCallback, 0); loadUrlSync("fooscheme:MyPath"); ASSERT_STREQ(ewk_view_title_get(webView()), "Foo"); } @@ -114,7 +116,7 @@ static void loadVibrationHTMLString(Evas_Object* webView, const char* vibrationP TEST_F(EWK2UnitTestBase, ewk_context_vibration_client_callbacks_set) { VibrationCbData data = { false, false, 0, 5000 }; - ewk_context_vibration_client_callbacks_set(ewk_context_default_get(), vibrateCallback, cancelVibrationCallback, &data); + ewk_context_vibration_client_callbacks_set(ewk_view_context_get(webView()), vibrateCallback, cancelVibrationCallback, &data); // Vibrate for 5 seconds. loadVibrationHTMLString(webView(), "5000", true, &data); @@ -134,7 +136,7 @@ TEST_F(EWK2UnitTestBase, ewk_context_vibration_client_callbacks_set) ASSERT_TRUE(data.didReceiveCancelVibrationCallback); // Stop listening for vibration events, by calling the function with null for the callbacks. - ewk_context_vibration_client_callbacks_set(ewk_context_default_get(), 0, 0, &data); + ewk_context_vibration_client_callbacks_set(ewk_view_context_get(webView()), 0, 0, &data); // Make sure we don't receive vibration event. loadVibrationHTMLString(webView(), "[5000]", false, &data); @@ -148,3 +150,25 @@ TEST_F(EWK2UnitTestBase, ewk_context_vibration_client_callbacks_set) ASSERT_STREQ(ewk_view_title_get(webView()), "Loaded"); ASSERT_FALSE(data.didReceiveCancelVibrationCallback); } + +TEST_F(EWK2UnitTestBase, ewk_context_new) +{ + Ewk_Context* context = ewk_context_new(); + ASSERT_TRUE(context); + ewk_context_unref(context); +} + +TEST_F(EWK2UnitTestBase, ewk_context_new_with_injected_bundle_path) +{ + Ewk_Context* context = ewk_context_new_with_injected_bundle_path(environment->injectedBundleSample()); + ASSERT_TRUE(context); + ewk_context_unref(context); +} + +TEST_F(EWK2UnitTestBase, ewk_context_ref) +{ + Ewk_Context* context = ewk_context_new(); + ASSERT_EQ(context, ewk_context_ref(context)); + ewk_context_unref(context); + ewk_context_unref(context); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp index e0319f7ce..4353ced79 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp @@ -121,7 +121,7 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_accept_policy) OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); httpServer->run(serverCallback); - Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get()); + Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView())); ASSERT_TRUE(cookieManager); // Default policy is EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY. @@ -164,7 +164,7 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_changes_watch) OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); httpServer->run(serverCallback); - Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get()); + Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView())); ASSERT_TRUE(cookieManager); ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); @@ -227,7 +227,7 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_cookies_delete) OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); httpServer->run(serverCallback); - Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get()); + Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView())); ASSERT_TRUE(cookieManager); ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); @@ -269,7 +269,7 @@ TEST_F(EWK2UnitTestBase, DISABLED_ewk_cookie_manager_permanent_storage) char sqliteStorage[] = "/tmp/sqlite-cookie.XXXXXX"; ASSERT_TRUE(mktemp(sqliteStorage)); - Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get()); + Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView())); ASSERT_TRUE(cookieManager); ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp index 25f62fcf8..8c258ba66 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp @@ -714,4 +714,11 @@ TEST_F(EWK2UnitTestBase, ewk_view_color_picker_color_set) ecore_main_loop_iterate(); evas_object_smart_callback_del(webView(), "input,type,color,request", onColorPickerDone); } + +TEST_F(EWK2UnitTestBase, ewk_view_context_get) +{ + Ewk_Context* context = ewk_view_context_get(webView()); + ASSERT_TRUE(context); + ASSERT_EQ(context, ewk_view_context_get(webView())); +} #endif // ENABLE(INPUT_TYPE_COLOR) |