2 * Copyright (c) 2013 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 permission_popup_manager.cpp
18 * @author Jihoon Chung (jihoon.chung@samsung.com)
21 #include "permission_popup_manager.h"
23 #include <dpl/availability.h>
24 #include <dpl/foreach.h>
25 #include <dpl/log/wrt_log.h>
26 #include <dpl/singleton_safe_impl.h>
29 IMPLEMENT_SAFE_SINGLETON(PermissionPopupManager)
31 PermissionPopupManager::PermissionPopupManager()
34 PermissionPopupManager::~PermissionPopupManager()
37 void PermissionPopupManager::registerPopup(Evas_Object* webview, Evas_Object* popup)
41 if (!webview || !popup)
43 WrtLogW("Wrong input argument");
48 m_pairList.push_back(Pair(webview, popup));
51 void PermissionPopupManager::unregisterWebview(Evas_Object* webview)
55 FOREACH(it, m_pairList)
57 if (it->first == webview)
59 removePopup(it->second);
60 evas_object_del(it->second);
63 PairList::iterator next = it;
69 removeWebview(webview);
72 void PermissionPopupManager::unregisterPopup(Evas_Object* popup)
74 WrtLogD("unegister popup");
76 Evas_Object* webview = NULL;
78 FOREACH(it, m_pairList)
80 if (it->second == popup)
83 removePopup(it->second);
86 PairList::iterator next = it;
95 FOREACH(it, m_pairList)
97 if (it->first == webview)
99 // PairList still has webview usage.
100 // Do not clean-up webview data.
104 removeWebview(webview);
108 void PermissionPopupManager::addWebview(Evas_Object* webview)
110 evas_object_event_callback_add(webview, EVAS_CALLBACK_DEL, deleteWebviewCallback, this);
113 void PermissionPopupManager::addPopup(Evas_Object* popup)
115 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, deletePopupCallback, this);
118 void PermissionPopupManager::removeWebview(Evas_Object* webview)
120 evas_object_event_callback_del(webview, EVAS_CALLBACK_DEL, deleteWebviewCallback);
123 void PermissionPopupManager::removePopup(Evas_Object* popup)
125 evas_object_event_callback_del(popup, EVAS_CALLBACK_DEL, deletePopupCallback);
128 void PermissionPopupManager::deleteWebviewCallback(void* data, Evas* e, Evas_Object* obj, void* eventInfo)
134 DPL_UNUSED_PARAM(eventInfo);
136 PermissionPopupManager* This = static_cast<PermissionPopupManager*>(data);
137 This->unregisterWebview(obj);
140 void PermissionPopupManager::deletePopupCallback(void* data, Evas* e, Evas_Object* obj, void* eventInfo)
146 DPL_UNUSED_PARAM(eventInfo);
148 PermissionPopupManager* This = static_cast<PermissionPopupManager*>(data);
149 This->unregisterPopup(obj);