2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file plugin_module_support.cpp
18 * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
19 * @author Yunchan Cho (yunchan.cho@samsung.com)
20 * @brief Plugin module support for Webkit2 - implementation.
22 #include "plugin_module_support.h"
23 #include "messages_names.h"
27 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
28 #include <js_overlay_types.h>
30 namespace PluginModuleSupport {
31 void init(Ewk_Context* ewkContext, const std::string& tizenId)
33 const char* name = BundleMessages::INIT;
34 const char* msg = tizenId.c_str();
36 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
39 void start(Ewk_Context* ewkContext,
40 const DPL::String& tizenId,
42 const char *encodedBundle,
46 std::stringstream ssMsg;
48 std::string id = DPL::ToUTF8String(tizenId);
51 ssMsg << "_" << scale << " ";
54 ssMsg << "_" << encodedBundle << " ";
56 ssMsg << "null" << " ";
60 ssMsg << "_" << theme << " ";
62 ssMsg << "null" << " ";
67 std::string msgString = ssMsg.str();
69 const char* msg = msgString.c_str();
70 const char* name = BundleMessages::START;
72 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
75 void shutdown(Ewk_Context* ewkContext)
77 const char* name = BundleMessages::SHUTDOWN;
78 ewk_context_message_post_to_injected_bundle(ewkContext, name, name);
81 void setCustomProperties(
82 Ewk_Context* ewkContext,
84 const char* encodedBundle,
87 std::stringstream ssMsg;
90 ssMsg << "_" << *scale << " ";
92 ssMsg << "null" << " ";
96 ssMsg << "_" << encodedBundle << " ";
98 ssMsg << "null" << " ";
102 ssMsg << "_" << theme;
107 std::string msgString = ssMsg.str();
109 const char* msg = msgString.c_str();
110 const char* name = BundleMessages::SET_CUSTOM_PROPERTIES;
112 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
115 void dispatchJavaScriptEvent(
116 Ewk_Context* ewkContext,
117 WrtPlugins::W3C::CustomEventType eventType,
120 using namespace WrtPlugins::W3C;
121 std::stringstream str;
124 // if needed, arguments for event should be set here
125 if (eventType == SoftKeyboardChangeCustomEvent) {
127 SoftKeyboardChangeArgs* args =
128 static_cast<SoftKeyboardChangeArgs *>(data);
129 str << " " << args->state;
130 str << " " << args->width;
131 str << " " << args->height;
135 std::string msgString = str.str();
136 const char* msg = msgString.c_str();
137 const char* name = BundleMessages::DISPATCH_JAVASCRIPT_EVENT;
139 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
142 void suspend(Ewk_Context* ewkContext)
144 const char* name = BundleMessages::SUSPEND;
145 ewk_context_message_post_to_injected_bundle(ewkContext, name, name);
148 void resume(Ewk_Context* ewkContext)
150 const char* name = BundleMessages::RESUME;
151 ewk_context_message_post_to_injected_bundle(ewkContext, name, name);
153 } //namespace PluginModuleSupport