2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @author Yunchan Cho (yunchan.cho@samsung.com)
23 #include <Core/Util/Log.h>
24 #include "IRenderView.h"
25 #include "IPdHelper.h"
28 PdHelper::PdHelper(Evas_Object* pdWin, std::string pdStartUrl, RenderInfoPtr pdRenderInfo)
32 , m_startUrl(pdStartUrl)
33 , m_renderInfo(pdRenderInfo)
42 void PdHelper::startOpen()
49 //make javascript string for pd
50 std::string script = "var pdWindow = window.open(\"";
51 script += validateUrl(m_startUrl);
52 script += "\", \"_blank\");";
54 // execute javascript for opening new webview for pd
55 LogD("executed script: %s", script.c_str());
56 ewk_view_script_execute(
57 m_baseWebView, script.c_str(), executeScriptCallback, this);
60 void PdHelper::finishOpen(Evas_Object*& child)
64 // pd webview set and resize
66 evas_object_resize(m_pdWebView, m_renderInfo->width, m_renderInfo->height);
70 void PdHelper::close()
73 evas_object_del(m_pdWebView);
76 void PdHelper::setBaseWebView(Evas_Object*& parent)
79 m_baseWebView = parent;
82 Evas_Object* PdHelper::getBaseWebView() const
88 Evas* PdHelper::getPdCanvas() const
91 evas_object_evas_get(m_win);
94 bool PdHelper::isPdOpened() const
100 void PdHelper::didExecuteScript(Evas_Object* webview, std::string& result)
103 LogD("javascript execution result: %s", result.c_str());
106 std::string PdHelper::validateUrl(std::string& url)
111 return std::string();
114 if((!url.compare(0, 4, "http")) ||
115 (!url.compare(0, 5, "https")) ||
116 (!url.compare(0, 4, "file")))
121 std::string newUrl("file://");
126 void PdHelper::executeScriptCallback(
127 Evas_Object* webview, const char* result, void* data)
131 PdHelper* This = static_cast<PdHelper*>(data);
132 std::string resultStr(result ? result : "null");
133 This->didExecuteScript(webview, resultStr);