Add to ewk api for setting/getting the User Agent by using system info library.
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / API / efl / ewk_view.cpp
index af456ca..cc62359 100755 (executable)
@@ -517,8 +517,10 @@ static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, con
     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
 
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
-    if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
+    if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned()) {
+        impl->pageClient->initTextSelectionHandlesMouseDownedStatus();
         return true;
+    }
 #endif
 
 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
@@ -548,8 +550,13 @@ static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, con
 #endif
 
             impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
-        } else if (event->count == 2)
+        } else if (event->count == 2) {
+#if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
+            if (impl->focusRing)
+                impl->focusRing->requestToHide(true);
+#endif
             impl->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
+        }
         break;
     case EWK_GESTURE_LONG_PRESS:
         // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
@@ -586,8 +593,12 @@ static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, co
 #endif
 
 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
-    if (impl->focusRing && !(event->type == EWK_GESTURE_PAN && !impl->exceedTouchMoveThreshold))
-        impl->focusRing->requestToHide(true);
+    if (impl->focusRing && !(event->type == EWK_GESTURE_PAN && !impl->exceedTouchMoveThreshold)) {
+#if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
+        if (!impl->pageClient->isContextMenuVisible())
+#endif
+            impl->focusRing->requestToHide(true);
+    }
 #endif
 
     switch (event->type) {
@@ -995,9 +1006,6 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView)
 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
         impl->pageClient->frameRectChanged();
 #endif
-#if ENABLE(TIZEN_SCREEN_READER)
-        impl->pageProxy->recalcScreenReaderFocusRect();
-#endif
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
         impl->pageClient->updateTextSelectionHandlesAndContextMenu(true);
 #endif
@@ -1999,6 +2007,10 @@ void ewkViewLoadCommitted(Evas_Object* ewkView)
 #if ENABLE(TIZEN_ISF_PORT)
     impl->inputMethodContext()->hideIMFContext();
 #endif
+#if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
+    if (smartData->api->formdata_candidate_is_showing(smartData))
+        smartData->api->formdata_candidate_hide(smartData);
+#endif
     impl->informURLChange();
     evas_object_smart_callback_call(ewkView, "load,committed", 0);
 }
@@ -2491,17 +2503,6 @@ bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExter
 #endif
 
 #if ENABLE(TIZEN_ISF_PORT)
-    Ecore_X_Window rootWin = ecore_x_window_root_first_get();
-    ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
-    Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
-    unsigned int connectedKeyboardNum = 0;
-    bool isExternalKeyboardConnected = false;
-
-    // get connected keyboard number
-    if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
-        && connectedKeyboardNum)
-        isExternalKeyboardConnected = true;
-
     // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
     // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
     // input field zoom should not work with below conditions
@@ -2510,7 +2511,7 @@ bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExter
     // 3. imfContext is null(if adjustForExternalKeyboard is false)
     // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
     if ((!(static_cast<PageClient*>(impl->pageClient.get()))->isViewFocused()
-        || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
+        || (adjustForExternalKeyboard && !InputMethodContextEfl::shouldUseExternalKeyboard())
         || (!adjustForExternalKeyboard && !impl->inputMethodContext())
         || (!adjustForExternalKeyboard && !impl->inputMethodContext()->isShow()))
 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
@@ -2869,6 +2870,14 @@ const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
 
+#if OS(TIZEN)
+    WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
+
+    int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
+    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
+    WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
+    impl->userAgent = buffer.get();
+#else
     if (!impl->userAgent) {
         WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
 
@@ -2877,9 +2886,41 @@ const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
         WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
         impl->userAgent = buffer.get();
     }
+#endif
 
     return impl->userAgent;
 }
+
+#if OS(TIZEN)
+Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* ewkView, const char* applicationName)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(applicationName, false);
+
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
+
+    WKRetainPtr<WKStringRef> applicationNameString(AdoptWK, WKStringCreateWithUTF8CString(applicationName));
+    WKPageSetApplicationNameForUserAgent(toAPI(impl->pageProxy.get()), applicationNameString.get());
+
+    return true;
+}
+
+const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* ewkView)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
+    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
+
+    WKRetainPtr<WKStringRef> applicationNameString(AdoptWK, WKPageCopyApplicationNameForUserAgent(toAPI(impl->pageProxy.get())));
+
+    int length = WKStringGetMaximumUTF8CStringSize(applicationNameString.get());
+    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
+    WKStringGetUTF8CString(applicationNameString.get(), buffer.get(), length);
+    impl->applicationName = buffer.get();
+
+    return impl->applicationName;
+}
+#endif
+
 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
 {
 #if ENABLE(TIZEN_CUSTOM_HEADERS)