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 js_function_manager.cpp
18 * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
19 * @author Yunchan Cho (yunchan.cho@samgsung.com)
24 #include <dpl/singleton_safe_impl.h>
25 #include <js_function_manager.h>
26 #include <js_iframe_support.h>
27 #include <js_overlay_functions.h>
28 #include <js_overlay_addEventListener.h>
29 #include <wrt_plugin_export.h>
31 using namespace WrtPlugins::W3C;
33 IMPLEMENT_SAFE_SINGLETON(JsFunctionManager)
36 const char* JSPRINT_NAME = "jsPrint";
37 const char* JSGLOBAL_OBJECT = "GLOBAL_OBJECT";
38 const char* JSHOOK_NAME = "jsHook";
39 const char* ADD_EVENT_LISTENER_NAME = "addEventListener";
42 namespace JavaScriptFunctions {
44 class_definition_options_t jsHookfunctionsOptions = {
48 USE_OVERLAYED, //ignored
51 reinterpret_cast<js_function_impl>(JSCFunctions::JavaScriptHookProc)
54 class_definition_options_t jsPrintfunctionsOptions = {
58 USE_OVERLAYED, //ignored
61 reinterpret_cast<js_function_impl>(JSCFunctions::JavaScriptPrintProc)
64 class_definition_options_t addEventListenerOptions = {
68 OVERLAYED_BEFORE_ORIGINAL,
69 IFrameSupport::RegisterAddEventListener,
71 reinterpret_cast<js_function_impl>(AddEventListenerSupport::
75 js_entity_definition_t jsPrint = {
81 &jsPrintfunctionsOptions
84 js_entity_definition_t jsHook = {
90 &jsHookfunctionsOptions
93 js_entity_definition_t addEventListener = {
95 ADD_EVENT_LISTENER_NAME,
99 &addEventListenerOptions
101 const js_entity_definition_ptr_t jsPrintPtr = &jsPrint;
102 const js_entity_definition_ptr_t jsHookPtr = &jsHook;
103 const js_entity_definition_ptr_t addEventListenerPtr = &addEventListener;
106 bool JsFunctionManager::initialize()
108 LogInfo("JSObjectDeclaration for js functions are intialized");
109 JSObjectDeclarationPtr jsPrintObj(
110 new JSObjectDeclaration(JavaScriptFunctions::jsPrintPtr));
112 JSObjectDeclarationPtr jsHookObj(
113 new JSObjectDeclaration(JavaScriptFunctions::jsHookPtr));
115 JSObjectDeclarationPtr addEventListenerObj(
116 new JSObjectDeclaration(JavaScriptFunctions::addEventListenerPtr));
118 m_functions.push_back(jsPrintObj);
119 m_functions.push_back(jsHookObj);
120 m_functions.push_back(addEventListenerObj);
125 JsFunctionManager::Functions JsFunctionManager::getFunctions()
127 LogInfo("get standard js fucntions");
128 static bool initialized = initialize();