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