[Release] wrt_0.8.226
[platform/framework/web/wrt.git] / src / view / webkit / injected-bundle / wrt-injected-bundle.cpp
index 1928ccd..2726d5a 100644 (file)
@@ -72,6 +72,7 @@
 // URI localization on WebProcess side
 #include "injected_bundle_uri_handling.h"
 #include "injected_bundle_decryption_support.h"
+#include "injected_bundle_viewmodes_support.h"
 
 namespace {
 const char * const SCHEME_HTTP = "http";
@@ -82,8 +83,6 @@ const char * const SCHEME_BOX_SLASH = "box://";
 const char * const BLANK_PAGE_URL = "about:blank";
 const char * const HTML_MIME = "text/html";
 const char * const PHP_MIME = "application/x-php";
-const char * const VIEWMODE_TYPE_FULLSCREEN = "fullscreen";
-const char * const VIEWMODE_TYPE_MAXIMIZED = "maximized";
 const std::size_t FILE_BUF_MAX_SIZE = 1024; // bytes
 const std::size_t PLAIN_CHUNK_SIZE = 1008; // bytes
 const unsigned int UID_ROOT = 0;
@@ -164,6 +163,7 @@ void Bundle::didCreatePage(WKBundlePageRef page)
     m_pagesList.push_back(page);
     m_pageGlobalContext.insertContextForPage(page, context);
     LogDebug("created Page : " << page << " created JSContext : " << context);
+    m_viewmodesSupport->initialize(page);
 
     WKBundlePageResourceLoadClient resourceLoadClient = {
         kWKBundlePageResourceLoadClientCurrentVersion,  /* version */
@@ -235,6 +235,7 @@ void Bundle::willDestroyPage(WKBundlePageRef page)
     m_pagesList.remove(page);
     m_pageGlobalContext.removeContextForPage(page);
     m_pageContext[page].erase(context);
+    m_viewmodesSupport->deinitialize(page);
 
     PluginModule::unloadFrame(context);
     PluginModule::stop(context);
@@ -485,6 +486,8 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
             bypassCORSforWARPAccessList(dao);
 #endif
             m_decryptionSupport->initialize(m_widgetTizenId);
+            m_viewmodesSupport.reset(
+                new InjectedBundle::ViewmodesSupport(m_widgetTizenId));
             m_initialized = true;
         } else {
             LogDebug("already initalized");
@@ -497,6 +500,18 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
                 toString(static_cast<WKStringRef>(messageBody));
             LogDebug("set x window handle [" << msgString << "]");
             IPCMessageSupport::setXwindowHandle(atoi(msgString.c_str()));
+    } else if (WKStringIsEqualToUTF8CString(
+                   messageName,
+                   Message::ToInjectedBundle::SET_VIEWMODES))
+    {
+        std::string msgBody =
+            toString(static_cast<WKStringRef>(messageBody));
+        LogDebug("set viewmode to [" << msgBody << "]");
+        if (msgBody == Message::ToInjectedBundle::SET_VIEWMODES_MSGBODY_EXIT) {
+            m_viewmodesSupport->exitViewmodesAllPages();
+        } else {
+            m_viewmodesSupport->enterViewmodesAllPages(msgBody);
+        }
     }
 }
 
@@ -523,21 +538,6 @@ void Bundle::didStartProvisionalLoadForFrameCallback(
     LogDebug("didStartProvisionalLoadForFrameCallback called");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
 
-    // set viewmode
-    WrtDB::WidgetDAOReadOnly dao(This->m_widgetTizenId);
-    WrtDB::WindowModeList modeList = dao.getWindowModes();
-    FOREACH(it, modeList) {
-        std::string viewMode = DPL::ToUTF8String(*it);
-        if (viewMode == VIEWMODE_TYPE_FULLSCREEN
-            || viewMode == VIEWMODE_TYPE_MAXIMIZED)
-        {
-            WKBundlePageSetViewMode(
-                page,
-                WKStringCreateWithUTF8CString(viewMode.c_str()));
-            break;
-        }
-    }
-
     if (This->m_pageGlobalContext.find(page) == This->m_pageGlobalContext.end()) {
         return;
     }
@@ -785,7 +785,7 @@ WKURLRequestRef Bundle::willSendRequestForFrame(WKURLRequestRef request)
     {
         if (logEnable){ LogDebug("external scheme return original WKURLRequestRef"); }
         WKRetain(request);
+
         return request;
     }
     else
@@ -803,11 +803,11 @@ WKURLRequestRef Bundle::willSendRequestForFrame(WKURLRequestRef request)
                 WKURLCreateWithUTF8CString(decryptString.c_str());
             WKURLRequestRef req = WKURLRequestCreateWithWKURL(destUrl);
             WKRelease(destUrl);
-            
+
             return req;
         }
     }
-    
+
     WKURLRef newUrl = WKURLCreateWithUTF8CString(localizedUrl.c_str());
     WKURLRequestRef req = WKURLRequestCreateWithWKURL(newUrl);
     WKRelease(newUrl);
@@ -855,12 +855,10 @@ WKBundlePagePolicyAction Bundle::decidePolicyForAction(
 
         // Send information about blocked URI to UIProcess
         WKStringRef urlStr = WKStringCreateWithUTF8CString(blockedUrl.c_str());
-        WKTypeRef retVal = NULL;
         WKStringRef blockMessage =
             WKStringCreateWithUTF8CString(Message::ToUIProcess::BLOCKED_URL);
-        WKBundlePostSynchronousMessage(m_bundle, blockMessage, urlStr, &retVal);
+        WKBundlePostMessage(m_bundle, blockMessage, urlStr);
         WKRelease(urlStr);
-        WKRelease(retVal);
         WKRelease(blockMessage);
         return WKBundlePagePolicyActionPassThrough;
     }
@@ -972,13 +970,11 @@ void Bundle::sendWebProcessPid()
     std::stringstream strPid;
     strPid << getpid();
     WKStringRef pidStr = WKStringCreateWithUTF8CString(strPid.str().c_str());
-    WKTypeRef retVal = NULL;
     WKStringRef message =
         WKStringCreateWithUTF8CString(
             Message::ToUIProcess::SEND_WEBPROCESS_PID);
-    WKBundlePostSynchronousMessage(m_bundle, message, pidStr, &retVal);
+    WKBundlePostMessage(m_bundle, message, pidStr);
     WKRelease(pidStr);
-    WKRelease(retVal);
     WKRelease(message);
 }
 #endif