Implement Focus UI
[framework/web/webkit-efl.git] / Source / WebKit2 / WebProcess / WebCoreSupport / WebChromeClient.cpp
index ed999b1..734b39d 100755 (executable)
 #include <WebCore/SecurityOrigin.h>
 #include <WebCore/Settings.h>
 
-#if ENABLE(TIZEN_DISPLAY_MESSAGE_TO_CONSOLE)
-#include <dlog/dlog.h>
-#endif
-
 using namespace WebCore;
 using namespace HTMLNames;
 
@@ -176,6 +172,11 @@ void WebChromeClient::focusedNodeChanged(Node* node)
         nodeRect.setY(nodeRect.y() / m_page->pageScaleFactor());
     }
     m_page->send(Messages::WebPageProxy::FocusedNodeChanged(nodeRect));
+
+#if ENABLE(TIZEN_FOCUS_UI)
+    if (m_page->corePage()->settings()->isSpatialNavigationEnabled())
+        m_page->didChangeFocusedRect(m_page->corePage()->focusController()->focusedOrMainFrame()->document()->focusedNode());
+#endif
 #else
     notImplemented();
 #endif
@@ -188,7 +189,7 @@ void WebChromeClient::focusedFrameChanged(Frame* frame)
     WebProcess::shared().connection()->send(Messages::WebPageProxy::FocusedFrameChanged(webFrame ? webFrame->frameID() : 0), m_page->pageID());
 }
 
-Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& windowFeatures, const NavigationAction& navigationAction)
+Page* WebChromeClient::createWindow(Frame* frame, const FrameLoadRequest& request, const WindowFeatures& windowFeatures, const NavigationAction& navigationAction)
 {
     uint32_t modifiers = static_cast<uint32_t>(InjectedBundleNavigationAction::modifiersForNavigationAction(navigationAction));
     int32_t mouseButton = static_cast<int32_t>(InjectedBundleNavigationAction::mouseButtonForNavigationAction(navigationAction));
@@ -202,6 +203,11 @@ Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest& request, con
         return 0;
 
     WebProcess::shared().createWebPage(newPageID, parameters);
+#if ENABLE(TIZEN_WEBKIT2_SAME_PAGE_GROUP_FOR_CREATE_WINDOW_OPERATION)
+    WebCore::Page* page = WebProcess::shared().webPage(newPageID)->corePage();
+    page->setGroupName(frame->page()->groupName());
+    return page;
+#endif
     return WebProcess::shared().webPage(newPageID)->corePage();
 }
 
@@ -305,16 +311,16 @@ void WebChromeClient::addMessageToConsole(MessageSource, MessageType, MessageLev
 
     switch (level) {
     case WarningMessageLevel:
-        ALOG(LOG_WARN, "ConsoleMessage", "%s", newMessage.utf8().data());
+        TIZEN_CONSOLEW("%s", newMessage.utf8().data());
         break;
     case ErrorMessageLevel:
-        ALOG(LOG_ERROR, "ConsoleMessage", "%s", newMessage.utf8().data());
+        TIZEN_CONSOLEE("%s", newMessage.utf8().data());
         break;
     case LogMessageLevel:
-        ALOG(LOG_DEBUG, "ConsoleMessage", "%s", newMessage.utf8().data());
+        TIZEN_CONSOLED("%s", newMessage.utf8().data());
         break;
     default:
-        ALOG(LOG_INFO, "ConsoleMessage", "%s", newMessage.utf8().data());
+        TIZEN_CONSOLEI("%s", newMessage.utf8().data());
         break;
     }
 #endif
@@ -485,6 +491,10 @@ void WebChromeClient::scroll(const IntSize& scrollOffset, const IntRect& scrollR
 void WebChromeClient::delegatedScrollRequested(const IntPoint& scrollOffset)
 {
     m_page->pageDidRequestScroll(scrollOffset);
+
+#if OS(TIZEN)
+    m_page->didChangeContents(m_page->bounds());
+#endif
 }
 #endif
 
@@ -504,6 +514,19 @@ PlatformPageClient WebChromeClient::platformPageClient() const
     return 0;
 }
 
+#if ENABLE(TIZEN_VIEWPORT_META_TAG)
+bool WebChromeClient::canContentsSizeChange(Frame* frame, const IntSize& size) const
+{
+    // FIXME1: This patch should be removed AS SOON AS unexpected layout change problem is fixed.
+    // A page on naver isn't fitted when device is moved from landscape to portrait.
+    String url = frame->document()->url().string();
+    if (url.startsWith("https://nid.naver.com/user"))
+        return false;
+
+    return true;
+}
+#endif
+
 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
 bool WebChromeClient::getStandaloneStatus()
 {
@@ -660,11 +683,31 @@ void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& database
 
     DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(databaseName, origin);
     uint64_t currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin);
+
+#if ENABLE(TIZEN_SQL_DATABASE)
+    uint64_t newQuota = 0;
+    const uint64_t defaultQuota = 5 * 1024 * 1024;
+    uint64_t requirement = currentQuota + details.expectedUsage();
+    if (requirement <= defaultQuota)
+        newQuota = requirement;
+    else {
+        unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
+        bool allowExceed = false;
+        WebProcess::shared().connection()->sendSync(
+            Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), details.displayName(), details.expectedUsage()),
+            Messages::WebPageProxy::ExceededDatabaseQuota::Reply(allowExceed), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags);
+        if (allowExceed)
+            newQuota = currentQuota + details.expectedUsage();
+        else
+            newQuota = currentQuota;
+    }
+#else
     uint64_t currentOriginUsage = DatabaseTracker::tracker().usageForOrigin(origin);
     uint64_t newQuota = 0;
     WebProcess::shared().connection()->sendSync(
         Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()),
         Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID());
+#endif
 
     DatabaseTracker::tracker().setQuota(origin, newQuota);
 }
@@ -681,6 +724,25 @@ void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_
     notImplemented();
 }
 
+#if ENABLE(TIZEN_APPLICATION_CACHE)
+bool WebChromeClient::requestApplicationCachePermission(Frame* frame)
+{
+    WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
+    SecurityOrigin* origin = frame->document()->securityOrigin();
+
+    unsigned syncSendFlags = WebCore::AXObjectCache::accessibilityEnabled() ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
+    bool allow = false;
+#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
+    WebProcess::WaitForJavaScriptPopupFinished waiting;
+#endif
+
+    if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RequestApplicationCachePermission(webFrame->frameID(), origin->databaseIdentifier()), Messages::WebPageProxy::RequestApplicationCachePermission::Reply(allow), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
+        return false;
+
+    return allow;
+}
+#endif
+
 #if ENABLE(DASHBOARD_SUPPORT)
 void WebChromeClient::dashboardRegionsChanged()
 {
@@ -736,8 +798,13 @@ PassOwnPtr<ColorChooser> WebChromeClient::createColorChooser(ColorChooserClient*
 
 void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
 {
+#if OS(TIZEN)
+    if (m_page->activeOpenPanelResultListener())
+        m_page->cancelForOpenPanel();
+#else
     if (m_page->activeOpenPanelResultListener())
         return;
+#endif
 
     RefPtr<FileChooser> fileChooser = prpFileChooser;
 
@@ -964,11 +1031,60 @@ float WebChromeClient::contentsScaleFactor() const
 }
 #endif
 
-#if ENABLE(TIZEN_SCREEN_READER)
+#if OS(TIZEN)
 void WebChromeClient::rendererWillBeDestroyed(RenderObject* object)
 {
+#if ENABLE(TIZEN_SCREEN_READER)
     m_page->updateScreenReaderFocus(object);
+#endif
+
+#if ENABLE(TIZEN_ISF_PORT)
+    if (object->node() && object->node()->isRootEditableElement())
+        m_page->send(Messages::WebPageProxy::RemoveInputMethodContext(reinterpret_cast<uintptr_t>(object->node())));
+#endif
+}
+#endif
+
+#if ENABLE(TIZEN_INDEXED_DATABASE)
+bool WebChromeClient::exceededIndexedDatabaseQuota(Frame* frame, int64_t currentQuota)
+{
+    WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
+    SecurityOrigin* origin = frame->document()->securityOrigin();
+
+    unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
+    bool allow = false;
+#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
+    WebProcess::WaitForJavaScriptPopupFinished waiting;
+#endif
+    if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::ExceededIndexedDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), currentQuota), Messages::WebPageProxy::ExceededIndexedDatabaseQuota::Reply(allow), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
+        return false;
+
+    return allow;
 }
 #endif
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+bool WebChromeClient::exceededLocalFileSystemQuota(Frame* frame, int64_t currentQuota)
+{
+    WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
+    SecurityOrigin* origin = frame->document()->securityOrigin();
+
+    unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
+    bool result = false;
+#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
+    WebProcess::WaitForJavaScriptPopupFinished waiting;
+#endif
+    if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::ExceededLocalFileSystemQuota(webFrame->frameID(), origin->databaseIdentifier(), currentQuota), Messages::WebPageProxy::ExceededLocalFileSystemQuota::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
+        return false;
+
+    return result;
+}
+#endif
+
+#if ENABLE(TIZEN_WEBKIT2_NOTIFY_SUSPEND_BY_REMOTE_WEB_INSPECTOR)
+void WebChromeClient::setContentSuspendedByInspector(bool isSuspended)
+{
+    m_page->send(Messages::WebPageProxy::setContentSuspendedByInspector(isSuspended));
+}
+#endif
 } // namespace WebKit