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