Changeset 129134 in webkit
- Timestamp:
- Sep 20, 2012 7:39:23 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r129121 r129134 1 2012-09-20 Eunmi Lee <eunmi15.lee@samsung.com> 2 3 [EFL][WK2] Add APIs to create, delete and get ewk_context. 4 https://bugs.webkit.org/show_bug.cgi?id=89186 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Provide APIs to create ewk_context with or without injected bundle path 9 and delete created ewk_context. 10 Additionally, the ewk_view can be created with ewk_context which is not 11 default context, so we have to get ewk_context from ewk_view. 12 13 * PlatformEfl.cmake: 14 * UIProcess/API/efl/PageClientImpl.cpp: 15 (WebKit::PageClientImpl::handleDownloadRequest): 16 * UIProcess/API/efl/ewk_context.cpp: 17 (_Ewk_Context): 18 (_Ewk_Context::_Ewk_Context): 19 (ewk_context_ref): 20 (ewk_context_unref): 21 (ewk_context_new): 22 (ewk_context_new_with_injected_bundle_path): 23 * UIProcess/API/efl/ewk_context.h: 24 * UIProcess/API/efl/ewk_view.cpp: 25 (_Ewk_View_Private_Data): 26 (_Ewk_View_Private_Data::_Ewk_View_Private_Data): 27 (_ewk_view_priv_del): 28 (_ewk_view_initialize): 29 (ewk_view_context_get): 30 * UIProcess/API/efl/ewk_view.h: 31 * UIProcess/API/efl/tests/InjectedBundle/injected_bundle_sample.cpp: Added. 32 * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp: 33 (EWK2UnitTest::EWK2UnitTestEnvironment::injectedBundleSample): 34 (EWK2UnitTest): 35 * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h: 36 (EWK2UnitTestEnvironment): 37 * UIProcess/API/efl/tests/test_ewk2_context.cpp: 38 (TEST_F): 39 * UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp: 40 (TEST_F): 41 * UIProcess/API/efl/tests/test_ewk2_view.cpp: 42 (TEST_F): 43 1 44 2012-09-20 KwangYong Choi <ky0.choi@samsung.com> 2 45 -
trunk/Source/WebKit2/PlatformEfl.cmake
r128853 r129134 262 262 SET(WEBKIT2_EFL_TEST_DIR "${WEBKIT2_DIR}/UIProcess/API/efl/tests") 263 263 SET(TEST_RESOURCES_DIR ${WEBKIT2_EFL_TEST_DIR}/resources) 264 SET(TEST_INJECTED_BUNDLE_DIR ${WEBKIT2_EFL_TEST_DIR}/InjectedBundle) 264 265 265 266 ADD_DEFINITIONS(-DTEST_RESOURCES_DIR=\"${TEST_RESOURCES_DIR}\" … … 301 302 TARGET_LINK_LIBRARIES(${testName} ${EWK2UnitTests_LIBRARIES} ewk2UnitTestUtils) 302 303 ENDFOREACH () 304 305 ADD_LIBRARY(ewk2UnitTestInjectedBundleSample SHARED ${TEST_INJECTED_BUNDLE_DIR}/injected_bundle_sample.cpp) 306 SET_TARGET_PROPERTIES(ewk2UnitTestInjectedBundleSample PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${TEST_RESOURCES_DIR}") 303 307 ENDIF () 304 308 -
trunk/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
r129096 r129134 286 286 { 287 287 Ewk_Download_Job* ewkDownload = ewk_download_job_new(download, m_viewWidget); 288 // For now we only support one default context, but once we support 289 // multiple contexts, we will need to retrieve the context from the 290 // view. 291 ewk_context_download_job_add(ewk_context_default_get(), ewkDownload); 288 ewk_context_download_job_add(ewk_view_context_get(m_viewWidget), ewkDownload); 292 289 ewk_download_job_unref(ewkDownload); 293 290 } -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
r128413 r129134 29 29 #include "WKRetainPtr.h" 30 30 #include "WKString.h" 31 #include "WebContext.h" 31 32 #include "ewk_context_download_client_private.h" 32 33 #include "ewk_context_private.h" … … 35 36 #include "ewk_download_job.h" 36 37 #include "ewk_download_job_private.h" 38 #include <WebCore/FileSystem.h> 37 39 #include <wtf/HashMap.h> 38 40 #include <wtf/text/WTFString.h> 39 41 42 using namespace WebCore; 40 43 using namespace WebKit; 41 44 … … 58 61 59 62 struct _Ewk_Context { 63 unsigned __ref; /**< the reference count of the object */ 60 64 WKRetainPtr<WKContextRef> context; 61 65 … … 73 77 74 78 _Ewk_Context(WKRetainPtr<WKContextRef> contextRef) 75 : context(contextRef) 79 : __ref(1) 80 , context(contextRef) 76 81 , cookieManager(0) 77 82 , requestManager(WKContextGetSoupRequestManager(contextRef.get())) … … 113 118 }; 114 119 120 Ewk_Context* ewk_context_ref(Ewk_Context* ewkContext) 121 { 122 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0); 123 ++ewkContext->__ref; 124 125 return ewkContext; 126 } 127 128 void ewk_context_unref(Ewk_Context* ewkContext) 129 { 130 EINA_SAFETY_ON_NULL_RETURN(ewkContext); 131 EINA_SAFETY_ON_FALSE_RETURN(ewkContext->__ref > 0); 132 133 if (--ewkContext->__ref) 134 return; 135 136 delete ewkContext; 137 } 138 115 139 Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext) 116 140 { … … 216 240 } 217 241 242 Ewk_Context* ewk_context_new() 243 { 244 return new Ewk_Context(adoptWK(WKContextCreate())); 245 } 246 247 Ewk_Context* ewk_context_new_with_injected_bundle_path(const char* path) 248 { 249 EINA_SAFETY_ON_NULL_RETURN_VAL(path, 0); 250 251 WKRetainPtr<WKStringRef> pathRef(AdoptWK, WKStringCreateWithUTF8CString(path)); 252 if (!fileExists(toImpl(pathRef.get())->string())) 253 return 0; 254 255 return new Ewk_Context(adoptWK(WKContextCreateWithInjectedBundlePath(pathRef.get()))); 256 } 257 218 258 Eina_Bool ewk_context_uri_scheme_register(Ewk_Context* ewkContext, const char* scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData) 219 259 { -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.h
r123482 r129134 23 23 * 24 24 * @note ewk_context encapsulates all pages related to specific use of WebKit. 25 * All pages in this context share the same visited link set, 26 * local storage set, and preferences. 25 * 26 * Applications have the option of creating a context different than the default one 27 * and use it for a group of pages. All pages in the same context share the same 28 * preferences, visited link set, local storage, etc. 29 * 30 * A process model can be specified per context. The default one is the shared model 31 * where the web-engine process is shared among the pages in the context. The second 32 * model allows each page to use a separate web-engine process. This latter model is 33 * currently not supported by WebKit2/EFL. 34 * 27 35 */ 28 36 … … 62 70 63 71 /** 72 * Increases the reference count of the given object. 73 * 74 * @param context context object to increase the reference count 75 * 76 * @return Ewk_Context object on success or @c NULL on failure 77 */ 78 EAPI Ewk_Context *ewk_context_ref(Ewk_Context *context); 79 80 /** 81 * Decreases the reference count of the given object, possibly freeing it. 82 * 83 * When the reference count it's reached 0, the Ewk_Context is freed. 84 * 85 * @param context context object to decrease the reference count 86 */ 87 EAPI void ewk_context_unref(Ewk_Context *context); 88 89 /** 64 90 * Gets default Ewk_Context instance. 91 * 92 * The returned Ewk_Context object @b should not be unref'ed if application 93 * does not call ewk_context_ref() for that. 65 94 * 66 95 * @return Ewk_Context object. 67 96 */ 68 EAPI Ewk_Context *ewk_context_default_get(); 97 EAPI Ewk_Context *ewk_context_default_get(void); 98 99 /** 100 * Creates a new Ewk_Context. 101 * 102 * The returned Ewk_Context object @b should be unref'ed after use. 103 * 104 * @return Ewk_Context object on success or @c NULL on failure 105 * 106 * @see ewk_context_unref 107 * @see ewk_context_new_with_injected_bundle_path 108 */ 109 EAPI Ewk_Context *ewk_context_new(void); 110 111 /** 112 * Creates a new Ewk_Context. 113 * 114 * The returned Ewk_Context object @b should be unref'ed after use. 115 * 116 * @param path path of injected bundle library 117 * 118 * @return Ewk_Context object on success or @c NULL on failure 119 * 120 * @see ewk_context_unref 121 * @see ewk_context_new 122 */ 123 EAPI Ewk_Context *ewk_context_new_with_injected_bundle_path(const char *path); 69 124 70 125 /** -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
r129121 r129134 101 101 bool areMouseEventsEnabled; 102 102 WKColorPickerResultListenerRef colorPickerResultListener; 103 Ewk_Context* context; 103 104 104 105 WebPopupMenuProxyEfl* popupMenuProxy; … … 120 121 , areMouseEventsEnabled(false) 121 122 , colorPickerResultListener(0) 123 , context(0) 122 124 , popupMenuProxy(0) 123 125 , popupMenuItems(0) … … 385 387 static void _ewk_view_priv_del(Ewk_View_Private_Data* priv) 386 388 { 389 ewk_context_unref(priv->context); 387 390 delete priv; 388 391 } … … 715 718 priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageProxy->backForwardList())); 716 719 priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get()))))); 720 priv->context = ewk_context_ref(context); 717 721 718 722 #if USE(COORDINATED_GRAPHICS) … … 799 803 } 800 804 805 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView) 806 { 807 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); 808 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); 809 810 return priv->context; 811 } 812 801 813 /** 802 814 * @internal -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h
r129121 r129134 320 320 321 321 /** 322 * Gets the Ewk_Context of this view. 323 * 324 * @param o the view object to get the Ewk_Context 325 * 326 * @return the Ewk_Context of this view or @c NULL on failure 327 */ 328 EAPI Ewk_Context *ewk_view_context_get(const Evas_Object *o); 329 330 /** 322 331 * Asks the object to load the given URI. 323 332 * -
trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp
r127823 r129134 44 44 } 45 45 46 const char* EWK2UnitTestEnvironment::injectedBundleSample() const 47 { 48 return TEST_RESOURCES_DIR "/libewk2UnitTestInjectedBundleSample.so"; 49 } 50 46 51 CString EWK2UnitTestEnvironment::urlForResource(const char* resource) 47 52 { -
trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h
r127823 r129134 33 33 const char* defaultTestPageUrl() const; 34 34 const char* defaultTheme() const; 35 const char* injectedBundleSample() const; 35 36 CString urlForResource(const char* resource); 36 37 CString pathForResource(const char* resource); -
trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp
r129111 r129134 1 1 /* 2 2 * Copyright (C) 2012 Intel Corporation. All rights reserved. 3 * Copyright (C) 2012 Samsung Electronics 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 47 48 TEST_F(EWK2UnitTestBase, ewk_context_cookie_manager_get) 48 49 { 49 Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get()); 50 Ewk_Context* context = ewk_view_context_get(webView()); 51 Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(context); 50 52 ASSERT_TRUE(cookieManager); 51 ASSERT_EQ(cookieManager, ewk_context_cookie_manager_get( ewk_context_default_get()));53 ASSERT_EQ(cookieManager, ewk_context_cookie_manager_get(context)); 52 54 } 53 55 … … 65 67 TEST_F(EWK2UnitTestBase, ewk_context_uri_scheme_register) 66 68 { 67 ewk_context_uri_scheme_register(ewk_ context_default_get(), "fooscheme", schemeRequestCallback, 0);69 ewk_context_uri_scheme_register(ewk_view_context_get(webView()), "fooscheme", schemeRequestCallback, 0); 68 70 loadUrlSync("fooscheme:MyPath"); 69 71 ASSERT_STREQ(ewk_view_title_get(webView()), "Foo"); … … 115 117 { 116 118 VibrationCbData data = { false, false, 0, 5000 }; 117 ewk_context_vibration_client_callbacks_set(ewk_ context_default_get(), vibrateCallback, cancelVibrationCallback, &data);119 ewk_context_vibration_client_callbacks_set(ewk_view_context_get(webView()), vibrateCallback, cancelVibrationCallback, &data); 118 120 119 121 // Vibrate for 5 seconds. … … 135 137 136 138 // Stop listening for vibration events, by calling the function with null for the callbacks. 137 ewk_context_vibration_client_callbacks_set(ewk_ context_default_get(), 0, 0, &data);139 ewk_context_vibration_client_callbacks_set(ewk_view_context_get(webView()), 0, 0, &data); 138 140 139 141 // Make sure we don't receive vibration event. … … 149 151 ASSERT_FALSE(data.didReceiveCancelVibrationCallback); 150 152 } 153 154 TEST_F(EWK2UnitTestBase, ewk_context_new) 155 { 156 Ewk_Context* context = ewk_context_new(); 157 ASSERT_TRUE(context); 158 ewk_context_unref(context); 159 } 160 161 TEST_F(EWK2UnitTestBase, ewk_context_new_with_injected_bundle_path) 162 { 163 Ewk_Context* context = ewk_context_new_with_injected_bundle_path(environment->injectedBundleSample()); 164 ASSERT_TRUE(context); 165 ewk_context_unref(context); 166 } 167 168 TEST_F(EWK2UnitTestBase, ewk_context_ref) 169 { 170 Ewk_Context* context = ewk_context_new(); 171 ASSERT_EQ(context, ewk_context_ref(context)); 172 ewk_context_unref(context); 173 ewk_context_unref(context); 174 } -
trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp
r127405 r129134 122 122 httpServer->run(serverCallback); 123 123 124 Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_ context_default_get());124 Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView())); 125 125 ASSERT_TRUE(cookieManager); 126 126 … … 165 165 httpServer->run(serverCallback); 166 166 167 Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_ context_default_get());167 Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView())); 168 168 ASSERT_TRUE(cookieManager); 169 169 … … 228 228 httpServer->run(serverCallback); 229 229 230 Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_ context_default_get());230 Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView())); 231 231 ASSERT_TRUE(cookieManager); 232 232 … … 270 270 ASSERT_TRUE(mktemp(sqliteStorage)); 271 271 272 Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_ context_default_get());272 Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView())); 273 273 ASSERT_TRUE(cookieManager); 274 274 -
trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp
r129121 r129134 715 715 evas_object_smart_callback_del(webView(), "input,type,color,request", onColorPickerDone); 716 716 } 717 718 TEST_F(EWK2UnitTestBase, ewk_view_context_get) 719 { 720 Ewk_Context* context = ewk_view_context_get(webView()); 721 ASSERT_TRUE(context); 722 ASSERT_EQ(context, ewk_view_context_get(webView())); 723 } 717 724 #endif // ENABLE(INPUT_TYPE_COLOR)
Note: See TracChangeset
for help on using the changeset viewer.