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