Source/WebKit2/ChangeLog

 12013-04-15 Jinwoo Song <jinwoo7.song@samsung.com>
 2
 3 [EFL][WK2] Add ewk APIs for setting and getting user agent
 4 https://bugs.webkit.org/show_bug.cgi?id=114429
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Provide ewk_view_user_agent_get/set APIs which wraps WK APIs.
 9
 10 * UIProcess/API/efl/EwkView.cpp:
 11 (EwkView::userAgent):
 12 (EwkView::setUserAgent):
 13 * UIProcess/API/efl/EwkView.h:
 14 (EwkView):
 15 * UIProcess/API/efl/ewk_view.cpp:
 16 (ewk_view_user_agent_get):
 17 (ewk_view_user_agent_set):
 18 * UIProcess/API/efl/ewk_view.h:
 19 * UIProcess/API/efl/tests/test_ewk2_popup_menu.cpp:
 20 (showPopupMenu):
 21 * UIProcess/API/efl/tests/test_ewk2_view.cpp:
 22 (TEST_F):
 23 * UIProcess/WebPageProxy.cpp:
 24 (WebKit::WebPageProxy::setCustomUserAgent):
 25
1262013-04-15 Michał Pakuła vel Rutka <m.pakula@samsung.com>
227
328 [WK2] Add new callbacks and a function for WebKit2 context menu API

Source/WebKit2/UIProcess/API/efl/EwkView.cpp

@@void EwkView::setCustomTextEncodingName(const String& encoding)
671671 WKPageSetCustomTextEncodingName(wkPage(), wkEncoding.get());
672672}
673673
 674const char* EwkView::userAgent() const
 675{
 676 WKRetainPtr<WKStringRef> userAgent = adoptWK(WKPageCopyUserAgent(wkPage()));
 677 if (WKStringIsEmpty(userAgent.get()))
 678 return 0;
 679
 680 m_userAgent = WKEinaSharedString(userAgent.get());
 681
 682 return m_userAgent;
 683}
 684
 685void EwkView::setUserAgent(const String& userAgent)
 686{
 687 WKRetainPtr<WKStringRef> wkUserAgent = adoptWK(toCopiedAPI(userAgent));
 688 WKPageSetCustomUserAgent(wkPage(), wkUserAgent.get());
 689}
 690
674691void EwkView::setMouseEventsEnabled(bool enabled)
675692{
676693 if (m_mouseEventsEnabled == enabled)

Source/WebKit2/UIProcess/API/efl/EwkView.h

@@public:
140140 void setThemePath(const char* theme);
141141 const char* customTextEncodingName() const;
142142 void setCustomTextEncodingName(const String& encoding);
 143 const char* userAgent() const;
 144 void setUserAgent(const String& userAgent);
143145
144146 bool mouseEventsEnabled() const { return m_mouseEventsEnabled; }
145147 void setMouseEventsEnabled(bool enabled);

@@private:
272274 mutable WKEinaSharedString m_title;
273275 WKEinaSharedString m_theme;
274276 mutable WKEinaSharedString m_customEncoding;
 277 mutable WKEinaSharedString m_userAgent;
275278 bool m_mouseEventsEnabled;
276279#if ENABLE(TOUCH_EVENTS)
277280 bool m_touchEventsEnabled;

Source/WebKit2/UIProcess/API/efl/ewk_view.cpp

@@Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encodin
348348 return true;
349349}
350350
 351const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
 352{
 353 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
 354
 355 return impl->userAgent();
 356}
 357
 358Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
 359{
 360 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
 361
 362 impl->setUserAgent(userAgent ? userAgent : String());
 363
 364 return true;
 365}
 366
351367// EwkFindOptions should be matched up orders with WkFindOptions.
352368COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive);
353369COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts);

Source/WebKit2/UIProcess/API/efl/ewk_view.h

@@EAPI const char *ewk_view_theme_get(const Evas_Object *o);
632632 *
633633 * @param o view object to get the current encoding
634634 *
635  * @return @c eina_strinshare containing the current encoding, or
 635 * @return @c eina_stringshare containing the current encoding, or
636636 * @c NULL if it's not set
637637 */
638 EAPI const char *ewk_view_custom_encoding_get(const Evas_Object *o);
 638EAPI const char *ewk_view_custom_encoding_get(const Evas_Object *o);
639639
640640/**
641641 * Sets the custom character encoding and reloads the page.

@@EAPI const char *ewk_view_custom_encoding_get(const Evas_Object *o);
645645 *
646646 * @return @c EINA_TRUE on success @c EINA_FALSE otherwise
647647 */
648 EAPI Eina_Bool ewk_view_custom_encoding_set(Evas_Object *o, const char *encoding);
 648EAPI Eina_Bool ewk_view_custom_encoding_set(Evas_Object *o, const char *encoding);
 649
 650/**
 651 * Gets the current user agent string.
 652 *
 653 * @param o view object to get the current user agent
 654 *
 655 * @return @c eina_stringshare containing the current user agent, or
 656 * @c default user agent if it's not set
 657 */
 658EAPI const char *ewk_view_user_agent_get(const Evas_Object *o);
 659
 660/**
 661 * Sets the user agent string.
 662 *
 663 * @param o view to set the user agent
 664 * @param user_agent the user agent string to set or @c NULL to restore the default one
 665 *
 666 * @return @c EINA_TRUE on success @c EINA_FALSE otherwise
 667 */
 668EAPI Eina_Bool ewk_view_user_agent_set(Evas_Object *o, const char *encoding);
649669
650670/**
651671 * Searches and hightlights the given string in the document.

Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp

@@TEST_F(EWK2UnitTestBase, ewk_view_source_mode)
990990 // such as excuting the JavaScript, 'window.document.body.innerText'.
991991 // https://bugs.webkit.org/show_bug.cgi?id=101904.
992992}
 993
 994TEST_F(EWK2UnitTestBase, ewk_view_user_agent)
 995{
 996 const char* defaultUserAgent = eina_stringshare_add(ewk_view_user_agent_get(webView()));
 997 const char customUserAgent[] = "Foo";
 998
 999 ASSERT_TRUE(ewk_view_user_agent_set(webView(), customUserAgent));
 1000 ASSERT_STREQ(customUserAgent, ewk_view_user_agent_get(webView()));
 1001
 1002 // Set the default user agent string.
 1003 ewk_view_user_agent_set(webView(), 0);
 1004 ASSERT_STREQ(defaultUserAgent, ewk_view_user_agent_get(webView()));
 1005 eina_stringshare_del(defaultUserAgent);
 1006}