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.
18 * @file IFrameSupport.cpp
19 * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
24 #include <dpl/foreach.h>
25 #include <dpl/assert.h>
26 #include <dpl/log/log.h>
27 #include <js_iframe_support.h>
29 namespace WrtPlugins {
32 IFrameSupport::IFramesContainer IFrameSupport::m_iframesObject =
33 IFrameSupport::IFramesContainer();
36 void IFrameSupport::RegisterWidget(java_script_context_t global_context,
37 js_object_instance_t iframe,
38 js_object_instance_t object)
40 LogDebug("New widget instance registered");
41 LogDebug("iframe: " << iframe );
42 LogDebug("object: " << object );
43 getIFrameData(static_cast<JSObjectRef>(iframe))->widget =
44 static_cast<JSObjectRef>(object);
47 void IFrameSupport::RegisterAddEventListener(java_script_context_t global_context,
48 js_object_instance_t iframe,
49 js_object_instance_t object)
51 LogDebug("New addEventListener instance registered");
52 LogDebug("iframe: " << iframe );
53 LogDebug("object: " << object );
54 getIFrameData(static_cast<JSObjectRef>(iframe))->addEventListener
55 = static_cast<JSObjectRef>(object);
58 JSObjectRef IFrameSupport::getIFrameObjectForWidget(JSObjectRef widgetObject)
60 FOREACH(it, m_iframesObject)
62 if(it->second->widget == widgetObject)
64 LogDebug("iframe found");
68 LogDebug("Iframe not found");
72 IFrameDataPtr IFrameSupport::getIFrameData(JSObjectRef iframe)
74 auto it = m_iframesObject.find(iframe);
75 if(it != m_iframesObject.end()){
79 return m_iframesObject[iframe] = IFrameDataPtr(new IFrameData());