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