[Release] livebox.web-provider-1.14 submit/tizen_2.1/20130430.032239
authorJihoon Chung <jihoon.chung@samsung.com>
Tue, 30 Apr 2013 03:18:59 +0000 (12:18 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Tue, 30 Apr 2013 03:21:45 +0000 (12:21 +0900)
Change-Id: Id8a055681f9822a387459f29869670a110a1e857

28 files changed:
data/web_provider_db.sql
packaging/livebox.web-provider.spec
src/API/web_provider_livebox_info.cpp
src/API/web_provider_livebox_info.h
src/Core/Box.cpp
src/Core/BoxSchemeHandler.cpp [changed mode: 0755->0644]
src/Core/BoxSchemeHandler.h
src/Core/IBox.h
src/Core/Service/CMakeLists.txt
src/Core/Service/MessageManager.cpp [new file with mode: 0644]
src/Core/Service/MessageManager.h [new file with mode: 0644]
src/Core/View/CMakeLists.txt
src/Core/View/IPdHelper.h
src/Core/View/IRenderView.h
src/Core/View/InjectedScript.h [deleted file]
src/Core/View/PdHelper.cpp
src/Core/View/PdHelper.h
src/Core/View/WebView.cpp
src/Core/View/injection.js [new file with mode: 0644]
src/Daemon/BoxDaemonImpl.cpp [changed mode: 0755->0644]
src/Plugin/AppBoxPlugin/AppBoxPdHelper.cpp [new file with mode: 0644]
src/Plugin/AppBoxPlugin/AppBoxPdHelper.h [new file with mode: 0644]
src/Plugin/AppBoxPlugin/AppBoxRenderBuffer.cpp
src/Plugin/AppBoxPlugin/AppBoxRenderView.cpp
src/Plugin/AppBoxPlugin/AppBoxRenderView.h
src/Plugin/AppBoxPlugin/AppPdHelper.cpp [deleted file]
src/Plugin/AppBoxPlugin/AppPdHelper.h [deleted file]
src/Plugin/AppBoxPlugin/CMakeLists.txt

index a304108..df1a0c5 100644 (file)
@@ -5,6 +5,7 @@ CREATE TABLE LiveboxInfo (
     box_type TEXT not null,
     auto_launch INT,
     mouse_event INT,
+    pd_fast_open INT,
     PRIMARY KEY (box_id) ,
 CHECK(1) );
 COMMIT;
index b1a14fe..e36f8bf 100644 (file)
@@ -1,6 +1,6 @@
 Name: livebox.web-provider
 Summary: web framework for livebox 
-Version: 1.12
+Version: 1.14
 Release: 1
 Group: main/app
 License: Flora License, Version 1.1
index 6e93a6d..cdddef7 100644 (file)
@@ -30,6 +30,7 @@ enum InfoTableField {
     BOX_TYPE,
     AUTO_LAUNCH,
     MOUSE_EVENT,
+    PD_FAST_OPEN,
 };
 
 // TODO this default type should be retrieved more automatically
@@ -164,12 +165,41 @@ int web_provider_livebox_get_mouse_event(const char* box_id)
     return mouseEvent;
 }
 
+int web_provider_livebox_get_pd_fast_open(const char* box_id)
+{
+    if (!box_id) {
+        return NULL;
+    }
+
+    std::shared_ptr<WebProviderDB> handle(new WebProviderDB());
+    if (!handle->openDB()) {
+        return NULL;
+    }
+
+    std::string query = "select * from " + infoTable + " where box_id = ?";
+    if (!handle->setCommand(query, "s", box_id)) {
+        handle->closeDB();
+        return NULL;
+    }
+
+    if (!handle->executeCommand()) {
+        handle->closeDB();
+        return NULL;
+    }
+
+    int pdFastOpen = handle->getInt(InfoTableField::PD_FAST_OPEN);
+    handle->closeDB();
+
+    return pdFastOpen;
+}
+
 int web_provider_livebox_insert_box_info(
         const char* box_id, 
         const char* app_id, 
         const char* box_type,
         int auto_launch,
-        int mouse_event)
+        int mouse_event,
+        int pd_fast_open)
 {
     if (!box_id || !app_id || !box_type) {
         return -1;
@@ -182,11 +212,12 @@ int web_provider_livebox_insert_box_info(
 
     std::string query = 
         "insert into " + infoTable + 
-        " (box_id, app_id, box_type, auto_launch, mouse_event) values (?,?,?,?,?)";
+        " (box_id, app_id, box_type, auto_launch, mouse_event, pd_fast_open) \
+         values (?,?,?,?,?,?)";
 
     if (!handle->setCommand(
-                query, "sssii", 
-                box_id, app_id, box_type, auto_launch, mouse_event)) {
+                query, "sssiii",
+                box_id, app_id, box_type, auto_launch, mouse_event, pd_fast_open)) {
         handle->closeDB();
         return -1;
     }
@@ -205,7 +236,7 @@ int web_provider_livebox_insert_box_type(
         const char* app_id,
         const char* box_type)
 {
-    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0);
+    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0, 0);
 }
 
 int web_provider_livebox_delete_by_box_id(const char* box_id)
@@ -307,7 +338,7 @@ int web_provider_info_insert_box_type(
         const char* app_id,
         const char* box_type)
 {
-    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0);
+    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0, 0);
 }
 
 int web_provider_info_delete_by_box_id(const char* box_id)
index 120b2c4..91951fc 100644 (file)
@@ -34,12 +34,14 @@ EXPORT_API const char* web_provider_livebox_get_box_type(const char* box_id);
 EXPORT_API const char* web_provider_livebox_get_app_id(const char* box_id);
 EXPORT_API int web_provider_livebox_get_auto_launch(const char* box_id);
 EXPORT_API int web_provider_livebox_get_mouse_event(const char* box_id);
+EXPORT_API int web_provider_livebox_get_pd_fast_open(const char* box_id);
 EXPORT_API int web_provider_livebox_insert_box_info(
         const char* box_id,
         const char* app_id,
         const char* box_type,
         int auto_launch, 
-        int mouse_event);
+        int mouse_event,
+        int pd_fast_open);
 DEPRECATED_API int web_provider_livebox_insert_box_type(
         const char* box_id,
         const char* app_id,
index 461ed0e..190a903 100644 (file)
@@ -124,6 +124,7 @@ bool Box::resize(int width, int height)
         RenderInfoPtr renderInfo = makeRenderInfo(renderTypeResize);
         m_view->showBox(renderInfo);
     } catch (...) {
+        LogD("resize exception");
         return false;
     }
 
old mode 100755 (executable)
new mode 100644 (file)
index 83cfa67..0b7c689
 #include "Service/AppControl.h"
 #include "Service/PeriodChanger.h"
 #include "Service/ScrollHolder.h"
+#include "Service/MessageManager.h"
 #include "Util/Log.h"
 #include "BoxSchemeHandler.h"
 
+using namespace Service;
+
 static const std::string BOX_SCHEME("box://");
 static const std::string BOX_SCHEME_RELOAD("box://reload");
 static const std::string BOX_SCHEME_CHANGE_PERIOD("box://change-period");
 static const std::string BOX_SCHEME_LAUNCH_BROWSER("box://launch-browser");
 static const std::string BOX_SCHEME_SCROLL_START("box://scroll-start");
 static const std::string BOX_SCHEME_SCROLL_STOP("box://scroll-stop");
+static const std::string BOX_SCHEME_SEND_MESSAGE_TO_PD("box://send-message-to-pd");
+static const std::string BOX_SCHEME_SEND_MESSAGE_TO_BOX("box://send-message-to-box");
 
 static const std::string HTTP_SCHEME("http://");
 static const std::string HTTPS_SCHEME("https://");
@@ -122,6 +127,25 @@ bool BoxSchemeHandler::process(std::string& instanceId, std::string& uri)
        return handleScroll(instanceId, false);
     }
 
+    if (!uri.compare(
+                0,
+                BOX_SCHEME_SEND_MESSAGE_TO_BOX.size(),
+                BOX_SCHEME_SEND_MESSAGE_TO_BOX))
+    {
+        std::string key("message");
+        std::string message = parse(uri, key);
+        return handleSendMessage(instanceId, MessageManager::TO_BOX, message);
+    }
+
+    if (!uri.compare(
+                0,
+                BOX_SCHEME_SEND_MESSAGE_TO_PD.size(),
+                BOX_SCHEME_SEND_MESSAGE_TO_PD))
+    {
+        std::string key("message");
+        std::string message = parse(uri, key);
+        return handleSendMessage(instanceId, MessageManager::TO_PD, message);
+    }
     LogD("unknown box scheme protocol");
     return false;
 }
@@ -198,8 +222,8 @@ bool BoxSchemeHandler::handleChangePeriod(std::string& instanceId, float request
 bool BoxSchemeHandler::handleLaunchBrowser(std::string& instanceId, std::string& url)
 {
     LogD("enter");
-    if(!url.compare(0, HTTP_SCHEME.size(), HTTP_SCHEME) ||
-       !url.compare(0, HTTPS_SCHEME.size(), HTTPS_SCHEME))
+    if (!url.compare(0, HTTP_SCHEME.size(), HTTP_SCHEME) ||
+        !url.compare(0, HTTPS_SCHEME.size(), HTTPS_SCHEME))
     {
         return Service::AppControl::launchBrowser(url);
     }
@@ -207,6 +231,35 @@ bool BoxSchemeHandler::handleLaunchBrowser(std::string& instanceId, std::string&
     return false;
 }
 
+bool BoxSchemeHandler::handleSendMessage(
+        std::string& instanceId, 
+        MessageManager::ReceiverType receiver, 
+        std::string& message)
+{
+    LogD("enter");
+    Box* box = getBox(instanceId);
+    if (!box) {
+        LogD("no box for update period");
+        return false;
+    };
+
+    // set webview of receiver
+    Evas_Object* webview;
+    switch (receiver) {
+    case MessageManager::TO_BOX:
+        webview = box->m_view->getBoxWebView();
+        break;
+    case MessageManager::TO_PD:
+        webview = box->m_view->getPdWebView();
+        break;
+    default:
+        LogD("not supported receiver");
+        return false;
+    }
+
+    return m_messageManager->send(webview, receiver, message); 
+}
+
 std::string BoxSchemeHandler::parse(std::string& uri, std::string& key)
 {
     LogD("enter");
index 4a86df9..96765d1 100644 (file)
 
 #include <string>
 #include <map>
+#include "Service/PeriodChanger.h"
+#include "Service/MessageManager.h"
 
-class Box;
+using namespace Service;
 
-namespace Service {
-class PeriodChanger;
-}
+class Box;
 
 #define EXPORT_CLASS __attribute__ ((visibility("default"))
 
@@ -45,6 +45,10 @@ class EXPORT_CLASS BoxSchemeHandler {
         bool handleChangePeriod(std::string& instanceId, float requestedPeriod = -1.0f);
         bool handleLaunchBrowser(std::string& instanceId, std::string& url);
         bool handleScroll(std::string& instanceId, bool start);
+        bool handleSendMessage(
+                std::string& instanceId, 
+                MessageManager::ReceiverType receiver, 
+                std::string& message);
         std::string parse(std::string& uri, std::string& key);
 
         BoxSchemeHandler();
@@ -55,7 +59,8 @@ class EXPORT_CLASS BoxSchemeHandler {
         typedef std::pair<std::string, Box*> BoxMapPair;
         BoxMap m_boxMap;
         // members for service
-        std::shared_ptr<Service::PeriodChanger> m_periodChanger;
+        std::shared_ptr<PeriodChanger> m_periodChanger;
+        std::shared_ptr<MessageManager> m_messageManager;
         static BoxSchemeHandler* s_instance;
 };
 
index 72b2c14..5feee10 100644 (file)
 #ifndef I_BOX_H
 #define I_BOX_H
 
+#include <ewk_view.h>
 #include <ewk_context.h>
 
 class IBox {
     public:
+        // functions for lifecycle
         virtual bool show() = 0;
         virtual bool hide() = 0;
         virtual bool resize(int width, int height) = 0;
@@ -32,6 +34,8 @@ class IBox {
         virtual bool openPd(int width, int height, double x, double y) = 0;
         virtual bool closePd() = 0;
         virtual bool update() = 0;
+
+        // functions for specific service
         virtual bool changePeriod(float period) = 0;
 
         //virtual IBox& operator=(const IBox& rhs) = 0;
index f9b4b85..baf5d5c 100644 (file)
@@ -33,6 +33,7 @@ SET(SRCS
     ${CMAKE_CURRENT_SOURCE_DIR}/AppControl.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/PeriodChanger.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/ScrollHolder.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/MessageManager.cpp
 )
 
 SET(HEADERS
@@ -61,3 +62,8 @@ TARGET_LINK_LIBRARIES(${TARGET_NAME}
 GET_FILENAME_COMPONENT(CURRENT_DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
 GET_FILENAME_COMPONENT(PARENT_DIR_ABSOLUTE_PATH ${CMAKE_CURRENT_SOURCE_DIR} PATH)
 GET_FILENAME_COMPONENT(PARENT_DIR_NAME ${PARENT_DIR_ABSOLUTE_PATH} NAME)
+
+INSTALL_FILE(PeriodChanger.h include/${PROJECT_NAME}/${PARENT_DIR_NAME}/${CURRENT_DIR_NAME})
+INSTALL_FILE(MessageManager.h include/${PROJECT_NAME}/${PARENT_DIR_NAME}/${CURRENT_DIR_NAME})
+INSTALL_FILE(ScrollHolder.h include/${PROJECT_NAME}/${PARENT_DIR_NAME}/${CURRENT_DIR_NAME})
+INSTALL_FILE(AppControl.h include/${PROJECT_NAME}/${PARENT_DIR_NAME}/${CURRENT_DIR_NAME})
diff --git a/src/Core/Service/MessageManager.cpp b/src/Core/Service/MessageManager.cpp
new file mode 100644 (file)
index 0000000..4e368d1
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Flora License, Version 1.1 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.tizenopensource.org/license
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    MessageMenager.h
+ * @author  Yunchan Cho (yunchan.cho@samsung.com)
+ */
+
+#include <string>
+#include <Evas.h>
+#include <ewk_view.h>
+#include <Core/Util/Log.h>
+#include "MessageManager.h"
+
+namespace Service {
+
+static const std::string jsFireWindowEventFunction("webprovider.fireAppWidgetEvent");
+static const std::string jsPdMessageEvent("pdmessage");
+static const std::string jsBoxMessageEvent("boxmessage");
+
+MessageManager::MessageManager()
+{
+    LogD("enter");
+}
+
+MessageManager::~MessageManager()
+{
+    LogD("enter");
+}
+
+bool MessageManager::send(Evas_Object* webview, ReceiverType receiver, std::string& message)
+{
+    LogD("enter");
+
+    std::string eventName;
+
+    // set message event name triggered by receiver
+    switch (receiver) {
+    case TO_BOX:
+        eventName = jsPdMessageEvent;
+        break;
+    case TO_PD:
+        eventName = jsBoxMessageEvent;
+        break;
+    default:
+        return false;
+    }
+
+    std::string script = jsFireWindowEventFunction;
+    script += "(\"";
+    script += eventName;
+    script += "\", \"";
+    script += message;
+    script +="\");";
+    LogD("calling javascript: %s", script.c_str());
+
+    // execute js code for sending message
+    ewk_view_script_execute(webview, script.c_str(), executeScriptCallback, this);
+
+    return true;
+}
+
+void MessageManager::executeScriptCallback(
+        Evas_Object* webview, const char* result, void* data)
+{
+    LogD("enter");
+    std::string resultStr(result ? result : "null");
+    LogD("result: %s", resultStr.c_str());
+}
+} // Service
diff --git a/src/Core/Service/MessageManager.h b/src/Core/Service/MessageManager.h
new file mode 100644 (file)
index 0000000..be41ab6
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Flora License, Version 1.1 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.tizenopensource.org/license
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    MessageManager.h
+ * @author  Yunchan Cho (yunchan.cho@samsung.com)
+ */
+
+#ifndef MESSAGE_MANAGER_H
+#define MESSAGE_MANAGER_H
+
+#include <string>
+#include <memory>
+#include <Evas.h>
+
+namespace Service {
+
+class MessageManager;
+typedef std::shared_ptr<MessageManager> MessageManagerPtr;
+
+class MessageManager {
+    public:
+        enum ReceiverType {
+            TO_BOX,
+            TO_PD
+        };
+
+        static MessageManagerPtr create() {
+            return MessageManagerPtr(new MessageManager());
+        }
+        bool send(Evas_Object* webview, ReceiverType receiver, std::string& message);
+        ~MessageManager();
+
+    private:
+        static void executeScriptCallback(
+                Evas_Object* webview, const char* result, void* data);
+        MessageManager();
+};
+} // Service
+
+#endif // MESSAGE_MANAGER_H
index 00df3d4..083a34b 100644 (file)
@@ -63,3 +63,4 @@ INSTALL_FILE(IPdHelper.h include/${PROJECT_NAME}/${PARENT_DIR_NAME}/${CURRENT_DI
 INSTALL_FILE(PdHelper.h include/${PROJECT_NAME}/${PARENT_DIR_NAME}/${CURRENT_DIR_NAME}) 
 INSTALL_FILE(IWebView.h include/${PROJECT_NAME}/${PARENT_DIR_NAME}/${CURRENT_DIR_NAME}) 
 INSTALL_FILE(WebView.h include/${PROJECT_NAME}/${PARENT_DIR_NAME}/${CURRENT_DIR_NAME}) 
+INSTALL_FILE(injection.js /usr/share/${PROJECT_NAME})
index 3a4faad..b2f7db9 100644 (file)
 #define I_PD_HELPER_H
 
 #include <Evas.h>
+#include <memory>
 
 class IPdHelper {
     public:
         virtual void startOpen() = 0;
-        virtual void finishOpen(Evas_Object*& child) = 0;
+        virtual void finishOpen(Evas_Object* child) = 0;
         virtual void close() = 0;
-        virtual void setBaseWebView(Evas_Object*& base) = 0;
-        virtual Evas_Object* getBaseWebView() const = 0;
+        virtual void setBoxWebView(Evas_Object* webview) = 0;
+        virtual void setPdWebView(Evas_Object* webview) = 0;
+        virtual Evas_Object* getBoxWebView() const = 0;
+        virtual Evas_Object* getPdWebView() const = 0;
         virtual Evas* getPdCanvas() const = 0;
         virtual bool isPdOpened() const = 0;
 };
index efacbc9..6a4dec3 100644 (file)
@@ -43,6 +43,8 @@ class IRenderView {
         virtual void resumeBox() = 0;
         virtual void showPd(Evas_Object* pdWin, RenderInfoPtr renderInfo) = 0;
         virtual void hidePd() = 0;
+        virtual Evas_Object* getBoxWebView() = 0;
+        virtual Evas_Object* getPdWebView() = 0;
         virtual ~IRenderView() {};
 };
 typedef std::shared_ptr<IRenderView> IRenderViewPtr;
diff --git a/src/Core/View/InjectedScript.h b/src/Core/View/InjectedScript.h
deleted file mode 100644 (file)
index ad00390..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Flora License, Version 1.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://floralicense.org/license/
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/**
- * @file    InjectedScript.h
- * @author  Yunchan Cho (yunchan.cho@samsung.com)
- */
-
-#define INJECTED_SCRIPT                                                     \
-       "                                                                    \
-       function reload() {                                                  \
-           window.location.href=\"box://reload\";                           \
-       }                                                                    \
-       function changePeriod(period) {                                      \
-           switch (arguments.length) {                                      \
-               case 0:                                                      \
-                    window.location.href=\"box://change-period\";           \
-                    break;                                                  \
-               case 1:                                                      \
-                    window.location.href=\"box://change-period?period=\" + period;                    \
-                    break;                                                  \
-                default:                                                    \
-                    window.location.href=\"box://change-period\";           \
-                    break;                                                  \
-           }                                                                \
-       }                                                                    \
-       function launchBrowser(url) {                                        \
-           window.location.href=\"box://launch-browser?url=\" + url;        \
-       }                                                                    \
-       function scrollStart(){                                              \
-           window.location.href=\"box://scroll-start\";                     \
-       }                                                                    \
-       function scrollStop(){                                               \
-           window.location.href=\"box://scroll-stop\";                      \
-       }                                                                    \
-       window.tizen = new Object();                                         \
-       window.tizen.appwidget = new Object();                               \
-       window.tizen.appwidget.reload = reload;                              \
-       window.tizen.appwidget.changePeriod = changePeriod;                  \
-       window.tizen.appwidget.launchBrowser = launchBrowser;                \
-       window.tizen.appwidget.scrollStart = scrollStart;                    \
-       window.tizen.appwidget.scrollStop = scrollStop;                      \
-       "
index 0e425ec..00b8f44 100644 (file)
@@ -27,7 +27,7 @@
 
 PdHelper::PdHelper(Evas_Object* pdWin, std::string pdStartUrl, RenderInfoPtr pdRenderInfo)
     : m_win(pdWin)
-    , m_baseWebView()
+    , m_boxWebView()
     , m_pdWebView()
     , m_startUrl(pdStartUrl)
     , m_renderInfo(pdRenderInfo)
@@ -42,7 +42,7 @@ PdHelper::~PdHelper()
 void PdHelper::startOpen()
 {
     LogD("enter");
-    if (!m_baseWebView) {
+    if (!m_boxWebView) {
         return;
     }
 
@@ -54,10 +54,10 @@ void PdHelper::startOpen()
     // execute javascript for opening new webview for pd
     LogD("executed script: %s", script.c_str());
     ewk_view_script_execute(
-            m_baseWebView, script.c_str(), executeScriptCallback, this);
+            m_boxWebView, script.c_str(), executeScriptCallback, this);
 }
 
-void PdHelper::finishOpen(Evas_Object*& child)
+void PdHelper::finishOpen(Evas_Object* child)
 {
     LogD("enter");
 
@@ -73,16 +73,28 @@ void PdHelper::close()
     evas_object_del(m_pdWebView);
 }
 
-void PdHelper::setBaseWebView(Evas_Object*& parent)
+void PdHelper::setBoxWebView(Evas_Object* webview)
 {
     LogD("enter");
-    m_baseWebView = parent;
+    m_boxWebView = webview;
 }
 
-Evas_Object* PdHelper::getBaseWebView() const
+void PdHelper::setPdWebView(Evas_Object* webview)
 {
     LogD("enter");
-    return m_baseWebView;
+    m_pdWebView = webview;
+}
+
+Evas_Object* PdHelper::getBoxWebView() const
+{
+    LogD("enter");
+    return m_boxWebView;
+}
+
+Evas_Object* PdHelper::getPdWebView() const
+{
+    LogD("enter");
+    return m_pdWebView;
 }
 
 Evas* PdHelper::getPdCanvas() const  
index c2de92e..16d74ed 100644 (file)
@@ -19,6 +19,9 @@
  * @author  Yunchan Cho (yunchan.cho@samsung.com)
  */
 
+#ifndef PD_HELPER_H
+#define PD_HELPER_H
+
 #include <string>
 #include <Evas.h>
 #include "IRenderView.h"
@@ -36,10 +39,12 @@ class EXPORT_CLASS PdHelper: public IPdHelper {
             return IPdHelperPtr(new PdHelper(pdWin, pdStartUrl, pdRenderInfo));
         }
         virtual void startOpen();
-        virtual void finishOpen(Evas_Object*& child);
+        virtual void finishOpen(Evas_Object* child);
         virtual void close();
-        virtual void setBaseWebView(Evas_Object*& parent);
-        virtual Evas_Object* getBaseWebView() const;
+        virtual void setBoxWebView(Evas_Object* webview);
+        virtual void setPdWebView(Evas_Object* webview);
+        virtual Evas_Object* getBoxWebView() const;
+        virtual Evas_Object* getPdWebView() const;
         virtual Evas* getPdCanvas() const;
         virtual bool isPdOpened() const;
         virtual ~PdHelper();
@@ -55,9 +60,12 @@ class EXPORT_CLASS PdHelper: public IPdHelper {
 
         //members
         Evas_Object* m_win;
-        Evas_Object* m_baseWebView;
+        Evas_Object* m_boxWebView;
         Evas_Object* m_pdWebView;
         std::string m_startUrl;
         RenderInfoPtr m_renderInfo;
         bool m_opened;
 };
+
+#endif // PD_HELPER_H
+
index 8e16ee5..2241906 100644 (file)
  * @author  Yunchan Cho (yunchan.cho@samsung.com)
  */
 #include <string>
+#include <fstream>
+#include <streambuf>
 #include <Evas.h>
 #include <Eina.h>
 #include <ewk_context.h>
 #include <ewk_view.h>
 #include <Core/Util/Log.h>
-#include "InjectedScript.h"
 #include "WebView.h"
 
+// injection javascript file regarding creating js object used by box and pd
+static const std::string injectionFile("/usr/share/web-provider/injection.js");
+
 std::map<const std::string, const Evas_Smart_Cb> WebView::m_smartCallbacksMap =
 {
     {"load,started", WebView::loadStartedCallback},
@@ -217,8 +221,13 @@ void WebView::loadStartedCallback(
     LogD("enter");
 
     WebView* This = static_cast<WebView*>(data);
-    const char* injectedScript = INJECTED_SCRIPT;
-    ewk_view_script_execute(obj, injectedScript, executeScriptCallback, This);
+
+    std::ifstream jsFile(injectionFile);
+    std::string script((std::istreambuf_iterator<char>(jsFile)),
+                        std::istreambuf_iterator<char>());
+    LogD("injected js code: %s", script.c_str());
+
+    ewk_view_script_execute(obj, script.c_str(), executeScriptCallback, This);
     This->didLoadStarted(obj);
 }
 
diff --git a/src/Core/View/injection.js b/src/Core/View/injection.js
new file mode 100644 (file)
index 0000000..1d8cc54
--- /dev/null
@@ -0,0 +1,106 @@
+// set javascript objects for Web APIs of Tizen appwidget
+if (typeof window.tizen == 'undefined') {
+    console.log("window.tizen object not exists");
+    window.tizen = new Object();
+    window.tizen.appwidget = new Object();
+}
+
+// For future, only window.appwidget will be used
+window.appwidget = new Object();
+
+// these are functions for overriding standard javascript functions regarding event
+var original_addEventListener = window.addEventListener;
+var original_removeEventListener = window.removeEventListener;
+
+// this variable is responsible to keep information of appwidget evetns
+var appWidgetEvents = {};
+
+// define event structure for appwidget
+window.AppWidgetEventInfo = function(event, callback) {
+    this.event = event;
+    this.callback = callback;
+};
+
+window.addEventListener = function(event, callback, capture) {
+    var e = event.toLowerCase();
+    if (typeof appWidgetEvents[e] != 'undefined') {
+        appWidgetEvents[e].callback = callback;
+    } else {
+        original_addEventListener.call(window, event, callback, capture);
+    }
+};
+
+window.removeEventListener = function(event, callback, capture) {
+    var e = event.toLowerCase();
+    if (typeof appWidgetEvents[e] != "undefined") {
+        appWidgetEvents[e].callback = "null";
+    } else {
+        original_removeEventListener.call(window, event, callback, capture);
+    }
+};
+
+window.appwidget.sendMessageToBox = function(message) {
+    window.location.href = "box://send-message-to-box?message=" + message;
+}
+
+window.appwidget.sendMessageToPd = function(message) {
+    window.location.href = "box://send-message-to-pd?message=" + message;
+}
+
+var webprovider = {
+    // define specific function for registering appwidget event
+    registerAppWidgetEvent: function(event) {
+        return (appWidgetEvents[event] = new AppWidgetEventInfo(event, "null"));
+    },
+
+    // define specific function for firing registered appwidget event
+    fireAppWidgetEvent: function(event, data) {
+        // this is called by web-provider, which is native code
+        if (typeof appWidgetEvents[event] != 'undefined') {
+            setTimeout(function() {
+                appWidgetEvents[event].callback(data);
+            }, 0);
+            console.log("fire appwidget event: " + event);
+        } else {
+            console.log("unknown appwidget event: " + event);
+        }
+    },
+}
+
+// register custom events for appwidget
+webprovider.registerAppWidgetEvent("pdmessage");
+webprovider.registerAppWidgetEvent("boxmessage");
+
+// Define appwidget APIs
+// window.tizen.appwidget should be changed to window.appwidget
+//
+//
+window.tizen.appwidget.reload = function() {
+    window.location.href = "box://reload";
+}
+
+window.tizen.appwidget.changePeriod = function(period) {
+    switch (arguments.length) {
+    case 0:
+        window.location.href = "box://change-period";
+        break;
+    case 1:
+        window.location.href = "box://change-period?period=" + period;
+        break;
+    default:
+        window.location.href = "box://change-period";
+        break;
+    }
+}
+
+window.tizen.appwidget.launchBrowser = function(url) {
+    window.location.href = "box://launch-browser?url=" + url;
+}
+
+window.tizen.appwidget.scrollStart = function() {
+    window.location.href = "box://scroll-start";
+}
+
+window.tizen.appwidget.scrollStop = function() {
+    window.location.href = "box://scroll-stop";
+}
old mode 100755 (executable)
new mode 100644 (file)
index 2061482..9d0083f
@@ -144,7 +144,7 @@ int BoxDaemonImpl::boxCreateCallback(
     LogD("InstanceId: %s", info->instanceId.c_str());
     LogD("width: %d", info->boxWidth);
     LogD("height: %d", info->boxHeight);
-    LogD("update period: %d", info->period);
+    LogD("update period: %f", info->period);
     LogD("--------------------------------------------");
 
     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_ADD_BOX, info, This);
diff --git a/src/Plugin/AppBoxPlugin/AppBoxPdHelper.cpp b/src/Plugin/AppBoxPlugin/AppBoxPdHelper.cpp
new file mode 100644 (file)
index 0000000..21c71e4
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Flora License, Version 1.1 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://floralicense.org/license/
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    AppBoxPdHelper.cpp
+ * @author  Yunchan Cho (yunchan.cho@samsung.com)
+ */
+#include <string>
+#include <Evas.h>
+#include <ewk_view.h>
+#include <Core/Util/Log.h>
+#include "AppBoxPdHelper.h"
+
+AppBoxPdHelper::AppBoxPdHelper(Evas_Object* pdWin)
+    : m_win(pdWin)
+    , m_boxWebView()
+    , m_pdWebView()
+    , m_opened(false)
+{
+}
+
+AppBoxPdHelper::~AppBoxPdHelper()
+{
+}
+
+void AppBoxPdHelper::startOpen()
+{
+    LogD("enter");
+}
+
+void AppBoxPdHelper::finishOpen(Evas_Object* child)
+{
+    LogD("enter");
+    m_opened = true;
+    setPdWebView(child);
+}
+
+void AppBoxPdHelper::close()
+{
+    LogD("enter");
+}
+
+void AppBoxPdHelper::setBoxWebView(Evas_Object* webview)
+{
+    LogD("enter");
+    m_boxWebView = webview;
+}
+
+void AppBoxPdHelper::setPdWebView(Evas_Object* webview)
+{
+    LogD("enter");
+    m_pdWebView = webview;
+}
+
+Evas_Object* AppBoxPdHelper::getBoxWebView() const
+{
+    LogD("enter");
+    return m_boxWebView;
+}
+
+Evas_Object* AppBoxPdHelper::getPdWebView() const
+{
+    LogD("enter");
+    return m_pdWebView;
+}
+
+Evas* AppBoxPdHelper::getPdCanvas() const  
+{
+    LogD("enter");
+    evas_object_evas_get(m_win);
+}
+
+bool AppBoxPdHelper::isPdOpened() const
+{
+    LogD("enter");
+    return m_opened;
+}
diff --git a/src/Plugin/AppBoxPlugin/AppBoxPdHelper.h b/src/Plugin/AppBoxPlugin/AppBoxPdHelper.h
new file mode 100644 (file)
index 0000000..ae49863
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Flora License, Version 1.1 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://floralicense.org/license/
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    AppBoxPdHelper.h
+ * @author  Yunchan Cho (yunchan.cho@samsung.com)
+ */
+
+#ifndef APP_BOX_PD_HELPER_H
+#define APP_BOX_PD_HELPER_H
+
+#include <string>
+#include <Evas.h>
+#include <Core/View/IPdHelper.h>
+
+class AppBoxPdHelper: public IPdHelper {
+    public:
+        static IPdHelperPtr create(Evas_Object* pdWin)
+        {
+            return IPdHelperPtr(new AppBoxPdHelper(pdWin));
+        }
+        virtual void startOpen();
+        virtual void finishOpen(Evas_Object* child);
+        virtual void close();
+        virtual void setBoxWebView(Evas_Object* webview);
+        virtual void setPdWebView(Evas_Object* webview);
+        virtual Evas_Object* getBoxWebView() const;
+        virtual Evas_Object* getPdWebView() const;
+        virtual Evas* getPdCanvas() const;
+        virtual bool isPdOpened() const;
+        virtual ~AppBoxPdHelper();
+
+    private:
+        AppBoxPdHelper(Evas_Object* pdWin);
+
+        //members
+        Evas_Object* m_win;
+        Evas_Object* m_boxWebView;
+        Evas_Object* m_pdWebView;
+        bool m_opened;
+};
+
+#endif // APP_BOX_PD_HELPER_H
index ce27a6c..5456926 100644 (file)
@@ -61,7 +61,7 @@ void AppBoxRenderBuffer::didHandleTouchEvent(
 
     m_renderView = AppBoxObserver::Instance()->getRenderView(m_instanceId);
 
-    if (!m_renderView || !(m_renderView->m_view)) {
+    if (!m_renderView || !(m_renderView->m_boxWrt)) {
         LogD("no matched render view");
         return;
     }
@@ -72,7 +72,7 @@ void AppBoxRenderBuffer::didHandleTouchEvent(
     } else {
         if (!m_touchTimer) {
             startCanvasUpdate();
-            m_renderView->m_view->Resume();
+            m_renderView->m_boxWrt->Resume();
         } else {
             deleteTouchTimer();
         }
@@ -96,7 +96,7 @@ Eina_Bool AppBoxRenderBuffer::fireTouchTimerCallback(void* data)
     LogD("enter");
     AppBoxRenderBuffer* This = static_cast<AppBoxRenderBuffer*>(data); 
     This->stopCanvasUpdate();
-    This->m_renderView->m_view->Suspend();
+    This->m_renderView->m_boxWrt->Suspend();
     This->m_touchTimer = NULL;
 
     return ECORE_CALLBACK_CANCEL;
index bf9cce9..3602bb1 100644 (file)
  * @author  Yunchan Cho (yunchan.cho@samsung.com)
  */
 #include <string>
+#include <fstream>
+#include <streambuf>
 #include <Eina.h>
 #include <Evas.h>
 #include <Ecore.h>
+#include <ewk_view.h>
+#include <ewk_context.h>
 #include <livebox-service.h>
 #include <i_runnable_widget_object.h>
 #include <core_module.h>
 #include <dpl/fast_delegate.h>
+#include <Core/BoxSchemeHandler.h>
 #include <Core/View/IRenderView.h>
 #include <Core/View/IPdHelper.h>
 #include <Core/View/PdHelper.h>
 #include <Core/Util/Log.h>
 #include "AppBoxObserver.h"
 #include "AppBoxRenderBuffer.h"
+#include "AppBoxPdHelper.h"
 #include "AppBoxRenderView.h"
 
 #define RENDER_MAX_TIME 10.0
 
+// injection javascript file regarding creating js object used by box and pd
+static const std::string injectionFile("/usr/share/web-provider/injection.js");
+
 AppBoxRenderView::AppBoxRenderView(
         std::string boxId, std::string instanceId,
         Evas_Object* boxWin, EwkContextPtr ewkContext)
@@ -43,14 +52,15 @@ AppBoxRenderView::AppBoxRenderView(
     , m_boxId(boxId)
     , m_instanceId(instanceId)
     , m_boxWin(boxWin)
-    , m_baseWebView()
     , m_snapshot()
     , m_renderInfo()
-    , m_view()
-    , m_startUrl()
+    , m_boxWrt()
+    , m_pdWrt()
     , m_fireRenderTimer()
     , m_pdHelper()
+    , m_pdFastOpen(false)
     , m_ewkContext(ewkContext)
+    , m_renderBuffer()
 {
     LogD("enter");
     m_appId = getAppId(m_boxId);
@@ -60,6 +70,7 @@ AppBoxRenderView::AppBoxRenderView(
 
     evas_object_show(m_boxWin);
     m_renderBuffer = AppBoxObserver::Instance()->getRenderBuffer(m_instanceId);
+    m_pdFastOpen = web_provider_livebox_get_pd_fast_open(m_boxId.c_str()) ? true : false;
     AppBoxObserver::Instance()->registerRenderView(m_instanceId, this);
 }
 
@@ -83,53 +94,49 @@ void AppBoxRenderView::showBox(RenderInfoPtr renderInfo)
     }
 
     // copy to url
-    m_startUrl = getStartUrl(URL_TYPE_BOX, renderInfo->defaultUrlParams);
-
-    if (!createView()) {
-        LogD("can't create view instance");
-        return;
+    std::string boxStartUrl = getStartUrl(URL_TYPE_BOX, renderInfo->defaultUrlParams);
+    if (m_boxWrt) {
+        LogD("existing wrt core is removed");
+        destroyWrtCore(m_boxWrt);
     }
 
+    m_boxWrt = createWrtCore(boxStartUrl, m_boxWin, m_ewkContext); 
+
     // in case of showing box by request of pd open
     if (m_pdHelper) {
-        m_pdHelper->setBaseWebView(m_baseWebView);
+        m_pdHelper->setBoxWebView(m_boxWrt->GetCurrentWebview());
     }
 
     // resize webview fitted to width, height of Box
     evas_object_resize(
-            m_baseWebView
+            m_boxWrt->GetCurrentWebview()
             renderInfo->width,
             renderInfo->height);
 
-    clearSnapShot();
-    m_renderBuffer->startCanvasUpdate();
-    m_view->Show();
+    m_boxWrt->Show();
     m_renderInfo = renderInfo;
 }
 
-bool AppBoxRenderView::createView()
+AppBoxRenderView::WrtCorePtr AppBoxRenderView::createWrtCore(
+        std::string& startUrl, Evas_Object* win, EwkContextPtr ewkContext)
 {
     LogD("enter");
     
-    if (m_view) {
-        m_view->Hide();
-        m_view.reset();
-        m_baseWebView = NULL;
-    }
+    WrtCorePtr wrt;
 #ifdef MULTIPROCESS_SERVICE_SUPPORT
-    m_view = WRT::CoreModuleSingleton::
+    wrt = WRT::CoreModuleSingleton::
                 Instance().getRunnableWidgetObject(m_appId, DPL::Optional<unsigned>());
 #else
-    m_view = WRT::CoreModuleSingleton::
+    wrt = WRT::CoreModuleSingleton::
                 Instance().getRunnableWidgetObject(m_appId);
 #endif
     // prepare webview
-    if (m_startUrl.empty()) {
+    if (startUrl.empty()) {
         LogD("no start url");
-        return false;
+        return WrtCorePtr();
     }
-    m_view->PrepareView(m_startUrl, m_boxWin, m_ewkContext.get());
-    m_view->CheckBeforeLaunch();
+    wrt->PrepareView(startUrl, win, ewkContext.get());
+    wrt->CheckBeforeLaunch();
 
     // set callback functions of RunnableWidgetObject
     WRT::UserDelegatesPtr cbs(new WRT::UserDelegates);
@@ -137,38 +144,55 @@ bool AppBoxRenderView::createView()
     cbs->loadFinish = DPL::MakeDelegate(this, &AppBoxRenderView::finishLoadCallback);
     cbs->bufferSet = DPL::MakeDelegate(this, &AppBoxRenderView::setBufferCallback);
     cbs->bufferUnset = DPL::MakeDelegate(this, &AppBoxRenderView::unsetBufferCallback);
-    cbs->windowCreateBefore = DPL::MakeDelegate(this, &AppBoxRenderView::createWindowBeforeCallback);
-    cbs->windowCreateAfter = DPL::MakeDelegate(this, &AppBoxRenderView::createWindowAfterCallback);
-    m_view->SetUserDelegates(cbs);
+    if (!m_pdFastOpen) {
+        cbs->windowCreateBefore =
+            DPL::MakeDelegate(this, &AppBoxRenderView::createWindowBeforeCallback);
+        cbs->windowCreateAfter =
+            DPL::MakeDelegate(this, &AppBoxRenderView::createWindowAfterCallback);
+    }
 
-    // set base webview
-    m_baseWebView = m_view->GetCurrentWebview();
+    cbs->navigationDecide =
+        DPL::MakeDelegate(this, &AppBoxRenderView::decideNavigationCallback);
+    wrt->SetUserDelegates(cbs);
 
     // To support transparent background
-    evas_object_color_set(m_baseWebView, 0, 0, 0, 0);
-    evas_object_layer_set(m_baseWebView, EVAS_LAYER_MAX);
-    return true;
+    evas_object_color_set(wrt->GetCurrentWebview(), 0, 0, 0, 0);
+    evas_object_layer_set(wrt->GetCurrentWebview(), EVAS_LAYER_MAX);
+
+    return wrt;
 }
 
-bool AppBoxRenderView::destroyView()
+void AppBoxRenderView::destroyBoxWrtCore()
 {
     LogD("enter");
 
     m_renderBuffer->stopCanvasUpdate();
     deleteRenderTimer();
-    if (m_view) {
-        m_view->Hide();
-        m_view.reset();
-        m_baseWebView = NULL;
-    }
+    destroyWrtCore(m_boxWrt);
+    m_boxWrt.reset();
+}
+
+void AppBoxRenderView::destroyPdWrtCore()
+{
+    LogD("enter");
+
+    destroyWrtCore(m_pdWrt);
+    m_pdWrt.reset();
+}
+
+void AppBoxRenderView::destroyWrtCore(WrtCorePtr wrt)
+{
+    LogD("enter");
 
-    return true;
+    if (wrt) {
+        wrt->Hide();
+    }
 }
 
 void AppBoxRenderView::hideBox()
 {
     LogD("enter");
-    destroyView();
+    destroyBoxWrtCore();
 }
 
 void AppBoxRenderView::pauseBox()
@@ -187,7 +211,27 @@ void AppBoxRenderView::showPd(Evas_Object* pdWin, RenderInfoPtr renderInfo)
 
     // create pd helper
     std::string pdStartUrl = getStartUrl(URL_TYPE_PD, renderInfo->defaultUrlParams);
-    m_pdHelper = PdHelper::create(pdWin, pdStartUrl, renderInfo);
+    if (m_pdFastOpen) {
+        destroyPdWrtCore();
+        // if needed, last param regarding ewk context can be set to new one.
+        m_pdWrt = createWrtCore(pdStartUrl, pdWin, m_ewkContext);
+        if (!m_pdWrt) {
+            LogD("no wrt core instance");
+            return;
+        }
+        m_pdHelper = AppBoxPdHelper::create(pdWin);
+
+        // resize webview fitted to width, height of pd
+        evas_object_resize(
+                m_pdWrt->GetCurrentWebview(), 
+                renderInfo->width,
+                renderInfo->height);
+        // show pd
+        m_pdWrt->Show();
+        m_pdHelper->finishOpen(m_pdWrt->GetCurrentWebview());
+    } else {
+        m_pdHelper = PdHelper::create(pdWin, pdStartUrl, renderInfo);
+    }
 
     // show pd window
     evas_object_show(pdWin);
@@ -198,6 +242,9 @@ void AppBoxRenderView::hidePd()
 {
     LogD("enter");
 
+    if (m_pdFastOpen) {
+        destroyPdWrtCore();
+    }
     m_pdHelper->close();
     m_pdHelper.reset();
 
@@ -205,6 +252,20 @@ void AppBoxRenderView::hidePd()
     addRenderTimer();
 }
 
+Evas_Object* AppBoxRenderView::getBoxWebView()
+{
+    return m_boxWrt->GetCurrentWebview();
+}
+
+Evas_Object* AppBoxRenderView::getPdWebView()
+{
+    if (!m_pdHelper) {
+        return NULL;
+    }
+
+    return m_pdHelper->getPdWebView();
+}
+
 std::string AppBoxRenderView::getAppId(std::string& boxId)
 {
     LogD("enter");
@@ -292,13 +353,13 @@ Eina_Bool AppBoxRenderView::fireRenderTimerCallback(void* data)
     if (web_provider_livebox_get_mouse_event(This->m_boxId.c_str())) {
         // stop touch timer
         This->m_renderBuffer->deleteTouchTimer();
-        This->m_view->Suspend();
+        This->m_boxWrt->Suspend();
     } else {
         // Before webview should be removed,
         // new evas object with last render data should be created
         // otherwise, after webview is removed, box is white screen.
         evas_object_show(This->getCurrentSnapShot());
-        This->destroyView();
+        This->destroyBoxWrtCore();
     }
 
     return ECORE_CALLBACK_CANCEL;
@@ -314,10 +375,25 @@ Eina_Bool AppBoxRenderView::openPdIdlerCallback(void* data)
     return ECORE_CALLBACK_CANCEL;
 }
 
+void AppBoxRenderView::executeScriptCallback(
+        Evas_Object* webview, const char* result, void* data)
+{
+    LogD("enter");
+    std::string resultStr(result ? result : "null");
+    LogD("result: %s", resultStr.c_str());
+}
 
 void AppBoxRenderView::startLoadCallback(Evas_Object* webview)
 {
-    // start load
+    LogD("enter");
+    m_renderBuffer->startCanvasUpdate();
+    // execute injection for creating js objects
+    std::ifstream jsFile(injectionFile);
+    std::string script((std::istreambuf_iterator<char>(jsFile)),
+                        std::istreambuf_iterator<char>());
+
+    LogD("injected js code: %s", script.c_str());
+    ewk_view_script_execute(webview, script.c_str(), executeScriptCallback, this);
 }
 
 void AppBoxRenderView::finishLoadCallback(Evas_Object* webview)
@@ -329,11 +405,13 @@ void AppBoxRenderView::finishLoadCallback(Evas_Object* webview)
         // start render timer
         addRenderTimer();
     } else {
-        if (!(m_pdHelper->isPdOpened()) && 
-                webview == m_pdHelper->getBaseWebView())
-        {
-            // open pd
-            ecore_idler_add(openPdIdlerCallback, this);
+        if (!m_pdFastOpen) {
+            if (!(m_pdHelper->isPdOpened()) && 
+                    webview == m_pdHelper->getBoxWebView())
+            {
+                // open pd
+                ecore_idler_add(openPdIdlerCallback, this);
+            }
         }
     }
 }
@@ -344,13 +422,13 @@ void AppBoxRenderView::createWindowBeforeCallback(Evas** canvas, Evas_Object* pa
 
     if (m_pdHelper) {
         if (!(m_pdHelper->isPdOpened()) && 
-                parent == m_pdHelper->getBaseWebView())
+                parent == m_pdHelper->getBoxWebView())
         {
             LogD("pd canvas is used");
             *canvas = m_pdHelper->getPdCanvas();
             return;
         }
-    } 
+    }
     
     LogD("canvas of this webview is used");
     *canvas = evas_object_evas_get(parent);
@@ -392,3 +470,14 @@ void AppBoxRenderView::unsetBufferCallback(Evas_Object* webview)
     LogD("enter");
     evas_object_hide(webview);
 }
+
+void AppBoxRenderView::decideNavigationCallback(Evas_Object* webview, std::string& uri)
+{
+    LogD("enter");
+
+    // navigation of box scheme should be ignored
+    if(BoxSchemeHandler::Instance()->isBoxScheme(uri)) {
+        LogD("box scheme");
+        BoxSchemeHandler::Instance()->process(m_instanceId, uri);
+    }
+}
index 97c0b18..0d714a0 100644 (file)
@@ -35,6 +35,7 @@ class AppBoxRenderBuffer;
 class AppBoxRenderView: public IRenderView {
     public:
         typedef std::shared_ptr<Ewk_Context> EwkContextPtr;
+
         static IRenderViewPtr create(
                 std::string boxId, std::string instanceId, 
                 Evas_Object* boxWin, EwkContextPtr ewkContext)
@@ -49,18 +50,23 @@ class AppBoxRenderView: public IRenderView {
         virtual void resumeBox();
         virtual void showPd(Evas_Object* pdWin, RenderInfoPtr renderInfo);
         virtual void hidePd();
+        Evas_Object* getBoxWebView();
+        Evas_Object* getPdWebView();
         virtual ~AppBoxRenderView();
 
     private:
         // type definition
+        typedef std::shared_ptr<WRT::IRunnableWidgetObject> WrtCorePtr;
         enum UrlType {
             URL_TYPE_BOX,
             URL_TYPE_PD
         };
-        typedef std::shared_ptr<WRT::IRunnableWidgetObject> ViewPtr;
-        
-        bool createView();
-        bool destroyView();
+
+        WrtCorePtr createWrtCore(
+                std::string& startUrl, Evas_Object* win, EwkContextPtr ewkContext);
+        void destroyWrtCore(WrtCorePtr wrt);
+        void destroyBoxWrtCore();
+        void destroyPdWrtCore();
         std::string getAppId(std::string& boxId);
         std::string getStartUrl(UrlType type, std::string& defaultParams);
         Evas_Object* getCurrentSnapShot();
@@ -72,6 +78,10 @@ class AppBoxRenderView: public IRenderView {
         static Eina_Bool fireRenderTimerCallback(void* data);
         static Eina_Bool openPdIdlerCallback(void* data);
 
+        // ewk view callback
+        static void executeScriptCallback(
+                Evas_Object* webview, const char* result, void* data);
+
         // user Callbacks of RunnableWidgetObject
         void startLoadCallback(Evas_Object* webview);
         void finishLoadCallback(Evas_Object* webview);
@@ -79,6 +89,7 @@ class AppBoxRenderView: public IRenderView {
         void createWindowAfterCallback(Evas_Object* parent, Evas_Object* child);
         void setBufferCallback(Evas_Object* webview);
         void unsetBufferCallback(Evas_Object* webview);
+        void decideNavigationCallback(Evas_Object* webview, std::string& uri);
 
         // constructor
         explicit AppBoxRenderView(
@@ -90,13 +101,13 @@ class AppBoxRenderView: public IRenderView {
         std::string m_boxId;
         std::string m_instanceId;
         Evas_Object* m_boxWin;
-        Evas_Object* m_baseWebView;
         Evas_Object* m_snapshot;
         RenderInfoPtr m_renderInfo;
-        ViewPtr m_view;
-        std::string m_startUrl;
+        WrtCorePtr m_boxWrt;
+        WrtCorePtr m_pdWrt;
         Ecore_Timer* m_fireRenderTimer;
         IPdHelperPtr m_pdHelper;
+        bool m_pdFastOpen;
         EwkContextPtr m_ewkContext;
         AppBoxRenderBuffer* m_renderBuffer;
 
diff --git a/src/Plugin/AppBoxPlugin/AppPdHelper.cpp b/src/Plugin/AppBoxPlugin/AppPdHelper.cpp
deleted file mode 100644 (file)
index c0f508d..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Flora License, Version 1.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://floralicense.org/license/
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/**
- * @file    AppPdHelper.cpp
- * @author  Yunchan Cho (yunchan.cho@samsung.com)
- */
diff --git a/src/Plugin/AppBoxPlugin/AppPdHelper.h b/src/Plugin/AppBoxPlugin/AppPdHelper.h
deleted file mode 100644 (file)
index d02cdd9..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Flora License, Version 1.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://floralicense.org/license/
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/**
- * @file    AppPdHelper.h
- * @author  Yunchan Cho (yunchan.cho@samsung.com)
- */
index 23547dd..462f074 100644 (file)
@@ -38,7 +38,7 @@ SET(SRCS
     ${CMAKE_CURRENT_SOURCE_DIR}/AppBoxPluginFactory.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/AppBoxRenderView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/AppBoxRenderBuffer.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/AppPdHelper.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/AppBoxPdHelper.cpp
 )
 
 SET(HEADERS