Temporary fix for asking geolocation permission popup crash.
[platform/framework/web/wrt.git] / src / view / common / view_logic_get_parent_window_util.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /**
17  * @file    view_logic_get_parent_window_util.h
18  * @author  Tae-Jeong Lee (taejeong.lee@samsung.com)
19  */
20
21 #ifndef VIEW_LOGIC_GET_PARENT_WINDOW_UTIL_H_
22 #define VIEW_LOGIC_GET_PARENT_WINDOW_UTIL_H_
23
24 #include <Elementary.h>
25 #include <dpl/log/log.h>
26
27 namespace ViewModule {
28 namespace PopupUtil {
29
30 static Evas_Object* getParentWindow(Evas_Object* object)
31 {
32     Evas_Object* parent = elm_object_parent_widget_get(object);
33     Evas_Object* win = parent;
34
35     while (parent) {
36         const char* type = elm_object_widget_type_get(parent);
37         if (type) {
38             if (!strncmp(type, "elm_win", strlen("elm_win"))) {
39                 win = parent;
40                 break;
41             }
42         }
43         parent = elm_object_parent_widget_get(parent);
44     }
45
46     if (!win)
47     {
48         LogError("Parent window was not found!");
49         win = object;
50     }
51
52     return win;
53 }
54
55 } //namespace ViewModule
56 } //namespace PopupUtil
57 #endif //VIEW_LOGIC_GET_PARENT_WINDOW_UTIL_H_