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 24dcf69..cc62359 100755 (executable)
@@ -413,13 +413,13 @@ static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, c
             impl->focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
         } else if (event->type == EWK_GESTURE_PAN) {
             if (impl->exceedTouchMoveThreshold)
-                impl->focusRing->hide();
+                impl->focusRing->requestToHide();
         } else {
             if (event->type != EWK_GESTURE_LONG_PRESS) {
 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
                 if (!impl->pageClient->isContextMenuVisible())
 #endif
-                    impl->focusRing->hide();
+                    impl->focusRing->requestToHide();
             }
         }
     }
@@ -447,8 +447,11 @@ static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, c
             break;
 #if ENABLE(TIZEN_DRAG_SUPPORT)
         // 1. Check to start dragging.
-        if (hitTestResultData.isDragSupport) {
+        if (hitTestResultData.isDragSupport && !hitTestResultData.isContentEditable) {
             impl->pageClient->setDragPoint(scenePoint);
+            if (impl->pageClient->isDragMode()) {
+                impl->pageClient->setDragMode(false);
+            }
 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
             if (impl->focusRing)
                 impl->focusRing->show(IntRect(), true);
@@ -458,8 +461,8 @@ static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, c
         }
 #endif
         // 2. Check to show context menu.
-        if (!hitTestResultData.absoluteImageURL.isEmpty()
-            || !hitTestResultData.absoluteLinkURL.isEmpty()) {
+        if ((!hitTestResultData.absoluteImageURL.isEmpty() || !hitTestResultData.absoluteLinkURL.isEmpty())
+            && !hitTestResultData.isContentEditable) {
 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
             if (impl->focusRing)
                 impl->focusRing->show(IntRect(), true);
@@ -514,16 +517,18 @@ 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)
     if (impl->focusRing) {
 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
-        if (!impl->pageClient->isContextMenuVisible())
+        if (!impl->pageClient->isContextMenuVisible() || impl->pageClient->isTextSelectionMode())
 #endif
-            impl->focusRing->hide();
+            impl->focusRing->requestToHide();
     }
 #endif
 
@@ -545,14 +550,15 @@ 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:
-#if ENABLE(TIZEN_DRAG_SUPPORT)
-        if (impl->pageClient->isDragMode())
-            impl->pageClient->setDragMode(false);
-#endif
         // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
         impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
         break;
@@ -587,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->hide();
+    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) {
@@ -889,8 +899,17 @@ static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
     evas_object_image_native_surface_set(smartData->image, 0);
 
+#if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
+    if (impl->pageClient->isVisible()) {
+        Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
+        impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
+    } else
+        impl->pageClient->setDeferUpdateViewportSize(true);
+#else
     Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
     impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
+#endif
+
 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
     if (!ewk_view_is_opengl_backend(ewkView))
         _ewk_view_composite(smartData);
@@ -960,6 +979,12 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView)
 #endif
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
                 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
+                int newAngle = ecore_evas_rotation_get(ee);
+#if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
+                if (impl->pageClient->deferUpdateViewportSize()) {
+                    impl->pageClient->updateViewportSize(IntSize(width, height), newAngle);
+                }
+#endif
                 impl->pageClient->updateVisibleContentRectSize(IntSize(width, height));
                 if (ewk_view_is_opengl_backend(ewkView))
                     impl->pageClient->displayViewport();
@@ -981,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
@@ -1978,9 +2000,17 @@ void ewkViewLoadCommitted(Evas_Object* ewkView)
     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
     impl->gestureClient->reset();
 #endif
+#if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
+    if (impl->focusRing)
+        impl->focusRing->hide();
+#endif
 #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);
 }
@@ -2473,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
@@ -2492,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)
@@ -2851,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())));
 
@@ -2859,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)
@@ -4809,3 +4868,20 @@ void ewk_view_use_settings_font(Evas_Object* ewkView)
     impl->pageProxy->useSettingsFont();
 #endif
 }
+
+void ewk_view_fullscreen_exit(Evas_Object* ewkView)
+{
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    TIZEN_LOGI("");
+
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
+
+    if (!impl->pageProxy->fullScreenManager()->isFullScreen())
+        return;
+
+    impl->pageProxy->fullScreenManager()->requestExitFullScreen();
+#else
+    UNUSED_PARAM(ewkView);
+#endif
+}