Changeset 139422 in webkit
- Timestamp:
- Jan 11, 2013 2:31:42 AM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r139421 r139422 1 2013-01-11 KwangYong Choi <ky0.choi@samsung.com> 2 3 [EFL][WK2] Add ewk_view_page_contents_get() API 4 https://bugs.webkit.org/show_bug.cgi?id=106440 5 6 Reviewed by Gyuyoung Kim. 7 8 Add ewk_view_page_contents_get() API for getting contents of the current page. 9 Currently, it supports only MHTML type. 10 11 * UIProcess/API/efl/ewk_view.cpp: 12 (Ewk_Page_Contents_Context): 13 (ewkViewPageContentsCallback): 14 (ewk_view_page_contents_get): 15 * UIProcess/API/efl/ewk_view.h: 16 * UIProcess/API/efl/tests/test_ewk2_view.cpp: 17 (PageContentsCallback): 18 (TEST_F): 19 1 20 2013-01-11 Krzysztof Czech <k.czech@samsung.com> 2 21 -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
r139417 r139422 40 40 #include "WKString.h" 41 41 #include "WebContext.h" 42 #include "WebData.h" 42 43 #include "WebFullScreenManagerProxy.h" 43 44 #include "WebPageGroup.h" … … 146 147 } while (0) 147 148 149 /// Creates a type name for Ewk_Page_Contents_Context. 150 typedef struct Ewk_Page_Contents_Context Ewk_Page_Contents_Context; 151 152 /* 153 * @brief Structure containing page contents context used for ewk_view_page_contents_get() API. 154 */ 155 struct Ewk_Page_Contents_Context { 156 Ewk_Page_Contents_Type type; 157 Ewk_Page_Contents_Cb callback; 158 }; 159 148 160 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData) 149 161 { … … 939 951 impl->setDrawsBackground(enabled); 940 952 } 953 954 /** 955 * @internal 956 * Callback function used for ewk_view_page_contents_get(). 957 */ 958 static void ewkViewPageContentsCallback(WKDataRef wkData, WKErrorRef, void* context) 959 { 960 EINA_SAFETY_ON_NULL_RETURN(context); 961 962 RefPtr<WebData> webData = toImpl(wkData); 963 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context); 964 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes())); 965 966 delete contentsContext; 967 } 968 969 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Type type, Ewk_Page_Contents_Cb callback) 970 { 971 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false); 972 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); 973 974 // We only support MHTML at the moment. 975 if (type != EWK_PAGE_CONTENTS_TYPE_MHTML) 976 return false; 977 978 Ewk_Page_Contents_Context* context = new Ewk_Page_Contents_Context; 979 context->type = type; 980 context->callback = callback; 981 982 impl->page()->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsCallback), false); 983 984 return true; 985 } -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h
r137916 r139422 108 108 } Ewk_Text_Direction; 109 109 110 /// Enum values containing page contents type values. 111 typedef enum { 112 EWK_PAGE_CONTENTS_TYPE_MHTML 113 } Ewk_Page_Contents_Type; 114 110 115 typedef struct Ewk_View_Smart_Data Ewk_View_Smart_Data; 111 116 typedef struct Ewk_View_Smart_Class Ewk_View_Smart_Class; … … 316 321 317 322 /** 323 * Creates a type name for the callback function used to get the page contents. 324 * 325 * @param type type of the contents 326 * @param data string buffer of the contents 327 */ 328 typedef void (*Ewk_Page_Contents_Cb)(Ewk_Page_Contents_Type type, const char *data); 329 330 /** 318 331 * Sets the smart class APIs, enabling view to be inherited. 319 332 * … … 847 860 EAPI void ewk_view_draws_page_background_set(Evas_Object *o, Eina_Bool enabled); 848 861 862 /** 863 * Get contents of the current web page. 864 * 865 * @param o view object to get the page contents 866 * @param type type of the page contents 867 * @param callback callback function to be called when the operation is finished 868 * 869 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise 870 */ 871 EAPI Eina_Bool ewk_view_page_contents_get(const Evas_Object *o, Ewk_Page_Contents_Type type, Ewk_Page_Contents_Cb callback); 872 849 873 #ifdef __cplusplus 850 874 } -
trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp
r137595 r139422 917 917 evas_object_smart_callback_del(webView(), "contents,size,changed", onContentsSizeChanged); 918 918 } 919 920 static bool isObtainedPageContents = false; 921 922 static void PageContentsCallback(Ewk_Page_Contents_Type type, const char* data) 923 { 924 // Check the type 925 ASSERT_EQ(EWK_PAGE_CONTENTS_TYPE_MHTML, type); 926 927 // The variable data should have below text block. 928 const char lines[] = "<=00h=00t=00m=00l=00>=00<=00h=00e=00a=00d=00>=00<=00m=00e=00t=00a=00 =00c=\r\n" 929 "=00h=00a=00r=00s=00e=00t=00=3D=00\"=00U=00T=00F=00-=001=006=00L=00E=00\"=00>=\r\n" 930 "=00<=00/=00h=00e=00a=00d=00>=00<=00b=00o=00d=00y=00>=00<=00p=00>=00S=00i=00=\r\n" 931 "m=00p=00l=00e=00 =00H=00T=00M=00L=00<=00/=00p=00>=00<=00/=00b=00o=00d=00y=\r\n" 932 "=00>=00<=00/=00h=00t=00m=00l=00>=00"; 933 ASSERT_EQ(0, strncmp(data + 359, lines, strlen(lines))); 934 935 isObtainedPageContents = true; 936 } 937 938 TEST_F(EWK2UnitTestBase, ewk_view_page_contents_get) 939 { 940 const char content[] = "<p>Simple HTML</p>"; 941 ewk_view_html_string_load(webView(), content, 0, 0); 942 waitUntilLoadFinished(); 943 944 ASSERT_TRUE(ewk_view_page_contents_get(webView(), EWK_PAGE_CONTENTS_TYPE_MHTML, PageContentsCallback)); 945 while (!isObtainedPageContents) 946 ecore_main_loop_iterate(); 947 }
Note: See TracChangeset
for help on using the changeset viewer.