[EFL][WK2] Add APIs to get/set whether scripts can open new windows.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2012 12:13:27 +0000 (12:13 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2012 12:13:27 +0000 (12:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102054

Patch by Yuni Jeong <yhnet.jung@samsung.com> on 2012-11-15
Reviewed by Gyuyoung Kim.

Added setting APIs make it possible to allow or prevent scripts from opening new windows automatically.

* UIProcess/API/efl/ewk_settings.cpp:
(ewk_settings_scripts_can_open_windows_set):
(ewk_settings_scripts_can_open_windows_get):
* UIProcess/API/efl/ewk_settings.h:
* UIProcess/API/efl/tests/test_ewk2_settings.cpp:
(TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134760 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp
Source/WebKit2/UIProcess/API/efl/ewk_settings.h
Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp

index d34c22f..b706715 100644 (file)
@@ -1,3 +1,19 @@
+2012-11-15  Yuni Jeong  <yhnet.jung@samsung.com>
+
+        [EFL][WK2] Add APIs to get/set whether scripts can open new windows.
+        https://bugs.webkit.org/show_bug.cgi?id=102054
+
+        Reviewed by Gyuyoung Kim.
+
+        Added setting APIs make it possible to allow or prevent scripts from opening new windows automatically.
+
+        * UIProcess/API/efl/ewk_settings.cpp:
+        (ewk_settings_scripts_can_open_windows_set):
+        (ewk_settings_scripts_can_open_windows_get):
+        * UIProcess/API/efl/ewk_settings.h:
+        * UIProcess/API/efl/tests/test_ewk2_settings.cpp:
+        (TEST_F):
+
 2012-11-14  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r134691, r134703, r134715, r134716,
index 779ef2b..e695e9b 100644 (file)
@@ -317,3 +317,18 @@ Eina_Bool ewk_settings_offline_web_application_cache_enabled_get(const Ewk_Setti
 
     return settings->preferences()->offlineWebApplicationCacheEnabled();
 }
+
+Eina_Bool ewk_settings_scripts_can_open_windows_set(Ewk_Settings* settings, Eina_Bool enable)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
+    settings->preferences()->setJavaScriptCanOpenWindowsAutomatically(enable);
+
+    return true;
+}
+
+Eina_Bool ewk_settings_scripts_can_open_windows_get(const Ewk_Settings* settings)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
+
+    return settings->preferences()->javaScriptCanOpenWindowsAutomatically();
+}
index 5948201..fe62b8b 100644 (file)
@@ -368,6 +368,29 @@ EAPI Eina_Bool ewk_settings_offline_web_application_cache_enabled_set(Ewk_Settin
  */
 EAPI Eina_Bool ewk_settings_offline_web_application_cache_enabled_get(const Ewk_Settings *settings);
 
+/**
+ * Enables/disables if the scripts can open new windows.
+ *
+ * By default, the scripts can open new windows.
+ *
+ * @param settings settings object to set if the scripts can open new windows
+ * @param enable @c EINA_TRUE if the scripts can open new windows
+ *        @c EINA_FALSE if not
+ *
+ * @return @c EINA_TRUE on success or @c EINA_FALSE on failure (scripts are disabled)
+ */
+EAPI Eina_Bool ewk_settings_scripts_can_open_windows_set(Ewk_Settings *settings, Eina_Bool enable);
+
+/**
+ * Returns whether the scripts can open new windows.
+ *
+ * @param settings settings object to query whether the scripts can open new windows
+ *
+ * @return @c EINA_TRUE if the scripts can open new windows
+ *         @c EINA_FALSE if not or on failure (scripts are disabled)
+ */
+EAPI Eina_Bool ewk_settings_scripts_can_open_windows_get(const Ewk_Settings *settings);
+
 #ifdef __cplusplus
 }
 #endif
index 0d36c99..d9f0fdb 100644 (file)
@@ -197,3 +197,16 @@ TEST_F(EWK2UnitTestBase, ewk_settings_offline_web_application_cache_enabled)
     ASSERT_FALSE(ewk_settings_offline_web_application_cache_enabled_get(settings));
 }
 
+TEST_F(EWK2UnitTestBase, ewk_settings_scripts_can_open_windows)
+{
+    Ewk_Settings* settings = ewk_view_settings_get(webView());
+
+    // The scripts can open new windows by default.
+    ASSERT_TRUE(ewk_settings_scripts_can_open_windows_get(settings));
+
+    ASSERT_TRUE(ewk_settings_scripts_can_open_windows_set(settings, true));
+    ASSERT_TRUE(ewk_settings_scripts_can_open_windows_get(settings));
+
+    ASSERT_TRUE(ewk_settings_scripts_can_open_windows_set(settings, false));
+    ASSERT_FALSE(ewk_settings_scripts_can_open_windows_get(settings));
+}