2010-12-06 Philippe Normand <pnormand@igalia.com>
[WebKit-https.git] / WebKit / gtk / webkit / webkitwebsettings.cpp
1 /*
2  * Copyright (C) 2008 Christian Dywan <christian@imendio.com>
3  * Copyright (C) 2008 Nuanti Ltd.
4  * Copyright (C) 2008 Collabora Ltd.
5  * Copyright (C) 2008 Holger Hans Peter Freyther
6  * Copyright (C) 2009 Jan Michael Alonzo
7  * Copyright (C) 2009 Movial Creative Technologies Inc.
8  * Copyright (C) 2009 Igalia S.L.
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public License
21  * along with this library; see the file COPYING.LIB.  If not, write to
22  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  */
25
26 #include "config.h"
27 #include "webkitwebsettings.h"
28
29 #include "webkitenumtypes.h"
30 #include "webkitprivate.h"
31 #include "webkitversion.h"
32
33 #include "FileSystem.h"
34 #include "PluginDatabase.h"
35 #include "Language.h"
36 #include <wtf/text/CString.h>
37 #include <wtf/text/StringConcatenate.h>
38
39 #include <glib/gi18n-lib.h>
40 #if OS(UNIX)
41 #include <sys/utsname.h>
42 #endif
43
44 /**
45  * SECTION:webkitwebsettings
46  * @short_description: Control the behaviour of a #WebKitWebView
47  *
48  * #WebKitWebSettings can be applied to a #WebKitWebView to control text encoding, 
49  * color, font sizes, printing mode, script support, loading of images and various other things. 
50  * After creation, a #WebKitWebSettings object contains default settings. 
51  *
52  * <informalexample><programlisting>
53  * /<!-- -->* Create a new websettings and disable java script *<!-- -->/
54  * WebKitWebSettings *settings = webkit_web_settings_new ();
55  * g_object_set (G_OBJECT(settings), "enable-scripts", FALSE, NULL);
56  *
57  * /<!-- -->* Apply the result *<!-- -->/
58  * webkit_web_view_set_settings (WEBKIT_WEB_VIEW(my_webview), settings);
59  * </programlisting></informalexample>
60  */
61
62 using namespace WebCore;
63
64 G_DEFINE_TYPE(WebKitWebSettings, webkit_web_settings, G_TYPE_OBJECT)
65
66 struct _WebKitWebSettingsPrivate {
67     gchar* default_encoding;
68     gchar* cursive_font_family;
69     gchar* default_font_family;
70     gchar* fantasy_font_family;
71     gchar* monospace_font_family;
72     gchar* sans_serif_font_family;
73     gchar* serif_font_family;
74     guint default_font_size;
75     guint default_monospace_font_size;
76     guint minimum_font_size;
77     guint minimum_logical_font_size;
78     gboolean enforce_96_dpi;
79     gboolean auto_load_images;
80     gboolean auto_shrink_images;
81     gboolean print_backgrounds;
82     gboolean enable_scripts;
83     gboolean enable_plugins;
84     gboolean resizable_text_areas;
85     gchar* user_stylesheet_uri;
86     gfloat zoom_step;
87     gboolean enable_developer_extras;
88     gboolean enable_private_browsing;
89     gboolean enable_spell_checking;
90     gchar* spell_checking_languages;
91     GSList* enchant_dicts;
92     gboolean enable_caret_browsing;
93     gboolean enable_html5_database;
94     gboolean enable_html5_local_storage;
95     gboolean enable_xss_auditor;
96     gboolean enable_spatial_navigation;
97     gboolean enable_frame_flattening;
98     gchar* user_agent;
99     gboolean javascript_can_open_windows_automatically;
100     gboolean javascript_can_access_clipboard;
101     gboolean enable_offline_web_application_cache;
102     WebKitEditingBehavior editing_behavior;
103     gboolean enable_universal_access_from_file_uris;
104     gboolean enable_file_access_from_file_uris;
105     gboolean enable_dom_paste;
106     gboolean tab_key_cycles_through_elements;
107     gboolean enable_default_context_menu;
108     gboolean enable_site_specific_quirks;
109     gboolean enable_page_cache;
110     gboolean auto_resize_window;
111     gboolean enable_java_applet;
112     gboolean enable_hyperlink_auditing;
113     gboolean enable_fullscreen;
114 };
115
116 #define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate))
117
118 enum {
119     PROP_0,
120
121     PROP_DEFAULT_ENCODING,
122     PROP_CURSIVE_FONT_FAMILY,
123     PROP_DEFAULT_FONT_FAMILY,
124     PROP_FANTASY_FONT_FAMILY,
125     PROP_MONOSPACE_FONT_FAMILY,
126     PROP_SANS_SERIF_FONT_FAMILY,
127     PROP_SERIF_FONT_FAMILY,
128     PROP_DEFAULT_FONT_SIZE,
129     PROP_DEFAULT_MONOSPACE_FONT_SIZE,
130     PROP_MINIMUM_FONT_SIZE,
131     PROP_MINIMUM_LOGICAL_FONT_SIZE,
132     PROP_ENFORCE_96_DPI,
133     PROP_AUTO_LOAD_IMAGES,
134     PROP_AUTO_SHRINK_IMAGES,
135     PROP_PRINT_BACKGROUNDS,
136     PROP_ENABLE_SCRIPTS,
137     PROP_ENABLE_PLUGINS,
138     PROP_RESIZABLE_TEXT_AREAS,
139     PROP_USER_STYLESHEET_URI,
140     PROP_ZOOM_STEP,
141     PROP_ENABLE_DEVELOPER_EXTRAS,
142     PROP_ENABLE_PRIVATE_BROWSING,
143     PROP_ENABLE_SPELL_CHECKING,
144     PROP_SPELL_CHECKING_LANGUAGES,
145     PROP_ENABLE_CARET_BROWSING,
146     PROP_ENABLE_HTML5_DATABASE,
147     PROP_ENABLE_HTML5_LOCAL_STORAGE,
148     PROP_ENABLE_XSS_AUDITOR,
149     PROP_ENABLE_SPATIAL_NAVIGATION,
150     PROP_ENABLE_FRAME_FLATTENING,
151     PROP_USER_AGENT,
152     PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
153     PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD,
154     PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
155     PROP_EDITING_BEHAVIOR,
156     PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS,
157     PROP_ENABLE_FILE_ACCESS_FROM_FILE_URIS,
158     PROP_ENABLE_DOM_PASTE,
159     PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS,
160     PROP_ENABLE_DEFAULT_CONTEXT_MENU,
161     PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
162     PROP_ENABLE_PAGE_CACHE,
163     PROP_AUTO_RESIZE_WINDOW,
164     PROP_ENABLE_JAVA_APPLET,
165     PROP_ENABLE_HYPERLINK_AUDITING,
166     PROP_ENABLE_FULLSCREEN
167 };
168
169 // Create a default user agent string
170 // This is a liberal interpretation of http://www.mozilla.org/build/revised-user-agent-strings.html
171 // See also http://developer.apple.com/internet/safari/faq.html#anchor2
172 static String webkitPlatform()
173 {
174 #if PLATFORM(X11)
175     DEFINE_STATIC_LOCAL(const String, uaPlatform, (String("X11")));
176 #elif OS(WINDOWS)
177     DEFINE_STATIC_LOCAL(const String, uaPlatform, (String("Windows")));
178 #elif PLATFORM(MAC)
179     DEFINE_STATIC_LOCAL(const String, uaPlatform, (String("Macintosh")));
180 #elif defined(GDK_WINDOWING_DIRECTFB)
181     DEFINE_STATIC_LOCAL(const String, uaPlatform, (String("DirectFB")));
182 #else
183     DEFINE_STATIC_LOCAL(const String, uaPlatform, (String("Unknown")));
184 #endif
185
186     return uaPlatform;
187 }
188
189 static String webkitOSVersion()
190 {
191    // FIXME: platform/version detection can be shared.
192 #if OS(DARWIN)
193
194 #if CPU(X86)
195     DEFINE_STATIC_LOCAL(const String, uaOSVersion, (String("Intel Mac OS X")));
196 #else
197     DEFINE_STATIC_LOCAL(const String, uaOSVersion, (String("PPC Mac OS X")));
198 #endif
199
200 #elif OS(UNIX)
201     DEFINE_STATIC_LOCAL(String, uaOSVersion, (String()));
202
203     if (!uaOSVersion.isEmpty())
204         return uaOSVersion;
205
206     struct utsname name;
207     if (uname(&name) != -1)
208         uaOSVersion = makeString(name.sysname, ' ', name.machine);
209     else
210         uaOSVersion = String("Unknown");
211 #elif OS(WINDOWS)
212     DEFINE_STATIC_LOCAL(const String, uaOSVersion, (String("Windows")));
213 #else
214     DEFINE_STATIC_LOCAL(const String, uaOSVersion, (String("Unknown")));
215 #endif
216
217     return uaOSVersion;
218 }
219
220 String webkitUserAgent()
221 {
222     // We mention Safari since many broken sites check for it (OmniWeb does this too)
223     // We re-use the WebKit version, though it doesn't seem to matter much in practice
224
225     DEFINE_STATIC_LOCAL(const String, uaVersion, (makeString(String::number(WEBKIT_USER_AGENT_MAJOR_VERSION), '.', String::number(WEBKIT_USER_AGENT_MINOR_VERSION), '+')));
226     DEFINE_STATIC_LOCAL(const String, staticUA, (makeString("Mozilla/5.0 (", webkitPlatform(), "; U; ", webkitOSVersion(), "; ", defaultLanguage(), ") AppleWebKit/", uaVersion) +
227                                                  makeString(" (KHTML, like Gecko) Version/5.0 Safari/", uaVersion)));
228
229     return staticUA;
230 }
231
232 static void webkit_web_settings_finalize(GObject* object);
233
234 static void webkit_web_settings_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
235
236 static void webkit_web_settings_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec);
237
238 static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
239 {
240     GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
241     gobject_class->finalize = webkit_web_settings_finalize;
242     gobject_class->set_property = webkit_web_settings_set_property;
243     gobject_class->get_property = webkit_web_settings_get_property;
244
245     webkit_init();
246
247     GParamFlags flags = (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT);
248
249     g_object_class_install_property(gobject_class,
250                                     PROP_DEFAULT_ENCODING,
251                                     g_param_spec_string(
252                                     "default-encoding",
253                                     _("Default Encoding"),
254                                     _("The default encoding used to display text."),
255                                     "iso-8859-1",
256                                     flags));
257
258     g_object_class_install_property(gobject_class,
259                                     PROP_CURSIVE_FONT_FAMILY,
260                                     g_param_spec_string(
261                                     "cursive-font-family",
262                                     _("Cursive Font Family"),
263                                     _("The default Cursive font family used to display text."),
264                                     "serif",
265                                     flags));
266
267     g_object_class_install_property(gobject_class,
268                                     PROP_DEFAULT_FONT_FAMILY,
269                                     g_param_spec_string(
270                                     "default-font-family",
271                                     _("Default Font Family"),
272                                     _("The default font family used to display text."),
273                                     "sans-serif",
274                                     flags));
275
276     g_object_class_install_property(gobject_class,
277                                     PROP_FANTASY_FONT_FAMILY,
278                                     g_param_spec_string(
279                                     "fantasy-font-family",
280                                     _("Fantasy Font Family"),
281                                     _("The default Fantasy font family used to display text."),
282                                     "serif",
283                                     flags));
284
285     g_object_class_install_property(gobject_class,
286                                     PROP_MONOSPACE_FONT_FAMILY,
287                                     g_param_spec_string(
288                                     "monospace-font-family",
289                                     _("Monospace Font Family"),
290                                     _("The default font family used to display monospace text."),
291                                     "monospace",
292                                     flags));
293
294     g_object_class_install_property(gobject_class,
295                                     PROP_SANS_SERIF_FONT_FAMILY,
296                                     g_param_spec_string(
297                                     "sans-serif-font-family",
298                                     _("Sans Serif Font Family"),
299                                     _("The default Sans Serif font family used to display text."),
300                                     "sans-serif",
301                                     flags));
302
303     g_object_class_install_property(gobject_class,
304                                     PROP_SERIF_FONT_FAMILY,
305                                     g_param_spec_string(
306                                     "serif-font-family",
307                                     _("Serif Font Family"),
308                                     _("The default Serif font family used to display text."),
309                                     "serif",
310                                     flags));
311
312     g_object_class_install_property(gobject_class,
313                                     PROP_DEFAULT_FONT_SIZE,
314                                     g_param_spec_int(
315                                     "default-font-size",
316                                     _("Default Font Size"),
317                                     _("The default font size used to display text."),
318                                     5, G_MAXINT, 12,
319                                     flags));
320
321     g_object_class_install_property(gobject_class,
322                                     PROP_DEFAULT_MONOSPACE_FONT_SIZE,
323                                     g_param_spec_int(
324                                     "default-monospace-font-size",
325                                     _("Default Monospace Font Size"),
326                                     _("The default font size used to display monospace text."),
327                                     5, G_MAXINT, 10,
328                                     flags));
329
330     g_object_class_install_property(gobject_class,
331                                     PROP_MINIMUM_FONT_SIZE,
332                                     g_param_spec_int(
333                                     "minimum-font-size",
334                                     _("Minimum Font Size"),
335                                     _("The minimum font size used to display text."),
336                                     1, G_MAXINT, 5,
337                                     flags));
338
339     g_object_class_install_property(gobject_class,
340                                     PROP_MINIMUM_LOGICAL_FONT_SIZE,
341                                     g_param_spec_int(
342                                     "minimum-logical-font-size",
343                                     _("Minimum Logical Font Size"),
344                                     _("The minimum logical font size used to display text."),
345                                     1, G_MAXINT, 5,
346                                     flags));
347
348     /**
349     * WebKitWebSettings:enforce-96-dpi:
350     *
351     * Enforce a resolution of 96 DPI. This is meant for compatibility
352     * with web pages which cope badly with different screen resolutions
353     * and for automated testing.
354     * Web browsers and applications that typically display arbitrary
355     * content from the web should provide a preference for this.
356     *
357     * Since: 1.0.3
358     */
359     g_object_class_install_property(gobject_class,
360                                     PROP_ENFORCE_96_DPI,
361                                     g_param_spec_boolean(
362                                     "enforce-96-dpi",
363                                     _("Enforce 96 DPI"),
364                                     _("Enforce a resolution of 96 DPI"),
365                                     FALSE,
366                                     flags));
367
368     g_object_class_install_property(gobject_class,
369                                     PROP_AUTO_LOAD_IMAGES,
370                                     g_param_spec_boolean(
371                                     "auto-load-images",
372                                     _("Auto Load Images"),
373                                     _("Load images automatically."),
374                                     TRUE,
375                                     flags));
376
377     g_object_class_install_property(gobject_class,
378                                     PROP_AUTO_SHRINK_IMAGES,
379                                     g_param_spec_boolean(
380                                     "auto-shrink-images",
381                                     _("Auto Shrink Images"),
382                                     _("Automatically shrink standalone images to fit."),
383                                     TRUE,
384                                     flags));
385
386     g_object_class_install_property(gobject_class,
387                                     PROP_PRINT_BACKGROUNDS,
388                                     g_param_spec_boolean(
389                                     "print-backgrounds",
390                                     _("Print Backgrounds"),
391                                     _("Whether background images should be printed."),
392                                     TRUE,
393                                     flags));
394
395     g_object_class_install_property(gobject_class,
396                                     PROP_ENABLE_SCRIPTS,
397                                     g_param_spec_boolean(
398                                     "enable-scripts",
399                                     _("Enable Scripts"),
400                                     _("Enable embedded scripting languages."),
401                                     TRUE,
402                                     flags));
403
404     g_object_class_install_property(gobject_class,
405                                     PROP_ENABLE_PLUGINS,
406                                     g_param_spec_boolean(
407                                     "enable-plugins",
408                                     _("Enable Plugins"),
409                                     _("Enable embedded plugin objects."),
410                                     TRUE,
411                                     flags));
412
413     g_object_class_install_property(gobject_class,
414                                     PROP_RESIZABLE_TEXT_AREAS,
415                                     g_param_spec_boolean(
416                                     "resizable-text-areas",
417                                     _("Resizable Text Areas"),
418                                     _("Whether text areas are resizable."),
419                                     TRUE,
420                                     flags));
421
422     g_object_class_install_property(gobject_class,
423                                     PROP_USER_STYLESHEET_URI,
424                                     g_param_spec_string("user-stylesheet-uri",
425                                     _("User Stylesheet URI"),
426                                     _("The URI of a stylesheet that is applied to every page."),
427                                     0,
428                                     flags));
429
430     /**
431     * WebKitWebSettings:zoom-step:
432     *
433     * The value by which the zoom level is changed when zooming in or out.
434     *
435     * Since: 1.0.1
436     */
437     g_object_class_install_property(gobject_class,
438                                     PROP_ZOOM_STEP,
439                                     g_param_spec_float(
440                                     "zoom-step",
441                                     _("Zoom Stepping Value"),
442                                     _("The value by which the zoom level is changed when zooming in or out."),
443                                     0.0f, G_MAXFLOAT, 0.1f,
444                                     flags));
445
446     /**
447     * WebKitWebSettings:enable-developer-extras:
448     *
449     * Whether developer extensions should be enabled. This enables,
450     * for now, the Web Inspector, which can be controlled using the
451     * #WebKitWebInspector instance held by the #WebKitWebView this
452     * setting is enabled for.
453     *
454     * Since: 1.0.3
455     */
456     g_object_class_install_property(gobject_class,
457                                     PROP_ENABLE_DEVELOPER_EXTRAS,
458                                     g_param_spec_boolean(
459                                     "enable-developer-extras",
460                                     _("Enable Developer Extras"),
461                                     _("Enables special extensions that help developers"),
462                                     FALSE,
463                                     flags));
464
465     /**
466     * WebKitWebSettings:enable-private-browsing:
467     *
468     * Whether to enable private browsing mode. Private browsing mode prevents
469     * WebKit from updating the global history and storing any session
470     * information e.g., on-disk cache, as well as suppressing any messages
471     * from being printed into the (javascript) console.
472     *
473     * This is currently experimental for WebKitGtk.
474     *
475     * Since: 1.1.2
476     */
477     g_object_class_install_property(gobject_class,
478                                     PROP_ENABLE_PRIVATE_BROWSING,
479                                     g_param_spec_boolean(
480                                     "enable-private-browsing",
481                                     _("Enable Private Browsing"),
482                                     _("Enables private browsing mode"),
483                                     FALSE,
484                                     flags));
485
486     /**
487     * WebKitWebSettings:enable-spell-checking:
488     *
489     * Whether to enable spell checking while typing.
490     *
491     * Since: 1.1.6
492     */
493     g_object_class_install_property(gobject_class,
494                                     PROP_ENABLE_SPELL_CHECKING,
495                                     g_param_spec_boolean(
496                                     "enable-spell-checking",
497                                     _("Enable Spell Checking"),
498                                     _("Enables spell checking while typing"),
499                                     FALSE,
500                                     flags));
501
502     /**
503     * WebKitWebSettings:spell-checking-languages:
504     *
505     * The languages to be used for spell checking, separated by commas.
506     *
507     * The locale string typically is in the form lang_COUNTRY, where lang
508     * is an ISO-639 language code, and COUNTRY is an ISO-3166 country code.
509     * For instance, sv_FI for Swedish as written in Finland or pt_BR
510     * for Portuguese as written in Brazil.
511     *
512     * If no value is specified then the value returned by
513     * gtk_get_default_language will be used.
514     *
515     * Since: 1.1.6
516     */
517     g_object_class_install_property(gobject_class,
518                                     PROP_SPELL_CHECKING_LANGUAGES,
519                                     g_param_spec_string(
520                                     "spell-checking-languages",
521                                     _("Languages to use for spell checking"),
522                                     _("Comma separated list of languages to use for spell checking"),
523                                     0,
524                                     flags));
525
526     /**
527     * WebKitWebSettings:enable-caret-browsing:
528     *
529     * Whether to enable caret browsing mode.
530     *
531     * Since: 1.1.6
532     */
533     g_object_class_install_property(gobject_class,
534                                     PROP_ENABLE_CARET_BROWSING,
535                                     g_param_spec_boolean("enable-caret-browsing",
536                                                          _("Enable Caret Browsing"),
537                                                          _("Whether to enable accesibility enhanced keyboard navigation"),
538                                                          FALSE,
539                                                          flags));
540     /**
541     * WebKitWebSettings:enable-html5-database:
542     *
543     * Whether to enable HTML5 client-side SQL database support. Client-side
544     * SQL database allows web pages to store structured data and be able to
545     * use SQL to manipulate that data asynchronously.
546     *
547     * Since: 1.1.8
548     */
549     g_object_class_install_property(gobject_class,
550                                     PROP_ENABLE_HTML5_DATABASE,
551                                     g_param_spec_boolean("enable-html5-database",
552                                                          _("Enable HTML5 Database"),
553                                                          _("Whether to enable HTML5 database support"),
554                                                          TRUE,
555                                                          flags));
556
557     /**
558     * WebKitWebSettings:enable-html5-local-storage:
559     *
560     * Whether to enable HTML5 localStorage support. localStorage provides
561     * simple synchronous storage access.
562     *
563     * Since: 1.1.8
564     */
565     g_object_class_install_property(gobject_class,
566                                     PROP_ENABLE_HTML5_LOCAL_STORAGE,
567                                     g_param_spec_boolean("enable-html5-local-storage",
568                                                          _("Enable HTML5 Local Storage"),
569                                                          _("Whether to enable HTML5 Local Storage support"),
570                                                          TRUE,
571                                                          flags));
572     /**
573     * WebKitWebSettings:enable-xss-auditor
574     *
575     * Whether to enable the XSS Auditor. This feature filters some kinds of
576     * reflective XSS attacks on vulnerable web sites.
577     *
578     * Since: 1.1.11
579     */
580     g_object_class_install_property(gobject_class,
581                                     PROP_ENABLE_XSS_AUDITOR,
582                                     g_param_spec_boolean("enable-xss-auditor",
583                                                          _("Enable XSS Auditor"),
584                                                          _("Whether to enable the XSS auditor"),
585                                                          TRUE,
586                                                          flags));
587     /**
588     * WebKitWebSettings:enable-spatial-navigation
589     *
590     * Whether to enable the Spatial Navigation. This feature consists in the ability
591     * to navigate between focusable elements in a Web page, such as hyperlinks and
592     * form controls, by using Left, Right, Up and Down arrow keys. For example, if
593     * an user presses the Right key, heuristics determine whether there is an element
594     * he might be trying to reach towards the right, and if there are multiple elements,
595     * which element he probably wants.
596     *
597     * Since: 1.1.23
598     */
599     g_object_class_install_property(gobject_class,
600                                     PROP_ENABLE_SPATIAL_NAVIGATION,
601                                     g_param_spec_boolean("enable-spatial-navigation",
602                                                          _("Enable Spatial Navigation"),
603                                                          _("Whether to enable Spatial Navigation"),
604                                                          FALSE,
605                                                          flags));
606     /**
607     * WebKitWebSettings:enable-frame-flattening
608     *
609     * Whether to enable the Frame Flattening. With this setting each subframe is expanded
610     * to its contents, which will flatten all the frames to become one scrollable page.
611     * On touch devices, it is desired to not have any scrollable sub parts of the page as
612     * it results in a confusing user experience, with scrolling sometimes scrolling sub parts
613     * and at other times scrolling the page itself. For this reason iframes and framesets are
614     * barely usable on touch devices.
615     *
616     * Since: 1.3.5
617     */
618     g_object_class_install_property(gobject_class,
619                                     PROP_ENABLE_FRAME_FLATTENING,
620                                     g_param_spec_boolean("enable-frame-flattening",
621                                                          _("Enable Frame Flattening"),
622                                                          _("Whether to enable Frame Flattening"),
623                                                          FALSE,
624                                                          flags));
625     /**
626      * WebKitWebSettings:user-agent:
627      *
628      * The User-Agent string used by WebKitGtk.
629      *
630      * This will return a default User-Agent string if a custom string wasn't
631      * provided by the application. Setting this property to a NULL value or
632      * an empty string will result in the User-Agent string being reset to the
633      * default value.
634      *
635      * Since: 1.1.11
636      */
637     g_object_class_install_property(gobject_class, PROP_USER_AGENT,
638                                     g_param_spec_string("user-agent",
639                                                         _("User Agent"),
640                                                         _("The User-Agent string used by WebKitGtk"),
641                                                         webkitUserAgent().utf8().data(),
642                                                         flags));
643
644     /**
645     * WebKitWebSettings:javascript-can-open-windows-automatically
646     *
647     * Whether JavaScript can open popup windows automatically without user
648     * intervention.
649     *
650     * Since: 1.1.11
651     */
652     g_object_class_install_property(gobject_class,
653                                     PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
654                                     g_param_spec_boolean("javascript-can-open-windows-automatically",
655                                                          _("JavaScript can open windows automatically"),
656                                                          _("Whether JavaScript can open windows automatically"),
657                                                          FALSE,
658                                                          flags));
659
660     /**
661     * WebKitWebSettings:javascript-can-access-clipboard
662     *
663     * Whether JavaScript can access Clipboard.
664     *
665     * Since: 1.3.0
666     */
667     g_object_class_install_property(gobject_class,
668                                     PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD,
669                                     g_param_spec_boolean("javascript-can-access-clipboard",
670                                                          _("JavaScript can access Clipboard"),
671                                                          _("Whether JavaScript can access Clipboard"),
672                                                          FALSE,
673                                                          flags));
674
675     /**
676     * WebKitWebSettings:enable-offline-web-application-cache
677     *
678     * Whether to enable HTML5 offline web application cache support. Offline
679     * Web Application Cache ensures web applications are available even when
680     * the user is not connected to the network.
681     *
682     * Since: 1.1.13
683     */
684     g_object_class_install_property(gobject_class,
685                                     PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
686                                     g_param_spec_boolean("enable-offline-web-application-cache",
687                                                          _("Enable offline web application cache"),
688                                                          _("Whether to enable offline web application cache"),
689                                                          TRUE,
690                                                          flags));
691
692     COMPILE_ASSERT(static_cast<int>(WEBKIT_EDITING_BEHAVIOR_MAC) == static_cast<int>(WebCore::EditingMacBehavior), editing_behavior_type_mac_match);
693     COMPILE_ASSERT(static_cast<int>(WEBKIT_EDITING_BEHAVIOR_WINDOWS) == static_cast<int>(WebCore::EditingWindowsBehavior), editing_behavior_type_windows_match);
694     COMPILE_ASSERT(static_cast<int>(WEBKIT_EDITING_BEHAVIOR_UNIX) == static_cast<int>(WebCore::EditingUnixBehavior), editing_behavior_type_unix_match);
695
696     /**
697     * WebKitWebSettings:editing-behavior
698     *
699     * This setting controls various editing behaviors that differ
700     * between platforms and that have been combined in two groups,
701     * 'Mac' and 'Windows'. Some examples:
702     * 
703     *  1) Clicking below the last line of an editable area puts the
704     * caret at the end of the last line on Mac, but in the middle of
705     * the last line on Windows.
706     *
707     *  2) Pushing down the arrow key on the last line puts the caret
708     *  at the end of the last line on Mac, but does nothing on
709     *  Windows. A similar case exists on the top line.
710     *
711     * Since: 1.1.13
712     */
713     g_object_class_install_property(gobject_class,
714                                     PROP_EDITING_BEHAVIOR,
715                                     g_param_spec_enum("editing-behavior",
716                                                       _("Editing behavior"),
717                                                       _("The behavior mode to use in editing mode"),
718                                                       WEBKIT_TYPE_EDITING_BEHAVIOR,
719                                                       WEBKIT_EDITING_BEHAVIOR_UNIX,
720                                                       flags));
721
722     /**
723      * WebKitWebSettings:enable-universal-access-from-file-uris
724      *
725      * Whether to allow files loaded through file:// URIs universal access to
726      * all pages.
727      *
728      * Since: 1.1.13
729      */
730     g_object_class_install_property(gobject_class,
731                                     PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS,
732                                     g_param_spec_boolean("enable-universal-access-from-file-uris",
733                                                          _("Enable universal access from file URIs"),
734                                                          _("Whether to allow universal access from file URIs"),
735                                                          FALSE,
736                                                          flags));
737
738     /**
739      * WebKitWebSettings:enable-dom-paste
740      *
741      * Whether to enable DOM paste. If set to %TRUE, document.execCommand("Paste")
742      * will correctly execute and paste content of the clipboard.
743      *
744      * Since: 1.1.16
745      */
746     g_object_class_install_property(gobject_class,
747                                     PROP_ENABLE_DOM_PASTE,
748                                     g_param_spec_boolean("enable-dom-paste",
749                                                          _("Enable DOM paste"),
750                                                          _("Whether to enable DOM paste"),
751                                                          FALSE,
752                                                          flags));
753     /**
754     * WebKitWebSettings:tab-key-cycles-through-elements:
755     *
756     * Whether the tab key cycles through elements on the page.
757     *
758     * If @flag is %TRUE, pressing the tab key will focus the next element in
759     * the @web_view. If @flag is %FALSE, the @web_view will interpret tab
760     * key presses as normal key presses. If the selected element is editable, the
761     * tab key will cause the insertion of a tab character.
762     *
763     * Since: 1.1.17
764     */
765     g_object_class_install_property(gobject_class,
766                                     PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS,
767                                     g_param_spec_boolean("tab-key-cycles-through-elements",
768                                                          _("Tab key cycles through elements"),
769                                                          _("Whether the tab key cycles through elements on the page."),
770                                                          TRUE,
771                                                          flags));
772
773     /**
774      * WebKitWebSettings:enable-default-context-menu:
775      *
776      * Whether right-clicks should be handled automatically to create,
777      * and display the context menu. Turning this off will make
778      * WebKitGTK+ not emit the populate-popup signal. Notice that the
779      * default button press event handler may still handle right
780      * clicks for other reasons, such as in-page context menus, or
781      * right-clicks that are handled by the page itself.
782      *
783      * Since: 1.1.18
784      */
785     g_object_class_install_property(gobject_class,
786                                     PROP_ENABLE_DEFAULT_CONTEXT_MENU,
787                                     g_param_spec_boolean(
788                                     "enable-default-context-menu",
789                                     _("Enable Default Context Menu"),
790                                     _("Enables the handling of right-clicks for the creation of the default context menu"),
791                                     TRUE,
792                                     flags));
793
794     /**
795      * WebKitWebSettings::enable-site-specific-quirks
796      *
797      * Whether to turn on site-specific hacks.  Turning this on will
798      * tell WebKitGTK+ to use some site-specific workarounds for
799      * better web compatibility.  For example, older versions of
800      * MediaWiki will incorrectly send WebKit a css file with KHTML
801      * workarounds.  By turning on site-specific quirks, WebKit will
802      * special-case this and other cases to make the sites work.
803      *
804      * Since: 1.1.18
805      */
806     g_object_class_install_property(gobject_class,
807                                     PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
808                                     g_param_spec_boolean(
809                                     "enable-site-specific-quirks",
810                                     _("Enable Site Specific Quirks"),
811                                     _("Enables the site-specific compatibility workarounds"),
812                                     FALSE,
813                                     flags));
814
815     /**
816     * WebKitWebSettings:enable-page-cache:
817     *
818     * Enable or disable the page cache. Disabling the page cache is
819     * generally only useful for special circumstances like low-memory
820     * scenarios or special purpose applications like static HTML
821     * viewers. This setting only controls the Page Cache, this cache
822     * is different than the disk-based or memory-based traditional
823     * resource caches, its point is to make going back and forth
824     * between pages much faster. For details about the different types
825     * of caches and their purposes see:
826     * http://webkit.org/blog/427/webkit-page-cache-i-the-basics/
827     *
828     * Since: 1.1.18
829     */
830     g_object_class_install_property(gobject_class,
831                                     PROP_ENABLE_PAGE_CACHE,
832                                     g_param_spec_boolean("enable-page-cache",
833                                                          _("Enable page cache"),
834                                                          _("Whether the page cache should be used"),
835                                                          FALSE,
836                                                          flags));
837
838     /**
839     * WebKitWebSettings:auto-resize-window:
840     *
841     * Web pages can request to modify the size and position of the
842     * window containing the #WebKitWebView through various DOM methods
843     * (resizeTo, moveTo, resizeBy, moveBy). By default WebKit will not
844     * honor this requests, but you can set this property to %TRUE if
845     * you'd like it to do so. If you wish to handle this manually, you
846     * can connect to the notify signal for the
847     * #WebKitWebWindowFeatures of your #WebKitWebView.
848     * 
849     * Since: 1.1.22
850     */
851     g_object_class_install_property(gobject_class,
852                                     PROP_AUTO_RESIZE_WINDOW,
853                                     g_param_spec_boolean("auto-resize-window",
854                                                          _("Auto Resize Window"),
855                                                          _("Automatically resize the toplevel window when a page requests it"),
856                                                          FALSE,
857                                                          flags));
858
859     /**
860      * WebKitWebSettings:enable-file-access-from-file-uris:
861      *
862      * Boolean property to control file access for file:// URIs. If this
863      * option is enabled every file:// will have its own security unique domain.
864      *
865      * Since: 1.1.22
866      */
867      g_object_class_install_property(gobject_class,
868                                      PROP_ENABLE_FILE_ACCESS_FROM_FILE_URIS,
869                                      g_param_spec_boolean("enable-file-access-from-file-uris",
870                                                           "Enable file access from file URIs",
871                                                           "Controls file access for file:// URIs.",
872                                                           FALSE,
873                                                           flags));
874
875    /**
876     * WebKitWebSettings:enable-java-applet:
877     *
878     * Enable or disable support for the Java &lt;applet&gt; tag. Keep in
879     * mind that Java content can be still shown in the page through
880     * &lt;object&gt; or &lt;embed&gt;, which are the preferred tags for this task.
881     *
882     * Since: 1.1.22
883     */
884     g_object_class_install_property(gobject_class,
885                                     PROP_ENABLE_JAVA_APPLET,
886                                     g_param_spec_boolean("enable-java-applet",
887                                                          _("Enable Java Applet"),
888                                                          _("Whether Java Applet support through <applet> should be enabled"),
889                                                          TRUE,
890                                                          flags));
891
892     /**
893     * WebKitWebSettings:enable-hyperlink-auditing:
894     *
895     * Enable or disable support for <a ping>.
896     *
897     * Since: 1.2.5
898     */
899     g_object_class_install_property(gobject_class,
900                                     PROP_ENABLE_HYPERLINK_AUDITING,
901                                     g_param_spec_boolean("enable-hyperlink-auditing",
902                                                          _("Enable Hyperlink Auditing"),
903                                                          _("Whether <a ping> should be able to send pings"),
904                                                          FALSE,
905                                                          flags));
906
907     /* Undocumented for now */
908     g_object_class_install_property(gobject_class,
909                                     PROP_ENABLE_FULLSCREEN,
910                                     g_param_spec_boolean("enable-fullscreen",
911                                                          _("Enable Fullscreen"),
912                                                          _("Whether the Mozilla style API should be enabled."),
913                                                          FALSE,
914                                                          flags));
915
916     g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate));
917 }
918
919 static void webkit_web_settings_init(WebKitWebSettings* web_settings)
920 {
921     web_settings->priv = WEBKIT_WEB_SETTINGS_GET_PRIVATE(web_settings);
922 }
923
924 static EnchantBroker* get_enchant_broker()
925 {
926     static EnchantBroker* broker = 0;
927     if (!broker)
928         broker = enchant_broker_init();
929
930     return broker;
931 }
932
933 static void free_spell_checking_language(gpointer data, gpointer user_data)
934 {
935     EnchantDict* dict = static_cast<EnchantDict*>(data);
936     EnchantBroker* broker = get_enchant_broker();
937
938     enchant_broker_free_dict(broker, dict);
939 }
940
941 static void webkit_web_settings_finalize(GObject* object)
942 {
943     WebKitWebSettings* web_settings = WEBKIT_WEB_SETTINGS(object);
944     WebKitWebSettingsPrivate* priv = web_settings->priv;
945
946     g_free(priv->default_encoding);
947     g_free(priv->cursive_font_family);
948     g_free(priv->default_font_family);
949     g_free(priv->fantasy_font_family);
950     g_free(priv->monospace_font_family);
951     g_free(priv->sans_serif_font_family);
952     g_free(priv->serif_font_family);
953     g_free(priv->user_stylesheet_uri);
954     g_free(priv->spell_checking_languages);
955
956     g_slist_foreach(priv->enchant_dicts, free_spell_checking_language, 0);
957     g_slist_free(priv->enchant_dicts);
958
959     g_free(priv->user_agent);
960
961     G_OBJECT_CLASS(webkit_web_settings_parent_class)->finalize(object);
962 }
963
964 static void webkit_web_settings_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
965 {
966     WebKitWebSettings* web_settings = WEBKIT_WEB_SETTINGS(object);
967     WebKitWebSettingsPrivate* priv = web_settings->priv;
968     EnchantBroker* broker;
969     EnchantDict* dict;
970     GSList* spellDictionaries = 0;
971
972     switch(prop_id) {
973     case PROP_DEFAULT_ENCODING:
974         g_free(priv->default_encoding);
975         priv->default_encoding = g_strdup(g_value_get_string(value));
976         break;
977     case PROP_CURSIVE_FONT_FAMILY:
978         g_free(priv->cursive_font_family);
979         priv->cursive_font_family = g_strdup(g_value_get_string(value));
980         break;
981     case PROP_DEFAULT_FONT_FAMILY:
982         g_free(priv->default_font_family);
983         priv->default_font_family = g_strdup(g_value_get_string(value));
984         break;
985     case PROP_FANTASY_FONT_FAMILY:
986         g_free(priv->fantasy_font_family);
987         priv->fantasy_font_family = g_strdup(g_value_get_string(value));
988         break;
989     case PROP_MONOSPACE_FONT_FAMILY:
990         g_free(priv->monospace_font_family);
991         priv->monospace_font_family = g_strdup(g_value_get_string(value));
992         break;
993     case PROP_SANS_SERIF_FONT_FAMILY:
994         g_free(priv->sans_serif_font_family);
995         priv->sans_serif_font_family = g_strdup(g_value_get_string(value));
996         break;
997     case PROP_SERIF_FONT_FAMILY:
998         g_free(priv->serif_font_family);
999         priv->serif_font_family = g_strdup(g_value_get_string(value));
1000         break;
1001     case PROP_DEFAULT_FONT_SIZE:
1002         priv->default_font_size = g_value_get_int(value);
1003         break;
1004     case PROP_DEFAULT_MONOSPACE_FONT_SIZE:
1005         priv->default_monospace_font_size = g_value_get_int(value);
1006         break;
1007     case PROP_MINIMUM_FONT_SIZE:
1008         priv->minimum_font_size = g_value_get_int(value);
1009         break;
1010     case PROP_MINIMUM_LOGICAL_FONT_SIZE:
1011         priv->minimum_logical_font_size = g_value_get_int(value);
1012         break;
1013     case PROP_ENFORCE_96_DPI:
1014         priv->enforce_96_dpi = g_value_get_boolean(value);
1015         break;
1016     case PROP_AUTO_LOAD_IMAGES:
1017         priv->auto_load_images = g_value_get_boolean(value);
1018         break;
1019     case PROP_AUTO_SHRINK_IMAGES:
1020         priv->auto_shrink_images = g_value_get_boolean(value);
1021         break;
1022     case PROP_PRINT_BACKGROUNDS:
1023         priv->print_backgrounds = g_value_get_boolean(value);
1024         break;
1025     case PROP_ENABLE_SCRIPTS:
1026         priv->enable_scripts = g_value_get_boolean(value);
1027         break;
1028     case PROP_ENABLE_PLUGINS:
1029         priv->enable_plugins = g_value_get_boolean(value);
1030         break;
1031     case PROP_RESIZABLE_TEXT_AREAS:
1032         priv->resizable_text_areas = g_value_get_boolean(value);
1033         break;
1034     case PROP_USER_STYLESHEET_URI:
1035         g_free(priv->user_stylesheet_uri);
1036         priv->user_stylesheet_uri = g_strdup(g_value_get_string(value));
1037         break;
1038     case PROP_ZOOM_STEP:
1039         priv->zoom_step = g_value_get_float(value);
1040         break;
1041     case PROP_ENABLE_DEVELOPER_EXTRAS:
1042         priv->enable_developer_extras = g_value_get_boolean(value);
1043         break;
1044     case PROP_ENABLE_PRIVATE_BROWSING:
1045         priv->enable_private_browsing = g_value_get_boolean(value);
1046         break;
1047     case PROP_ENABLE_CARET_BROWSING:
1048         priv->enable_caret_browsing = g_value_get_boolean(value);
1049         break;
1050     case PROP_ENABLE_HTML5_DATABASE:
1051         priv->enable_html5_database = g_value_get_boolean(value);
1052         break;
1053     case PROP_ENABLE_HTML5_LOCAL_STORAGE:
1054         priv->enable_html5_local_storage = g_value_get_boolean(value);
1055         break;
1056     case PROP_ENABLE_SPELL_CHECKING:
1057         priv->enable_spell_checking = g_value_get_boolean(value);
1058         break;
1059     case PROP_SPELL_CHECKING_LANGUAGES:
1060         g_free(priv->spell_checking_languages);
1061         priv->spell_checking_languages = g_strdup(g_value_get_string(value));
1062
1063         broker = get_enchant_broker();
1064         if (priv->spell_checking_languages) {
1065             char** langs = g_strsplit(priv->spell_checking_languages, ",", -1);
1066             for (int i = 0; langs[i]; i++) {
1067                 if (enchant_broker_dict_exists(broker, langs[i])) {
1068                     dict = enchant_broker_request_dict(broker, langs[i]);
1069                     spellDictionaries = g_slist_append(spellDictionaries, dict);
1070                 }
1071             }
1072             g_strfreev(langs);
1073         } else {
1074             const char* language = pango_language_to_string(gtk_get_default_language());
1075             if (enchant_broker_dict_exists(broker, language)) {
1076                 dict = enchant_broker_request_dict(broker, language);
1077                 spellDictionaries = g_slist_append(spellDictionaries, dict);
1078             }
1079         }
1080         g_slist_foreach(priv->enchant_dicts, free_spell_checking_language, 0);
1081         g_slist_free(priv->enchant_dicts);
1082         priv->enchant_dicts = spellDictionaries;
1083         break;
1084     case PROP_ENABLE_XSS_AUDITOR:
1085         priv->enable_xss_auditor = g_value_get_boolean(value);
1086         break;
1087     case PROP_ENABLE_SPATIAL_NAVIGATION:
1088         priv->enable_spatial_navigation = g_value_get_boolean(value);
1089         break;
1090     case PROP_ENABLE_FRAME_FLATTENING:
1091         priv->enable_frame_flattening = g_value_get_boolean(value);
1092         break;
1093     case PROP_USER_AGENT:
1094         g_free(priv->user_agent);
1095         if (!g_value_get_string(value) || !strlen(g_value_get_string(value)))
1096             priv->user_agent = g_strdup(webkitUserAgent().utf8().data());
1097         else
1098             priv->user_agent = g_strdup(g_value_get_string(value));
1099         break;
1100     case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
1101         priv->javascript_can_open_windows_automatically = g_value_get_boolean(value);
1102         break;
1103     case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD:
1104         priv->javascript_can_access_clipboard = g_value_get_boolean(value);
1105         break;
1106     case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
1107         priv->enable_offline_web_application_cache = g_value_get_boolean(value);
1108         break;
1109     case PROP_EDITING_BEHAVIOR:
1110         priv->editing_behavior = static_cast<WebKitEditingBehavior>(g_value_get_enum(value));
1111         break;
1112     case PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS:
1113         priv->enable_universal_access_from_file_uris = g_value_get_boolean(value);
1114         break;
1115     case PROP_ENABLE_FILE_ACCESS_FROM_FILE_URIS:
1116         priv->enable_file_access_from_file_uris = g_value_get_boolean(value);
1117         break;
1118     case PROP_ENABLE_DOM_PASTE:
1119         priv->enable_dom_paste = g_value_get_boolean(value);
1120         break;
1121     case PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS:
1122         priv->tab_key_cycles_through_elements = g_value_get_boolean(value);
1123         break;
1124     case PROP_ENABLE_DEFAULT_CONTEXT_MENU:
1125         priv->enable_default_context_menu = g_value_get_boolean(value);
1126         break;
1127     case PROP_ENABLE_SITE_SPECIFIC_QUIRKS:
1128         priv->enable_site_specific_quirks = g_value_get_boolean(value);
1129         break;
1130     case PROP_ENABLE_PAGE_CACHE:
1131         priv->enable_page_cache = g_value_get_boolean(value);
1132         break;
1133     case PROP_AUTO_RESIZE_WINDOW:
1134         priv->auto_resize_window = g_value_get_boolean(value);
1135         break;
1136     case PROP_ENABLE_JAVA_APPLET:
1137         priv->enable_java_applet = g_value_get_boolean(value);
1138         break;
1139     case PROP_ENABLE_HYPERLINK_AUDITING:
1140         priv->enable_hyperlink_auditing = g_value_get_boolean(value);
1141         break;
1142     case PROP_ENABLE_FULLSCREEN:
1143         priv->enable_fullscreen = g_value_get_boolean(value);
1144         break;
1145     default:
1146         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1147         break;
1148     }
1149 }
1150
1151 static void webkit_web_settings_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
1152 {
1153     WebKitWebSettings* web_settings = WEBKIT_WEB_SETTINGS(object);
1154     WebKitWebSettingsPrivate* priv = web_settings->priv;
1155
1156     switch (prop_id) {
1157     case PROP_DEFAULT_ENCODING:
1158         g_value_set_string(value, priv->default_encoding);
1159         break;
1160     case PROP_CURSIVE_FONT_FAMILY:
1161         g_value_set_string(value, priv->cursive_font_family);
1162         break;
1163     case PROP_DEFAULT_FONT_FAMILY:
1164         g_value_set_string(value, priv->default_font_family);
1165         break;
1166     case PROP_FANTASY_FONT_FAMILY:
1167         g_value_set_string(value, priv->fantasy_font_family);
1168         break;
1169     case PROP_MONOSPACE_FONT_FAMILY:
1170         g_value_set_string(value, priv->monospace_font_family);
1171         break;
1172     case PROP_SANS_SERIF_FONT_FAMILY:
1173         g_value_set_string(value, priv->sans_serif_font_family);
1174         break;
1175     case PROP_SERIF_FONT_FAMILY:
1176         g_value_set_string(value, priv->serif_font_family);
1177         break;
1178     case PROP_DEFAULT_FONT_SIZE:
1179         g_value_set_int(value, priv->default_font_size);
1180         break;
1181     case PROP_DEFAULT_MONOSPACE_FONT_SIZE:
1182         g_value_set_int(value, priv->default_monospace_font_size);
1183         break;
1184     case PROP_MINIMUM_FONT_SIZE:
1185         g_value_set_int(value, priv->minimum_font_size);
1186         break;
1187     case PROP_MINIMUM_LOGICAL_FONT_SIZE:
1188         g_value_set_int(value, priv->minimum_logical_font_size);
1189         break;
1190     case PROP_ENFORCE_96_DPI:
1191         g_value_set_boolean(value, priv->enforce_96_dpi);
1192         break;
1193     case PROP_AUTO_LOAD_IMAGES:
1194         g_value_set_boolean(value, priv->auto_load_images);
1195         break;
1196     case PROP_AUTO_SHRINK_IMAGES:
1197         g_value_set_boolean(value, priv->auto_shrink_images);
1198         break;
1199     case PROP_PRINT_BACKGROUNDS:
1200         g_value_set_boolean(value, priv->print_backgrounds);
1201         break;
1202     case PROP_ENABLE_SCRIPTS:
1203         g_value_set_boolean(value, priv->enable_scripts);
1204         break;
1205     case PROP_ENABLE_PLUGINS:
1206         g_value_set_boolean(value, priv->enable_plugins);
1207         break;
1208     case PROP_RESIZABLE_TEXT_AREAS:
1209         g_value_set_boolean(value, priv->resizable_text_areas);
1210         break;
1211     case PROP_USER_STYLESHEET_URI:
1212         g_value_set_string(value, priv->user_stylesheet_uri);
1213         break;
1214     case PROP_ZOOM_STEP:
1215         g_value_set_float(value, priv->zoom_step);
1216         break;
1217     case PROP_ENABLE_DEVELOPER_EXTRAS:
1218         g_value_set_boolean(value, priv->enable_developer_extras);
1219         break;
1220     case PROP_ENABLE_PRIVATE_BROWSING:
1221         g_value_set_boolean(value, priv->enable_private_browsing);
1222         break;
1223     case PROP_ENABLE_CARET_BROWSING:
1224         g_value_set_boolean(value, priv->enable_caret_browsing);
1225         break;
1226     case PROP_ENABLE_HTML5_DATABASE:
1227         g_value_set_boolean(value, priv->enable_html5_database);
1228         break;
1229     case PROP_ENABLE_HTML5_LOCAL_STORAGE:
1230         g_value_set_boolean(value, priv->enable_html5_local_storage);
1231         break;
1232     case PROP_ENABLE_SPELL_CHECKING:
1233         g_value_set_boolean(value, priv->enable_spell_checking);
1234         break;
1235     case PROP_SPELL_CHECKING_LANGUAGES:
1236         g_value_set_string(value, priv->spell_checking_languages);
1237         break;
1238     case PROP_ENABLE_XSS_AUDITOR:
1239         g_value_set_boolean(value, priv->enable_xss_auditor);
1240         break;
1241     case PROP_ENABLE_SPATIAL_NAVIGATION:
1242         g_value_set_boolean(value, priv->enable_spatial_navigation);
1243         break;
1244     case PROP_ENABLE_FRAME_FLATTENING:
1245         g_value_set_boolean(value, priv->enable_frame_flattening);
1246         break;
1247     case PROP_USER_AGENT:
1248         g_value_set_string(value, priv->user_agent);
1249         break;
1250     case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
1251         g_value_set_boolean(value, priv->javascript_can_open_windows_automatically);
1252         break;
1253     case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD:
1254         g_value_set_boolean(value, priv->javascript_can_access_clipboard);
1255         break;
1256     case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
1257         g_value_set_boolean(value, priv->enable_offline_web_application_cache);
1258         break;
1259     case PROP_EDITING_BEHAVIOR:
1260         g_value_set_enum(value, priv->editing_behavior);
1261         break;
1262     case PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS:
1263         g_value_set_boolean(value, priv->enable_universal_access_from_file_uris);
1264         break;
1265     case PROP_ENABLE_FILE_ACCESS_FROM_FILE_URIS:
1266         g_value_set_boolean(value, priv->enable_file_access_from_file_uris);
1267         break;
1268     case PROP_ENABLE_DOM_PASTE:
1269         g_value_set_boolean(value, priv->enable_dom_paste);
1270         break;
1271     case PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS:
1272         g_value_set_boolean(value, priv->tab_key_cycles_through_elements);
1273         break;
1274     case PROP_ENABLE_DEFAULT_CONTEXT_MENU:
1275         g_value_set_boolean(value, priv->enable_default_context_menu);
1276         break;
1277     case PROP_ENABLE_SITE_SPECIFIC_QUIRKS:
1278         g_value_set_boolean(value, priv->enable_site_specific_quirks);
1279         break;
1280     case PROP_ENABLE_PAGE_CACHE:
1281         g_value_set_boolean(value, priv->enable_page_cache);
1282         break;
1283     case PROP_AUTO_RESIZE_WINDOW:
1284         g_value_set_boolean(value, priv->auto_resize_window);
1285         break;
1286     case PROP_ENABLE_JAVA_APPLET:
1287         g_value_set_boolean(value, priv->enable_java_applet);
1288         break;
1289     case PROP_ENABLE_HYPERLINK_AUDITING:
1290         g_value_set_boolean(value, priv->enable_hyperlink_auditing);
1291         break;
1292     case PROP_ENABLE_FULLSCREEN:
1293         g_value_set_boolean(value, priv->enable_fullscreen);
1294         break;
1295     default:
1296         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1297         break;
1298     }
1299 }
1300
1301 /**
1302  * webkit_web_settings_new:
1303  *
1304  * Creates a new #WebKitWebSettings instance with default values. It must
1305  * be manually attached to a WebView.
1306  *
1307  * Returns: a new #WebKitWebSettings instance
1308  **/
1309 WebKitWebSettings* webkit_web_settings_new()
1310 {
1311     return WEBKIT_WEB_SETTINGS(g_object_new(WEBKIT_TYPE_WEB_SETTINGS, NULL));
1312 }
1313
1314 /**
1315  * webkit_web_settings_copy:
1316  *
1317  * Copies an existing #WebKitWebSettings instance.
1318  *
1319  * Returns: (transfer full): a new #WebKitWebSettings instance
1320  **/
1321 WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings)
1322 {
1323     WebKitWebSettingsPrivate* priv = web_settings->priv;
1324
1325     WebKitWebSettings* copy = WEBKIT_WEB_SETTINGS(g_object_new(WEBKIT_TYPE_WEB_SETTINGS,
1326                  "default-encoding", priv->default_encoding,
1327                  "cursive-font-family", priv->cursive_font_family,
1328                  "default-font-family", priv->default_font_family,
1329                  "fantasy-font-family", priv->fantasy_font_family,
1330                  "monospace-font-family", priv->monospace_font_family,
1331                  "sans-serif-font-family", priv->sans_serif_font_family,
1332                  "serif-font-family", priv->serif_font_family,
1333                  "default-font-size", priv->default_font_size,
1334                  "default-monospace-font-size", priv->default_monospace_font_size,
1335                  "minimum-font-size", priv->minimum_font_size,
1336                  "minimum-logical-font-size", priv->minimum_logical_font_size,
1337                  "auto-load-images", priv->auto_load_images,
1338                  "auto-shrink-images", priv->auto_shrink_images,
1339                  "print-backgrounds", priv->print_backgrounds,
1340                  "enable-scripts", priv->enable_scripts,
1341                  "enable-plugins", priv->enable_plugins,
1342                  "resizable-text-areas", priv->resizable_text_areas,
1343                  "user-stylesheet-uri", priv->user_stylesheet_uri,
1344                  "zoom-step", priv->zoom_step,
1345                  "enable-developer-extras", priv->enable_developer_extras,
1346                  "enable-private-browsing", priv->enable_private_browsing,
1347                  "enable-spell-checking", priv->enable_spell_checking,
1348                  "spell-checking-languages", priv->spell_checking_languages,
1349                  "enable-caret-browsing", priv->enable_caret_browsing,
1350                  "enable-html5-database", priv->enable_html5_database,
1351                  "enable-html5-local-storage", priv->enable_html5_local_storage,
1352                  "enable-xss-auditor", priv->enable_xss_auditor,
1353                  "enable-spatial-navigation", priv->enable_spatial_navigation,
1354                  "enable-frame-flattening", priv->enable_frame_flattening,
1355                  "user-agent", webkit_web_settings_get_user_agent(web_settings),
1356                  "javascript-can-open-windows-automatically", priv->javascript_can_open_windows_automatically,
1357                  "javascript-can-access-clipboard", priv->javascript_can_access_clipboard,
1358                  "enable-offline-web-application-cache", priv->enable_offline_web_application_cache,
1359                  "editing-behavior", priv->editing_behavior,
1360                  "enable-universal-access-from-file-uris", priv->enable_universal_access_from_file_uris,
1361                  "enable-file-access-from-file-uris", priv->enable_file_access_from_file_uris,
1362                  "enable-dom-paste", priv->enable_dom_paste,
1363                  "tab-key-cycles-through-elements", priv->tab_key_cycles_through_elements,
1364                  "enable-default-context-menu", priv->enable_default_context_menu,
1365                  "enable-site-specific-quirks", priv->enable_site_specific_quirks,
1366                  "enable-page-cache", priv->enable_page_cache,
1367                  "auto-resize-window", priv->auto_resize_window,
1368                  "enable-java-applet", priv->enable_java_applet,
1369                  "enable-hyperlink-auditing", priv->enable_hyperlink_auditing,
1370                  "enable-fullscreen", priv->enable_fullscreen,
1371                  NULL));
1372
1373     return copy;
1374 }
1375
1376 /**
1377  * webkit_web_settings_add_extra_plugin_directory:
1378  * @web_view: a #WebKitWebView
1379  * @directory: the directory to add
1380  *
1381  * Adds the @directory to paths where @web_view will search for plugins.
1382  *
1383  * Since: 1.0.3
1384  */
1385 void webkit_web_settings_add_extra_plugin_directory(WebKitWebView* webView, const gchar* directory)
1386 {
1387     g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
1388
1389     PluginDatabase::installedPlugins()->addExtraPluginDirectory(filenameToString(directory));
1390 }
1391
1392 /**
1393  * webkit_web_settings_get_enchant_dicts:
1394  * @web_view: a #WebKitWebView
1395  *
1396  * Internal use only. Retrieves a GSList of EnchantDicts from the
1397  * #WebKitWebSettings of @web_view.
1398  *
1399  * Since: 1.1.22
1400  */
1401 GSList* webkit_web_settings_get_enchant_dicts(WebKitWebView* webView)
1402 {
1403     g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
1404
1405     WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
1406
1407     return settings->priv->enchant_dicts;
1408 }
1409
1410 /**
1411  * webkit_web_settings_get_user_agent:
1412  * @web_settings: a #WebKitWebSettings
1413  *
1414  * Returns the User-Agent string currently used by the web view(s) associated
1415  * with the @web_settings.
1416  *
1417  * Since: 1.1.11
1418  */
1419 G_CONST_RETURN gchar* webkit_web_settings_get_user_agent(WebKitWebSettings* webSettings)
1420 {
1421     g_return_val_if_fail(WEBKIT_IS_WEB_SETTINGS(webSettings), NULL);
1422
1423     WebKitWebSettingsPrivate* priv = webSettings->priv;
1424
1425     return priv->user_agent;
1426 }