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 {
31 IFrameSupport::IFramesContainer IFrameSupport::m_iframesObject =
32 IFrameSupport::IFramesContainer();
34 void IFrameSupport::RegisterWidget(java_script_context_t /*global_context*/,
35 js_object_instance_t iframe,
36 js_object_instance_t object)
38 LogDebug("New widget instance registered");
39 LogDebug("iframe: " << iframe);
40 LogDebug("object: " << object);
41 getIFrameData(static_cast<JSObjectRef>(iframe))->widget =
42 static_cast<JSObjectRef>(object);
45 void IFrameSupport::RegisterAddEventListener(
46 java_script_context_t /*global_context*/,
47 js_object_instance_t iframe,
48 js_object_instance_t object)
50 LogDebug("New addEventListener instance registered");
51 LogDebug("iframe: " << iframe);
52 LogDebug("object: " << object);
53 getIFrameData(static_cast<JSObjectRef>(iframe))->addEventListener
54 = static_cast<JSObjectRef>(object);
57 JSObjectRef IFrameSupport::getIFrameObjectForWidget(JSObjectRef widgetObject)
59 FOREACH(it, m_iframesObject)
61 if (it->second->widget == widgetObject) {
62 LogDebug("iframe found");
66 LogDebug("Iframe not found");
70 IFrameDataPtr IFrameSupport::getIFrameData(JSObjectRef iframe)
72 auto it = m_iframesObject.find(iframe);
73 if (it != m_iframesObject.end()) {
77 return m_iframesObject[iframe] = IFrameDataPtr(new IFrameData());