Temporary fix for asking geolocation permission popup crash.
authorTae-Jeong Lee <taejeong.lee@samsung.com>
Fri, 13 Sep 2013 05:22:01 +0000 (14:22 +0900)
committerHoseon LEE <hoseon46.lee@samsung.com>
Sun, 29 Sep 2013 08:03:52 +0000 (17:03 +0900)
[Issue#] N/A
[Problem] A crash occurs when webkit ask geolocation permission to wrt.
[Cause] The ui popup has been created base on 'ewk_view' obejct.
[Solution] Fixed to creating popup based on window object by getParentWindow() api.

Change-Id: I62fa67da6de5d07cba52f6162290e3ff9af9dcd0

src/view/common/view_logic_certificate_support.cpp
src/view/common/view_logic_get_parent_window_util.h [new file with mode: 0644]
src/view/common/view_logic_security_origin_support.cpp
src/view/webkit/view_logic_usermedia_support.cpp

index 50f2fc4..5e02bba 100755 (executable)
@@ -31,6 +31,7 @@
 #include <wrt-commons/certificate-dao/certificate_dao.h>
 #include <widget_model.h>
 #include <widget_string.h>
+#include <common/view_logic_get_parent_window_util.h>
 
 namespace ViewModule {
 
@@ -93,6 +94,7 @@ Evas_Object* CertificateSupportUtil::createPopup(
 {
     LogDebug("createPopup");
 
+    Evas_Object* parentWindow = PopupUtil::getParentWindow(window);
     Evas_Object* popup = elm_popup_add(window);
     elm_object_style_set(popup, "popup/default");
     evas_object_size_hint_weight_set(popup,
diff --git a/src/view/common/view_logic_get_parent_window_util.h b/src/view/common/view_logic_get_parent_window_util.h
new file mode 100644 (file)
index 0000000..8dc2707
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    view_logic_get_parent_window_util.h
+ * @author  Tae-Jeong Lee (taejeong.lee@samsung.com)
+ */
+
+#ifndef VIEW_LOGIC_GET_PARENT_WINDOW_UTIL_H_
+#define VIEW_LOGIC_GET_PARENT_WINDOW_UTIL_H_
+
+#include <Elementary.h>
+#include <dpl/log/log.h>
+
+namespace ViewModule {
+namespace PopupUtil {
+
+static Evas_Object* getParentWindow(Evas_Object* object)
+{
+    Evas_Object* parent = elm_object_parent_widget_get(object);
+    Evas_Object* win = parent;
+
+    while (parent) {
+        const char* type = elm_object_widget_type_get(parent);
+        if (type) {
+            if (!strncmp(type, "elm_win", strlen("elm_win"))) {
+                win = parent;
+                break;
+            }
+        }
+        parent = elm_object_parent_widget_get(parent);
+    }
+
+    if (!win)
+    {
+        LogError("Parent window was not found!");
+        win = object;
+    }
+
+    return win;
+}
+
+} //namespace ViewModule
+} //namespace PopupUtil
+#endif //VIEW_LOGIC_GET_PARENT_WINDOW_UTIL_H_
index 11711a6..900b9d8 100644 (file)
@@ -31,6 +31,7 @@
 #include <wrt-commons/security-origin-dao/security_origin_dao.h>
 #include <widget_model.h>
 #include <widget_string.h>
+#include <common/view_logic_get_parent_window_util.h>
 
 namespace ViewModule {
 
@@ -92,7 +93,8 @@ Evas_Object* SecurityOriginSupportUtil::createPopup(
     void* data)
 {
     LogDebug("createPopup");
-    Evas_Object* popup = elm_popup_add(window);
+    Evas_Object* parentWindow = PopupUtil::getParentWindow(window);
+    Evas_Object* popup = elm_popup_add(parentWindow);
     elm_object_style_set(popup, "popup/default");
     evas_object_size_hint_weight_set(popup,
                                      EVAS_HINT_EXPAND,
index f3260ee..7e1adde 100755 (executable)
@@ -28,6 +28,7 @@
 #include <Elementary.h>
 #include <EWebKit2.h>
 #include <common/view_logic_security_origin_support.h>
+#include <common/view_logic_get_parent_window_util.h>
 
 namespace ViewModule {
 using namespace SecurityOriginDB;
@@ -45,7 +46,8 @@ void askUserForUsermediaPermission(Evas_Object* window, PermissionData* data)
 {
     LogDebug("askUserForUsermediaPermission called");
 
-    Evas_Object* popup = elm_popup_add(window);
+    Evas_Object* parentWindow = PopupUtil::getParentWindow(window);
+    Evas_Object* popup = elm_popup_add(parentWindow);
     evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
     elm_object_text_set(popup, USERMEDIA_USE_ASK_BODY);