[WebKit2][gtk] Add few more properties to WebKitSettings
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2011 09:10:53 +0000 (09:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2011 09:10:53 +0000 (09:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72468

Patch by Nayan Kumar K <nayankk@motorola.com> on 2011-11-17
Reviewed by Martin Robinson.

Add 'enable-private-browsing', 'enable-developer-extras, 'enable-resizable-text-areas'
and 'enable-tabs-to-links' properties to WebKitSettings.

* UIProcess/API/gtk/WebKitSettings.cpp:
(webKitSettingsSetProperty): Add new set functions.
(webKitSettingsGetProperty): Add new get functions.
(webkit_settings_class_init): Add new properties.
(webkit_settings_get_enable_private_browsing): Get 'enable-private-browsing' property.
(webkit_settings_set_enable_private_browsing): Set 'enable-private-browsing' property.
(webkit_settings_get_enable_developer_extras): Get 'enable-developer-extras' property.
(webkit_settings_set_enable_developer_extras): Set 'enable-developer-extras' property.
(webkit_settings_get_enable_resizable_text_areas): Get 'enable-resizable-text-areas' property.
(webkit_settings_set_enable_resizable_text_areas): Set 'enable-resizable-text-areas' property.
(webkit_settings_get_enable_tabs_to_links): Get 'enable-tabs-to-links' property.
(webkit_settings_set_enable_tabs_to_links): Set 'enable-tabs-to-links' property.
* UIProcess/API/gtk/WebKitSettings.h: New public APIs added.
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: New APIs added.
* UIProcess/API/gtk/tests/TestWebKitSettings.cpp:
(testWebKitSettings): Add new tests.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp

index e8e4fbf3897d32cbdd3bada36f286dd8af8cc40d..11b0cb516710740c59dbfd1eab2cc870f92239bd 100644 (file)
@@ -1,3 +1,30 @@
+2011-11-17  Nayan Kumar K  <nayankk@motorola.com>
+
+        [WebKit2][gtk] Add few more properties to WebKitSettings
+        https://bugs.webkit.org/show_bug.cgi?id=72468
+
+        Reviewed by Martin Robinson.
+
+        Add 'enable-private-browsing', 'enable-developer-extras, 'enable-resizable-text-areas'
+        and 'enable-tabs-to-links' properties to WebKitSettings.
+
+        * UIProcess/API/gtk/WebKitSettings.cpp:
+        (webKitSettingsSetProperty): Add new set functions.
+        (webKitSettingsGetProperty): Add new get functions.
+        (webkit_settings_class_init): Add new properties.
+        (webkit_settings_get_enable_private_browsing): Get 'enable-private-browsing' property.
+        (webkit_settings_set_enable_private_browsing): Set 'enable-private-browsing' property.
+        (webkit_settings_get_enable_developer_extras): Get 'enable-developer-extras' property.
+        (webkit_settings_set_enable_developer_extras): Set 'enable-developer-extras' property.
+        (webkit_settings_get_enable_resizable_text_areas): Get 'enable-resizable-text-areas' property.
+        (webkit_settings_set_enable_resizable_text_areas): Set 'enable-resizable-text-areas' property.
+        (webkit_settings_get_enable_tabs_to_links): Get 'enable-tabs-to-links' property.
+        (webkit_settings_set_enable_tabs_to_links): Set 'enable-tabs-to-links' property.
+        * UIProcess/API/gtk/WebKitSettings.h: New public APIs added.
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: New APIs added.
+        * UIProcess/API/gtk/tests/TestWebKitSettings.cpp:
+        (testWebKitSettings): Add new tests.
+
 2011-11-17  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Fix WebKit2 GTK+ build after r100569.
index e396248e92e3ea87bd8554e3cfa62a79266a4bb2..962bae4b002a15b10023754559a86ad342e9d1e1 100644 (file)
@@ -97,6 +97,10 @@ enum {
     PROP_DEFAULT_MONOSPACE_FONT_SIZE,
     PROP_MINIMUM_FONT_SIZE,
     PROP_DEFAULT_CHARSET,
+    PROP_ENABLE_PRIVATE_BROWSING,
+    PROP_ENABLE_DEVELOPER_EXTRAS,
+    PROP_ENABLE_RESIZABLE_TEXT_AREAS,
+    PROP_ENABLE_TABS_TO_LINKS,
     PROP_ENABLE_CARET_BROWSING,
 };
 
@@ -174,6 +178,18 @@ static void webKitSettingsSetProperty(GObject* object, guint propId, const GValu
     case PROP_DEFAULT_CHARSET:
         webkit_settings_set_default_charset(settings, g_value_get_string(value));
         break;
+    case PROP_ENABLE_PRIVATE_BROWSING:
+        webkit_settings_set_enable_private_browsing(settings, g_value_get_boolean(value));
+        break;
+    case PROP_ENABLE_DEVELOPER_EXTRAS:
+        webkit_settings_set_enable_developer_extras(settings, g_value_get_boolean(value));
+        break;
+    case PROP_ENABLE_RESIZABLE_TEXT_AREAS:
+        webkit_settings_set_enable_resizable_text_areas(settings, g_value_get_boolean(value));
+        break;
+    case PROP_ENABLE_TABS_TO_LINKS:
+        webkit_settings_set_enable_tabs_to_links(settings, g_value_get_boolean(value));
+        break;
     case PROP_ENABLE_CARET_BROWSING:
         webkit_settings_set_enable_caret_browsing(settings, g_value_get_boolean(value));
         break;
@@ -257,6 +273,18 @@ static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* val
     case PROP_DEFAULT_CHARSET:
         g_value_set_string(value, webkit_settings_get_default_charset(settings));
         break;
+    case PROP_ENABLE_PRIVATE_BROWSING:
+        g_value_set_boolean(value, webkit_settings_get_enable_private_browsing(settings));
+        break;
+    case PROP_ENABLE_DEVELOPER_EXTRAS:
+        g_value_set_boolean(value, webkit_settings_get_enable_developer_extras(settings));
+        break;
+    case PROP_ENABLE_RESIZABLE_TEXT_AREAS:
+        g_value_set_boolean(value, webkit_settings_get_enable_resizable_text_areas(settings));
+        break;
+    case PROP_ENABLE_TABS_TO_LINKS:
+        g_value_set_boolean(value, webkit_settings_get_enable_tabs_to_links(settings));
+        break;
     case PROP_ENABLE_CARET_BROWSING:
         g_value_set_boolean(value, webkit_settings_get_enable_caret_browsing(settings));
         break;
@@ -610,6 +638,62 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
                                                         "iso-8859-1",
                                                         readWriteConstructParamFlags));
 
+    /**
+     * WebKitSettings:enable-private-browsing:
+     *
+     * Determines whether or not private browsing is enabled. Private browsing
+     * will disable history, cache and form auto-fill for any pages visited.
+     */
+    g_object_class_install_property(gObjectClass,
+                                    PROP_ENABLE_PRIVATE_BROWSING,
+                                    g_param_spec_boolean("enable-private-browsing",
+                                                         _("Enable private browsing"),
+                                                         _("Whether to enable private browsing"),
+                                                         FALSE,
+                                                         readWriteConstructParamFlags));
+
+    /**
+     * WebKitSettings:enable-developer-extras:
+     *
+     * Determines whether or not developer tools, such as the Web Inspector, are enabled.
+     */
+    g_object_class_install_property(gObjectClass,
+                                    PROP_ENABLE_DEVELOPER_EXTRAS,
+                                    g_param_spec_boolean("enable-developer-extras",
+                                                         _("Enable developer extras"),
+                                                         _("Whether to enable developer extras"),
+                                                         FALSE,
+                                                         readWriteConstructParamFlags));
+
+    /**
+     * WebKitSettings:enable-resizable-text-areas:
+     *
+     * Determines whether or not text areas can be resized.
+     */
+    g_object_class_install_property(gObjectClass,
+                                    PROP_ENABLE_RESIZABLE_TEXT_AREAS,
+                                    g_param_spec_boolean("enable-resizable-text-areas",
+                                                         _("Enable resizable text areas"),
+                                                         _("Whether to enable resizable text areas"),
+                                                         TRUE,
+                                                         readWriteConstructParamFlags));
+
+    /**
+     * WebKitSettings:enable-tabs-to-links:
+     *
+     * Determines whether the tab key cycles through the elements on the page. 
+     * When this setting is enabled, users will be able to focus the next element 
+     * in the page by pressing the tab key. If the selected element is editable,
+     * then pressing tab key will insert the tab character.
+     */
+    g_object_class_install_property(gObjectClass,
+                                    PROP_ENABLE_TABS_TO_LINKS,
+                                    g_param_spec_boolean("enable-tabs-to-links",
+                                                         _("Enable tabs to links"),
+                                                         _("Whether to enable tabs to links"),
+                                                         FALSE,
+                                                         readWriteConstructParamFlags));
+
     /**
      * WebKitSettings:enable-caret-browsing:
      *
@@ -1531,6 +1615,146 @@ void webkit_settings_set_default_charset(WebKitSettings* settings, const gchar*
     g_object_notify(G_OBJECT(settings), "default-charset");
 }
 
+/**
+ * webkit_settings_get_enable_private_browsing:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-private-browsing property.
+ *
+ * Returns: %TRUE If private browsing is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_private_browsing(WebKitSettings* settings)
+{
+    g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+    return WKPreferencesGetPrivateBrowsingEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_private_caret_browsing:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-private-browsing property.
+ */
+void webkit_settings_set_enable_private_browsing(WebKitSettings* settings, gboolean enabled)
+{
+    g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+    WebKitSettingsPrivate* priv = settings->priv;
+    bool currentValue = WKPreferencesGetPrivateBrowsingEnabled(priv->preferences.get());
+    if (currentValue == enabled)
+        return;
+
+    WKPreferencesSetPrivateBrowsingEnabled(priv->preferences.get(), enabled);
+    g_object_notify(G_OBJECT(settings), "enable-private-browsing");
+}
+
+/**
+ * webkit_settings_get_enable_developer_extras:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-developer-extras property.
+ *
+ * Returns: %TRUE If developer extras is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_developer_extras(WebKitSettings* settings)
+{
+    g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+    return WKPreferencesGetDeveloperExtrasEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_developer_extras:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-developer-extras property.
+ */
+void webkit_settings_set_enable_developer_extras(WebKitSettings* settings, gboolean enabled)
+{
+    g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+    WebKitSettingsPrivate* priv = settings->priv;
+    bool currentValue = WKPreferencesGetDeveloperExtrasEnabled(priv->preferences.get());
+    if (currentValue == enabled)
+        return;
+
+    WKPreferencesSetDeveloperExtrasEnabled(priv->preferences.get(), enabled);
+    g_object_notify(G_OBJECT(settings), "enable-developer-extras");
+}
+
+/**
+ * webkit_settings_get_enable_resizable_text_areas:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-resizable-text-areas property.
+ *
+ * Returns: %TRUE If text areas can be resized or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_resizable_text_areas(WebKitSettings* settings)
+{
+    g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+    return WKPreferencesGetTextAreasAreResizable(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_resizable_text_areas:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-resizable-text-areas property.
+ */
+void webkit_settings_set_enable_resizable_text_areas(WebKitSettings* settings, gboolean enabled)
+{
+    g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+    WebKitSettingsPrivate* priv = settings->priv;
+    bool currentValue = WKPreferencesGetTextAreasAreResizable(priv->preferences.get());
+    if (currentValue == enabled)
+        return;
+
+    WKPreferencesSetTextAreasAreResizable(priv->preferences.get(), enabled);
+    g_object_notify(G_OBJECT(settings), "enable-resizable-text-areas");
+}
+
+/**
+ * webkit_settings_get_enable_tabs_to_links:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-tabs-to-links property.
+ *
+ * Returns: %TRUE If tabs to link is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_tabs_to_links(WebKitSettings* settings)
+{
+    g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+    return WKPreferencesGetTabsToLinks(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_tabs_to_links:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-tabs-to-links property.
+ */
+void webkit_settings_set_enable_tabs_to_links(WebKitSettings* settings, gboolean enabled)
+{
+    g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+    WebKitSettingsPrivate* priv = settings->priv;
+    bool currentValue = WKPreferencesGetTabsToLinks(priv->preferences.get());
+    if (currentValue == enabled)
+        return;
+
+    WKPreferencesSetTabsToLinks(priv->preferences.get(), enabled);
+    g_object_notify(G_OBJECT(settings), "enable-tabs-to-links");
+}
+
 /**
  * webkit_settings_get_enable_caret_browsing:
  * @settings: a #WebKitSettings
index 0dee1ff7738559906a7d18c022d54c9c0ff6a46c..3271bd7e7a14003d210d545a403f841d982d7e43 100644 (file)
@@ -237,6 +237,34 @@ WEBKIT_API void
 webkit_settings_set_default_charset                            (WebKitSettings* settings,
                                                                 const gchar* default_charset);
 
+WEBKIT_API gboolean
+webkit_settings_get_enable_private_browsing                    (WebKitSettings* settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_private_browsing                    (WebKitSettings* settings,
+                                                                gboolean        enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_developer_extras                    (WebKitSettings* settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_developer_extras                    (WebKitSettings* settings,
+                                                                gboolean        enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_resizable_text_areas                (WebKitSettings* settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_resizable_text_areas                (WebKitSettings* settings,
+                                                                gboolean        enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_tabs_to_links                       (WebKitSettings* settings);                              
+
+WEBKIT_API void
+webkit_settings_set_enable_tabs_to_links                       (WebKitSettings* settings,
+                                                                gboolean        enabled);
+
 WEBKIT_API gboolean
 webkit_settings_get_enable_caret_browsing                      (WebKitSettings* settings);
 
index 0acc43c48b83395262b4f04f216062acf1306635..3b3e9eb8ba7039e81a5b7af868045716c84be6c0 100644 (file)
@@ -204,6 +204,14 @@ webkit_settings_get_minimum_font_size
 webkit_settings_set_minimum_font_size
 webkit_settings_get_default_charset
 webkit_settings_set_default_charset
+webkit_settings_get_enable_private_browsing
+webkit_settings_set_enable_private_browsing
+webkit_settings_get_enable_developer_extras
+webkit_settings_set_enable_developer_extras
+webkit_settings_get_enable_resizable_text_areas
+webkit_settings_set_enable_resizable_text_areas
+webkit_settings_get_enable_tabs_to_links
+webkit_settings_set_enable_tabs_to_links
 webkit_settings_get_enable_caret_browsing
 webkit_settings_set_enable_caret_browsing
 
index 548d581d1c556e97be7d8ac9f2eb22f345d5f824..75f286bacab743bfe19a7668ec1ff6c4e44805f5 100644 (file)
@@ -157,6 +157,22 @@ static void testWebKitSettings(Test*, gconstpointer)
     webkit_settings_set_default_charset(settings, "utf8");
     g_assert_cmpstr(webkit_settings_get_default_charset(settings), ==, "utf8");
 
+    g_assert(!webkit_settings_get_enable_private_browsing(settings));
+    webkit_settings_set_enable_private_browsing(settings, TRUE);
+    g_assert(webkit_settings_get_enable_private_browsing(settings));
+
+    g_assert(!webkit_settings_get_enable_developer_extras(settings));
+    webkit_settings_set_enable_developer_extras(settings, TRUE);
+    g_assert(webkit_settings_get_enable_developer_extras(settings));
+
+    g_assert(webkit_settings_get_enable_resizable_text_areas(settings));
+    webkit_settings_set_enable_resizable_text_areas(settings, FALSE);
+    g_assert(!webkit_settings_get_enable_resizable_text_areas(settings));
+
+    g_assert(!webkit_settings_get_enable_tabs_to_links(settings));
+    webkit_settings_set_enable_tabs_to_links(settings, TRUE);
+    g_assert(webkit_settings_get_enable_tabs_to_links(settings));
+
     // Caret browsing is disabled by default.
     g_assert(!webkit_settings_get_enable_caret_browsing(settings));
     webkit_settings_set_enable_caret_browsing(settings, TRUE);