[Gtk] allow building with css-shaders
[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 "KURL.h"
32 #include "PluginDatabase.h"
33 #include "UserAgentGtk.h"
34 #include "webkitenumtypes.h"
35 #include "webkitglobalsprivate.h"
36 #include "webkitversion.h"
37 #include "webkitwebsettingsprivate.h"
38 #include <wtf/gobject/GOwnPtr.h>
39 #include <wtf/text/CString.h>
40 #include <wtf/text/StringConcatenate.h>
41 #include <glib/gi18n-lib.h>
42
43 /**
44  * SECTION:webkitwebsettings
45  * @short_description: Control the behaviour of a #WebKitWebView
46  *
47  * #WebKitWebSettings can be applied to a #WebKitWebView to control text encoding, 
48  * color, font sizes, printing mode, script support, loading of images and various other things. 
49  * After creation, a #WebKitWebSettings object contains default settings. 
50  *
51  * <informalexample><programlisting>
52  * /<!-- -->* Create a new websettings and disable java script *<!-- -->/
53  * WebKitWebSettings *settings = webkit_web_settings_new ();
54  * g_object_set (G_OBJECT(settings), "enable-scripts", FALSE, NULL);
55  *
56  * /<!-- -->* Apply the result *<!-- -->/
57  * webkit_web_view_set_settings (WEBKIT_WEB_VIEW(my_webview), settings);
58  * </programlisting></informalexample>
59  */
60
61 using namespace WebCore;
62
63 G_DEFINE_TYPE(WebKitWebSettings, webkit_web_settings, G_TYPE_OBJECT)
64
65 enum {
66     PROP_0,
67
68     PROP_DEFAULT_ENCODING,
69     PROP_CURSIVE_FONT_FAMILY,
70     PROP_DEFAULT_FONT_FAMILY,
71     PROP_FANTASY_FONT_FAMILY,
72     PROP_MONOSPACE_FONT_FAMILY,
73     PROP_SANS_SERIF_FONT_FAMILY,
74     PROP_SERIF_FONT_FAMILY,
75     PROP_DEFAULT_FONT_SIZE,
76     PROP_DEFAULT_MONOSPACE_FONT_SIZE,
77     PROP_MINIMUM_FONT_SIZE,
78     PROP_MINIMUM_LOGICAL_FONT_SIZE,
79     PROP_ENFORCE_96_DPI,
80     PROP_AUTO_LOAD_IMAGES,
81     PROP_AUTO_SHRINK_IMAGES,
82     PROP_PRINT_BACKGROUNDS,
83     PROP_ENABLE_SCRIPTS,
84     PROP_ENABLE_PLUGINS,
85     PROP_RESIZABLE_TEXT_AREAS,
86     PROP_USER_STYLESHEET_URI,
87     PROP_ZOOM_STEP,
88     PROP_ENABLE_DEVELOPER_EXTRAS,
89     PROP_ENABLE_PRIVATE_BROWSING,
90     PROP_ENABLE_SPELL_CHECKING,
91     PROP_SPELL_CHECKING_LANGUAGES,
92     PROP_ENABLE_CARET_BROWSING,
93     PROP_ENABLE_HTML5_DATABASE,
94     PROP_ENABLE_HTML5_LOCAL_STORAGE,
95     PROP_HTML5_LOCAL_STORAGE_DATABASE_PATH,
96     PROP_ENABLE_XSS_AUDITOR,
97     PROP_ENABLE_SPATIAL_NAVIGATION,
98     PROP_ENABLE_FRAME_FLATTENING,
99     PROP_USER_AGENT,
100     PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
101     PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD,
102     PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
103     PROP_EDITING_BEHAVIOR,
104     PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS,
105     PROP_ENABLE_FILE_ACCESS_FROM_FILE_URIS,
106     PROP_ENABLE_DOM_PASTE,
107     PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS,
108     PROP_ENABLE_DEFAULT_CONTEXT_MENU,
109     PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
110     PROP_ENABLE_PAGE_CACHE,
111     PROP_AUTO_RESIZE_WINDOW,
112     PROP_ENABLE_JAVA_APPLET,
113     PROP_ENABLE_HYPERLINK_AUDITING,
114     PROP_ENABLE_FULLSCREEN,
115     PROP_ENABLE_DNS_PREFETCHING,
116     PROP_ENABLE_WEBGL,
117     PROP_ENABLE_WEB_AUDIO,
118     PROP_ENABLE_ACCELERATED_COMPOSITING,
119     PROP_ENABLE_SMOOTH_SCROLLING,
120     PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE,
121     PROP_MEDIA_PLAYBACK_ALLOWS_INLINE,
122     PROP_ENABLE_CSS_SHADERS
123 };
124
125 static void webkit_web_settings_finalize(GObject* object);
126
127 static void webkit_web_settings_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
128
129 static void webkit_web_settings_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec);
130
131 static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
132 {
133     GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
134     gobject_class->finalize = webkit_web_settings_finalize;
135     gobject_class->set_property = webkit_web_settings_set_property;
136     gobject_class->get_property = webkit_web_settings_get_property;
137
138     webkitInit();
139
140     GParamFlags flags = (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT);
141
142     g_object_class_install_property(gobject_class,
143                                     PROP_DEFAULT_ENCODING,
144                                     g_param_spec_string(
145                                     "default-encoding",
146                                     _("Default Encoding"),
147                                     _("The default encoding used to display text."),
148                                     "iso-8859-1",
149                                     flags));
150
151     g_object_class_install_property(gobject_class,
152                                     PROP_CURSIVE_FONT_FAMILY,
153                                     g_param_spec_string(
154                                     "cursive-font-family",
155                                     _("Cursive Font Family"),
156                                     _("The default Cursive font family used to display text."),
157                                     "serif",
158                                     flags));
159
160     g_object_class_install_property(gobject_class,
161                                     PROP_DEFAULT_FONT_FAMILY,
162                                     g_param_spec_string(
163                                     "default-font-family",
164                                     _("Default Font Family"),
165                                     _("The default font family used to display text."),
166                                     "sans-serif",
167                                     flags));
168
169     g_object_class_install_property(gobject_class,
170                                     PROP_FANTASY_FONT_FAMILY,
171                                     g_param_spec_string(
172                                     "fantasy-font-family",
173                                     _("Fantasy Font Family"),
174                                     _("The default Fantasy font family used to display text."),
175                                     "serif",
176                                     flags));
177
178     g_object_class_install_property(gobject_class,
179                                     PROP_MONOSPACE_FONT_FAMILY,
180                                     g_param_spec_string(
181                                     "monospace-font-family",
182                                     _("Monospace Font Family"),
183                                     _("The default font family used to display monospace text."),
184                                     "monospace",
185                                     flags));
186
187     g_object_class_install_property(gobject_class,
188                                     PROP_SANS_SERIF_FONT_FAMILY,
189                                     g_param_spec_string(
190                                     "sans-serif-font-family",
191                                     _("Sans Serif Font Family"),
192                                     _("The default Sans Serif font family used to display text."),
193                                     "sans-serif",
194                                     flags));
195
196     g_object_class_install_property(gobject_class,
197                                     PROP_SERIF_FONT_FAMILY,
198                                     g_param_spec_string(
199                                     "serif-font-family",
200                                     _("Serif Font Family"),
201                                     _("The default Serif font family used to display text."),
202                                     "serif",
203                                     flags));
204
205     g_object_class_install_property(gobject_class,
206                                     PROP_DEFAULT_FONT_SIZE,
207                                     g_param_spec_int(
208                                     "default-font-size",
209                                     _("Default Font Size"),
210                                     _("The default font size used to display text."),
211                                     5, G_MAXINT, 12,
212                                     flags));
213
214     g_object_class_install_property(gobject_class,
215                                     PROP_DEFAULT_MONOSPACE_FONT_SIZE,
216                                     g_param_spec_int(
217                                     "default-monospace-font-size",
218                                     _("Default Monospace Font Size"),
219                                     _("The default font size used to display monospace text."),
220                                     5, G_MAXINT, 10,
221                                     flags));
222
223     g_object_class_install_property(gobject_class,
224                                     PROP_MINIMUM_FONT_SIZE,
225                                     g_param_spec_int(
226                                     "minimum-font-size",
227                                     _("Minimum Font Size"),
228                                     _("The minimum font size used to display text."),
229                                     0, G_MAXINT, 5,
230                                     flags));
231
232     g_object_class_install_property(gobject_class,
233                                     PROP_MINIMUM_LOGICAL_FONT_SIZE,
234                                     g_param_spec_int(
235                                     "minimum-logical-font-size",
236                                     _("Minimum Logical Font Size"),
237                                     _("The minimum logical font size used to display text."),
238                                     1, G_MAXINT, 5,
239                                     flags));
240
241     /**
242     * WebKitWebSettings:enforce-96-dpi:
243     *
244     * Enforce a resolution of 96 DPI. This is meant for compatibility
245     * with web pages which cope badly with different screen resolutions
246     * and for automated testing.
247     * Web browsers and applications that typically display arbitrary
248     * content from the web should provide a preference for this.
249     *
250     * Since: 1.0.3
251     */
252     g_object_class_install_property(gobject_class,
253                                     PROP_ENFORCE_96_DPI,
254                                     g_param_spec_boolean(
255                                     "enforce-96-dpi",
256                                     _("Enforce 96 DPI"),
257                                     _("Enforce a resolution of 96 DPI"),
258                                     FALSE,
259                                     flags));
260
261     g_object_class_install_property(gobject_class,
262                                     PROP_AUTO_LOAD_IMAGES,
263                                     g_param_spec_boolean(
264                                     "auto-load-images",
265                                     _("Auto Load Images"),
266                                     _("Load images automatically."),
267                                     TRUE,
268                                     flags));
269
270     g_object_class_install_property(gobject_class,
271                                     PROP_AUTO_SHRINK_IMAGES,
272                                     g_param_spec_boolean(
273                                     "auto-shrink-images",
274                                     _("Auto Shrink Images"),
275                                     _("Automatically shrink standalone images to fit."),
276                                     TRUE,
277                                     flags));
278
279     g_object_class_install_property(gobject_class,
280                                     PROP_PRINT_BACKGROUNDS,
281                                     g_param_spec_boolean(
282                                     "print-backgrounds",
283                                     _("Print Backgrounds"),
284                                     _("Whether background images should be printed."),
285                                     TRUE,
286                                     flags));
287
288     g_object_class_install_property(gobject_class,
289                                     PROP_ENABLE_SCRIPTS,
290                                     g_param_spec_boolean(
291                                     "enable-scripts",
292                                     _("Enable Scripts"),
293                                     _("Enable embedded scripting languages."),
294                                     TRUE,
295                                     flags));
296
297     g_object_class_install_property(gobject_class,
298                                     PROP_ENABLE_PLUGINS,
299                                     g_param_spec_boolean(
300                                     "enable-plugins",
301                                     _("Enable Plugins"),
302                                     _("Enable embedded plugin objects."),
303                                     TRUE,
304                                     flags));
305
306     g_object_class_install_property(gobject_class,
307                                     PROP_RESIZABLE_TEXT_AREAS,
308                                     g_param_spec_boolean(
309                                     "resizable-text-areas",
310                                     _("Resizable Text Areas"),
311                                     _("Whether text areas are resizable."),
312                                     TRUE,
313                                     flags));
314
315     g_object_class_install_property(gobject_class,
316                                     PROP_USER_STYLESHEET_URI,
317                                     g_param_spec_string("user-stylesheet-uri",
318                                     _("User Stylesheet URI"),
319                                     _("The URI of a stylesheet that is applied to every page."),
320                                     0,
321                                     flags));
322
323     /**
324     * WebKitWebSettings:zoom-step:
325     *
326     * The value by which the zoom level is changed when zooming in or out.
327     *
328     * Since: 1.0.1
329     */
330     g_object_class_install_property(gobject_class,
331                                     PROP_ZOOM_STEP,
332                                     g_param_spec_float(
333                                     "zoom-step",
334                                     _("Zoom Stepping Value"),
335                                     _("The value by which the zoom level is changed when zooming in or out."),
336                                     0.0f, G_MAXFLOAT, 0.1f,
337                                     flags));
338
339     /**
340     * WebKitWebSettings:enable-developer-extras:
341     *
342     * Whether developer extensions should be enabled. This enables,
343     * for now, the Web Inspector, which can be controlled using the
344     * #WebKitWebInspector instance held by the #WebKitWebView this
345     * setting is enabled for.
346     *
347     * Since: 1.0.3
348     */
349     g_object_class_install_property(gobject_class,
350                                     PROP_ENABLE_DEVELOPER_EXTRAS,
351                                     g_param_spec_boolean(
352                                     "enable-developer-extras",
353                                     _("Enable Developer Extras"),
354                                     _("Enables special extensions that help developers"),
355                                     FALSE,
356                                     flags));
357
358     /**
359     * WebKitWebSettings:enable-private-browsing:
360     *
361     * Whether to enable private browsing mode. Private browsing mode prevents
362     * WebKit from updating the global history and storing any session
363     * information e.g., on-disk cache, as well as suppressing any messages
364     * from being printed into the (javascript) console.
365     *
366     * This is currently experimental for WebKitGtk.
367     *
368     * Since: 1.1.2
369     */
370     g_object_class_install_property(gobject_class,
371                                     PROP_ENABLE_PRIVATE_BROWSING,
372                                     g_param_spec_boolean(
373                                     "enable-private-browsing",
374                                     _("Enable Private Browsing"),
375                                     _("Enables private browsing mode"),
376                                     FALSE,
377                                     flags));
378
379     /**
380     * WebKitWebSettings:enable-spell-checking:
381     *
382     * Whether to enable spell checking while typing.
383     *
384     * Since: 1.1.6
385     */
386     g_object_class_install_property(gobject_class,
387                                     PROP_ENABLE_SPELL_CHECKING,
388                                     g_param_spec_boolean(
389                                     "enable-spell-checking",
390                                     _("Enable Spell Checking"),
391                                     _("Enables spell checking while typing"),
392                                     FALSE,
393                                     flags));
394
395     /**
396     * WebKitWebSettings:spell-checking-languages:
397     *
398     * The languages to be used for spell checking, separated by commas.
399     *
400     * The locale string typically is in the form lang_COUNTRY, where lang
401     * is an ISO-639 language code, and COUNTRY is an ISO-3166 country code.
402     * For instance, sv_FI for Swedish as written in Finland or pt_BR
403     * for Portuguese as written in Brazil.
404     *
405     * If no value is specified then the value returned by
406     * gtk_get_default_language will be used.
407     *
408     * Since: 1.1.6
409     */
410     g_object_class_install_property(gobject_class,
411                                     PROP_SPELL_CHECKING_LANGUAGES,
412                                     g_param_spec_string(
413                                     "spell-checking-languages",
414                                     _("Languages to use for spell checking"),
415                                     _("Comma separated list of languages to use for spell checking"),
416                                     0,
417                                     flags));
418
419     /**
420     * WebKitWebSettings:enable-caret-browsing:
421     *
422     * Whether to enable caret browsing mode.
423     *
424     * Since: 1.1.6
425     */
426     g_object_class_install_property(gobject_class,
427                                     PROP_ENABLE_CARET_BROWSING,
428                                     g_param_spec_boolean("enable-caret-browsing",
429                                                          _("Enable Caret Browsing"),
430                                                          _("Whether to enable accessibility enhanced keyboard navigation"),
431                                                          FALSE,
432                                                          flags));
433     /**
434     * WebKitWebSettings:enable-html5-database:
435     *
436     * Whether to enable HTML5 client-side SQL database support. Client-side
437     * SQL database allows web pages to store structured data and be able to
438     * use SQL to manipulate that data asynchronously.
439     *
440     * Since: 1.1.8
441     */
442     g_object_class_install_property(gobject_class,
443                                     PROP_ENABLE_HTML5_DATABASE,
444                                     g_param_spec_boolean("enable-html5-database",
445                                                          _("Enable HTML5 Database"),
446                                                          _("Whether to enable HTML5 database support"),
447                                                          TRUE,
448                                                          flags));
449
450     /**
451     * WebKitWebSettings:enable-html5-local-storage:
452     *
453     * Whether to enable HTML5 localStorage support. localStorage provides
454     * simple synchronous storage access.
455     *
456     * Since: 1.1.8
457     */
458     g_object_class_install_property(gobject_class,
459                                     PROP_ENABLE_HTML5_LOCAL_STORAGE,
460                                     g_param_spec_boolean("enable-html5-local-storage",
461                                                          _("Enable HTML5 Local Storage"),
462                                                          _("Whether to enable HTML5 Local Storage support"),
463                                                          TRUE,
464                                                          flags));
465     /**
466     * WebKitWebSettings:html5-local-storage-database-path:
467     *
468     * Path to store persistent HTML5 localStorage databases, which are enabled by
469     * "enable-html5-local-storage". The default path is $XDG_DATA_HOME/webkit/databases/.
470     *
471     * Since: 1.5.2
472     */
473     GOwnPtr<gchar> localStoragePath(g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL));
474     g_object_class_install_property(gobject_class,
475                                     PROP_HTML5_LOCAL_STORAGE_DATABASE_PATH,
476                                     g_param_spec_string("html5-local-storage-database-path",
477                                                         _("Local Storage Database Path"),
478                                                         _("The path to where HTML5 Local Storage databases are stored."),
479                                                         localStoragePath.get(),
480                                                         flags));
481     /**
482     * WebKitWebSettings:enable-xss-auditor
483     *
484     * Whether to enable the XSS Auditor. This feature filters some kinds of
485     * reflective XSS attacks on vulnerable web sites.
486     *
487     * Since: 1.1.11
488     */
489     g_object_class_install_property(gobject_class,
490                                     PROP_ENABLE_XSS_AUDITOR,
491                                     g_param_spec_boolean("enable-xss-auditor",
492                                                          _("Enable XSS Auditor"),
493                                                          _("Whether to enable the XSS auditor"),
494                                                          TRUE,
495                                                          flags));
496     /**
497     * WebKitWebSettings:enable-spatial-navigation
498     *
499     * Whether to enable the Spatial Navigation. This feature consists in the ability
500     * to navigate between focusable elements in a Web page, such as hyperlinks and
501     * form controls, by using Left, Right, Up and Down arrow keys. For example, if
502     * an user presses the Right key, heuristics determine whether there is an element
503     * he might be trying to reach towards the right, and if there are multiple elements,
504     * which element he probably wants.
505     *
506     * Since: 1.1.23
507     */
508     g_object_class_install_property(gobject_class,
509                                     PROP_ENABLE_SPATIAL_NAVIGATION,
510                                     g_param_spec_boolean("enable-spatial-navigation",
511                                                          _("Enable Spatial Navigation"),
512                                                          _("Whether to enable Spatial Navigation"),
513                                                          FALSE,
514                                                          flags));
515     /**
516     * WebKitWebSettings:enable-frame-flattening
517     *
518     * Whether to enable the Frame Flattening. With this setting each subframe is expanded
519     * to its contents, which will flatten all the frames to become one scrollable page.
520     * On touch devices, it is desired to not have any scrollable sub parts of the page as
521     * it results in a confusing user experience, with scrolling sometimes scrolling sub parts
522     * and at other times scrolling the page itself. For this reason iframes and framesets are
523     * barely usable on touch devices.
524     *
525     * Since: 1.3.5
526     */
527     g_object_class_install_property(gobject_class,
528                                     PROP_ENABLE_FRAME_FLATTENING,
529                                     g_param_spec_boolean("enable-frame-flattening",
530                                                          _("Enable Frame Flattening"),
531                                                          _("Whether to enable Frame Flattening"),
532                                                          FALSE,
533                                                          flags));
534     /**
535      * WebKitWebSettings:user-agent:
536      *
537      * The User-Agent string used by WebKitGtk.
538      *
539      * This will return a default User-Agent string if a custom string wasn't
540      * provided by the application. Setting this property to a NULL value or
541      * an empty string will result in the User-Agent string being reset to the
542      * default value.
543      *
544      * Since: 1.1.11
545      */
546     g_object_class_install_property(gobject_class, PROP_USER_AGENT,
547                                     g_param_spec_string("user-agent",
548                                                         _("User Agent"),
549                                                         _("The User-Agent string used by WebKitGtk"),
550                                                         "", // An empty string means the default user-agent.
551                                                         flags));
552
553     /**
554     * WebKitWebSettings:javascript-can-open-windows-automatically
555     *
556     * Whether JavaScript can open popup windows automatically without user
557     * intervention.
558     *
559     * Since: 1.1.11
560     */
561     g_object_class_install_property(gobject_class,
562                                     PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
563                                     g_param_spec_boolean("javascript-can-open-windows-automatically",
564                                                          _("JavaScript can open windows automatically"),
565                                                          _("Whether JavaScript can open windows automatically"),
566                                                          FALSE,
567                                                          flags));
568
569     /**
570     * WebKitWebSettings:javascript-can-access-clipboard
571     *
572     * Whether JavaScript can access Clipboard.
573     *
574     * Since: 1.3.0
575     */
576     g_object_class_install_property(gobject_class,
577                                     PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD,
578                                     g_param_spec_boolean("javascript-can-access-clipboard",
579                                                          _("JavaScript can access Clipboard"),
580                                                          _("Whether JavaScript can access Clipboard"),
581                                                          FALSE,
582                                                          flags));
583
584     /**
585     * WebKitWebSettings:enable-offline-web-application-cache
586     *
587     * Whether to enable HTML5 offline web application cache support. Offline
588     * Web Application Cache ensures web applications are available even when
589     * the user is not connected to the network.
590     *
591     * Since: 1.1.13
592     */
593     g_object_class_install_property(gobject_class,
594                                     PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
595                                     g_param_spec_boolean("enable-offline-web-application-cache",
596                                                          _("Enable offline web application cache"),
597                                                          _("Whether to enable offline web application cache"),
598                                                          TRUE,
599                                                          flags));
600
601
602     /**
603     * WebKitWebSettings:editing-behavior
604     *
605     * This setting controls various editing behaviors that differ
606     * between platforms and that have been combined in two groups,
607     * 'Mac' and 'Windows'. Some examples:
608     * 
609     *  1) Clicking below the last line of an editable area puts the
610     * caret at the end of the last line on Mac, but in the middle of
611     * the last line on Windows.
612     *
613     *  2) Pushing down the arrow key on the last line puts the caret
614     *  at the end of the last line on Mac, but does nothing on
615     *  Windows. A similar case exists on the top line.
616     *
617     * Since: 1.1.13
618     */
619     g_object_class_install_property(gobject_class,
620                                     PROP_EDITING_BEHAVIOR,
621                                     g_param_spec_enum("editing-behavior",
622                                                       _("Editing behavior"),
623                                                       _("The behavior mode to use in editing mode"),
624                                                       WEBKIT_TYPE_EDITING_BEHAVIOR,
625                                                       WEBKIT_EDITING_BEHAVIOR_UNIX,
626                                                       flags));
627
628     /**
629      * WebKitWebSettings:enable-universal-access-from-file-uris
630      *
631      * Whether to allow files loaded through file:// URIs universal access to
632      * all pages.
633      *
634      * Since: 1.1.13
635      */
636     g_object_class_install_property(gobject_class,
637                                     PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS,
638                                     g_param_spec_boolean("enable-universal-access-from-file-uris",
639                                                          _("Enable universal access from file URIs"),
640                                                          _("Whether to allow universal access from file URIs"),
641                                                          FALSE,
642                                                          flags));
643
644     /**
645      * WebKitWebSettings:enable-dom-paste
646      *
647      * Whether to enable DOM paste. If set to %TRUE, document.execCommand("Paste")
648      * will correctly execute and paste content of the clipboard.
649      *
650      * Since: 1.1.16
651      */
652     g_object_class_install_property(gobject_class,
653                                     PROP_ENABLE_DOM_PASTE,
654                                     g_param_spec_boolean("enable-dom-paste",
655                                                          _("Enable DOM paste"),
656                                                          _("Whether to enable DOM paste"),
657                                                          FALSE,
658                                                          flags));
659     /**
660     * WebKitWebSettings:tab-key-cycles-through-elements:
661     *
662     * Whether the tab key cycles through elements on the page.
663     *
664     * If @flag is %TRUE, pressing the tab key will focus the next element in
665     * the @web_view. If @flag is %FALSE, the @web_view will interpret tab
666     * key presses as normal key presses. If the selected element is editable, the
667     * tab key will cause the insertion of a tab character.
668     *
669     * Since: 1.1.17
670     */
671     g_object_class_install_property(gobject_class,
672                                     PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS,
673                                     g_param_spec_boolean("tab-key-cycles-through-elements",
674                                                          _("Tab key cycles through elements"),
675                                                          _("Whether the tab key cycles through elements on the page."),
676                                                          TRUE,
677                                                          flags));
678
679     /**
680      * WebKitWebSettings:enable-default-context-menu:
681      *
682      * Whether right-clicks should be handled automatically to create,
683      * and display the context menu. Turning this off will make
684      * WebKitGTK+ not emit the populate-popup signal. Notice that the
685      * default button press event handler may still handle right
686      * clicks for other reasons, such as in-page context menus, or
687      * right-clicks that are handled by the page itself.
688      *
689      * Since: 1.1.18
690      *
691      * Deprecated: 1.10: Use #WebKitWebView::context-menu signal instead.
692      */
693     g_object_class_install_property(gobject_class,
694                                     PROP_ENABLE_DEFAULT_CONTEXT_MENU,
695                                     g_param_spec_boolean(
696                                     "enable-default-context-menu",
697                                     _("Enable Default Context Menu"),
698                                     _("Enables the handling of right-clicks for the creation of the default context menu"),
699                                     TRUE,
700                                     flags));
701
702     /**
703      * WebKitWebSettings::enable-site-specific-quirks
704      *
705      * Whether to turn on site-specific hacks.  Turning this on will
706      * tell WebKitGTK+ to use some site-specific workarounds for
707      * better web compatibility.  For example, older versions of
708      * MediaWiki will incorrectly send WebKit a css file with KHTML
709      * workarounds.  By turning on site-specific quirks, WebKit will
710      * special-case this and other cases to make the sites work.
711      *
712      * Since: 1.1.18
713      */
714     g_object_class_install_property(gobject_class,
715                                     PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
716                                     g_param_spec_boolean(
717                                     "enable-site-specific-quirks",
718                                     _("Enable Site Specific Quirks"),
719                                     _("Enables the site-specific compatibility workarounds"),
720                                     FALSE,
721                                     flags));
722
723     /**
724     * WebKitWebSettings:enable-page-cache:
725     *
726     * Enable or disable the page cache. Disabling the page cache is
727     * generally only useful for special circumstances like low-memory
728     * scenarios or special purpose applications like static HTML
729     * viewers. This setting only controls the Page Cache, this cache
730     * is different than the disk-based or memory-based traditional
731     * resource caches, its point is to make going back and forth
732     * between pages much faster. For details about the different types
733     * of caches and their purposes see:
734     * http://webkit.org/blog/427/webkit-page-cache-i-the-basics/
735     *
736     * Since: 1.1.18
737     */
738     g_object_class_install_property(gobject_class,
739                                     PROP_ENABLE_PAGE_CACHE,
740                                     g_param_spec_boolean("enable-page-cache",
741                                                          _("Enable page cache"),
742                                                          _("Whether the page cache should be used"),
743                                                          FALSE,
744                                                          flags));
745
746     /**
747     * WebKitWebSettings:auto-resize-window:
748     *
749     * Web pages can request to modify the size and position of the
750     * window containing the #WebKitWebView through various DOM methods
751     * (resizeTo, moveTo, resizeBy, moveBy). By default WebKit will not
752     * honor this requests, but you can set this property to %TRUE if
753     * you'd like it to do so. If you wish to handle this manually, you
754     * can connect to the notify signal for the
755     * #WebKitWebWindowFeatures of your #WebKitWebView.
756     * 
757     * Since: 1.1.22
758     */
759     g_object_class_install_property(gobject_class,
760                                     PROP_AUTO_RESIZE_WINDOW,
761                                     g_param_spec_boolean("auto-resize-window",
762                                                          _("Auto Resize Window"),
763                                                          _("Automatically resize the toplevel window when a page requests it"),
764                                                          FALSE,
765                                                          flags));
766
767     /**
768      * WebKitWebSettings:enable-file-access-from-file-uris:
769      *
770      * Boolean property to control file access for file:// URIs. If this
771      * option is enabled every file:// will have its own security unique domain.
772      *
773      * Since: 1.1.22
774      */
775      g_object_class_install_property(gobject_class,
776                                      PROP_ENABLE_FILE_ACCESS_FROM_FILE_URIS,
777                                      g_param_spec_boolean("enable-file-access-from-file-uris",
778                                                           "Enable file access from file URIs",
779                                                           "Controls file access for file:// URIs.",
780                                                           FALSE,
781                                                           flags));
782
783    /**
784     * WebKitWebSettings:enable-java-applet:
785     *
786     * Enable or disable support for the Java &lt;applet&gt; tag. Keep in
787     * mind that Java content can be still shown in the page through
788     * &lt;object&gt; or &lt;embed&gt;, which are the preferred tags for this task.
789     *
790     * Since: 1.1.22
791     */
792     g_object_class_install_property(gobject_class,
793                                     PROP_ENABLE_JAVA_APPLET,
794                                     g_param_spec_boolean("enable-java-applet",
795                                                          _("Enable Java Applet"),
796                                                          _("Whether Java Applet support through <applet> should be enabled"),
797                                                          TRUE,
798                                                          flags));
799
800     /**
801     * WebKitWebSettings:enable-hyperlink-auditing:
802     *
803     * Enable or disable support for &lt;a ping&gt;.
804     *
805     * Since: 1.2.5
806     */
807     g_object_class_install_property(gobject_class,
808                                     PROP_ENABLE_HYPERLINK_AUDITING,
809                                     g_param_spec_boolean("enable-hyperlink-auditing",
810                                                          _("Enable Hyperlink Auditing"),
811                                                          _("Whether <a ping> should be able to send pings"),
812                                                          FALSE,
813                                                          flags));
814
815     /* Undocumented for now */
816     g_object_class_install_property(gobject_class,
817                                     PROP_ENABLE_FULLSCREEN,
818                                     g_param_spec_boolean("enable-fullscreen",
819                                                          _("Enable Fullscreen"),
820                                                          _("Whether the Mozilla style API should be enabled."),
821                                                          FALSE,
822                                                          flags));
823     /**
824     * WebKitWebSettings:enable-webgl:
825     *
826     * Enable or disable support for WebGL on pages. WebGL is an experimental
827     * proposal for allowing web pages to use OpenGL ES-like calls directly. The
828     * standard is currently a work-in-progress by the Khronos Group.
829     *
830     * Since: 1.3.14
831     */
832     g_object_class_install_property(gobject_class,
833                                     PROP_ENABLE_WEBGL,
834                                     g_param_spec_boolean("enable-webgl",
835                                                          _("Enable WebGL"),
836                                                          _("Whether WebGL content should be rendered"),
837                                                          FALSE,
838                                                          flags));
839
840     /**
841     * WebKitWebSettings:enable-accelerated-compositing:
842     *
843     * Enable or disable support for accelerated compositing on pages. Accelerated
844     * compositing uses the GPU to render animations on pages smoothly and also allows
845     * proper rendering of 3D CSS transforms.
846     *
847     * Since: 1.7.5
848     */
849     g_object_class_install_property(gobject_class,
850                                     PROP_ENABLE_ACCELERATED_COMPOSITING,
851                                     g_param_spec_boolean("enable-accelerated-compositing",
852                                                          _("Enable accelerated compositing"),
853                                                          _("Whether accelerated compositing should be enabled"),
854                                                          FALSE,
855                                                          flags));
856     /**
857     * WebKitWebSettings:enable-webaudio:
858     *
859     * Enable or disable support for WebAudio on pages. WebAudio is an
860     * experimental proposal for allowing web pages to generate Audio
861     * WAVE data from JavaScript. The standard is currently a
862     * work-in-progress by the W3C Audio Working Group.
863     *
864     * See also https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
865     *
866     * Since: TODO
867     */
868     g_object_class_install_property(gobject_class,
869                                     PROP_ENABLE_WEB_AUDIO,
870                                     g_param_spec_boolean("enable-webaudio",
871                                                          _("Enable WebAudio"),
872                                                          _("Whether WebAudio content should be handled"),
873                                                          FALSE,
874                                                          flags));
875
876
877     /**
878     * WebKitWebSettings:enable-dns-prefetching
879     *
880     * Whether webkit prefetches domain names.  This is a separate knob from private browsing.
881     * Whether private browsing should set this or not is up for debate, for now it doesn't.
882     *
883     * Since: 1.3.13.
884     */
885     g_object_class_install_property(gobject_class,
886                                     PROP_ENABLE_DNS_PREFETCHING,
887                                     g_param_spec_boolean("enable-dns-prefetching",
888                                                          _("WebKit prefetches domain names"),
889                                                          _("Whether WebKit prefetches domain names"),
890                                                          TRUE,
891                                                          flags));
892
893     /**
894     * WebKitWebSettings:enable-smooth-scrolling
895     *
896     * Enable or disable support for smooth scrolling. The current implementation relies upon
897     * CPU work to produce a smooth scrolling experience.
898     *
899     * Since: 1.9.0
900     */
901     g_object_class_install_property(gobject_class,
902                                     PROP_ENABLE_SMOOTH_SCROLLING,
903                                     g_param_spec_boolean("enable-smooth-scrolling",
904                                                          _("Enable smooth scrolling"),
905                                                          _("Whether to enable smooth scrolling"),
906                                                          FALSE,
907                                                          flags));
908
909     /**
910     * WebKitWebSettings:media-playback-requires-user-gesture
911     *
912     * Whether a user gesture (such as clicking the play button) would
913     * be required to start media playback or load media. This is off
914     * by default, so media playback could start automatically. Setting
915     * it on requires a gesture by the user to start playback, or to load
916     * the media.
917     *
918     * Since: 1.10.0
919     */
920     g_object_class_install_property(gobject_class,
921                                     PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE,
922                                     g_param_spec_boolean("media-playback-requires-user-gesture",
923                                                          _("Media playback requires user gesture"),
924                                                          _("Whether media playback requires user gesture"),
925                                                          FALSE,
926                                                          flags));
927
928     /**
929     * WebKitWebSettings:media-playback-allows-inline
930     *
931     * Whether media playback is full-screen only or inline playback is allowed.
932     * This is true by default, so media playback can be inline. Setting it to
933     * false allows specifying that media playback should be always fullscreen.
934     *
935     * Since: 1.10.0
936     */
937     g_object_class_install_property(gobject_class,
938                                     PROP_MEDIA_PLAYBACK_ALLOWS_INLINE,
939                                     g_param_spec_boolean("media-playback-allows-inline",
940                                                          _("Media playback allows inline"),
941                                                          _("Whether media playback allows inline"),
942                                                          TRUE,
943                                                          flags));
944
945     /**
946     * WebKitWebSettings:enable-css-shaders
947     *
948     * Enable or disable support for css shaders (css custom filters).
949     * Accelerated compositing needs to be enabled at compile time, but needs
950     * not be enabled at runtime.
951     *
952     * See also https://dvcs.w3.org/hg/FXTF/raw-file/tip/custom/index.html
953     *
954     * Since: 2.0
955     */
956     g_object_class_install_property(gobject_class,
957                                     PROP_ENABLE_CSS_SHADERS,
958                                     g_param_spec_boolean("enable-css-shaders",
959                                                          _("Enable CSS shaders"),
960                                                          _("Whether to enable css shaders"),
961                                                          FALSE,
962                                                          flags));
963
964 }
965
966 static void webkit_web_settings_init(WebKitWebSettings* web_settings)
967 {
968     web_settings->priv = new WebKitWebSettingsPrivate;
969 }
970
971 static void webkit_web_settings_finalize(GObject* object)
972 {
973     delete WEBKIT_WEB_SETTINGS(object)->priv;
974     G_OBJECT_CLASS(webkit_web_settings_parent_class)->finalize(object);
975 }
976
977 static void webkit_web_settings_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
978 {
979     WebKitWebSettings* web_settings = WEBKIT_WEB_SETTINGS(object);
980     WebKitWebSettingsPrivate* priv = web_settings->priv;
981
982     switch(prop_id) {
983     case PROP_DEFAULT_ENCODING:
984         priv->defaultEncoding = g_value_get_string(value);
985         break;
986     case PROP_CURSIVE_FONT_FAMILY:
987         priv->cursiveFontFamily = g_value_get_string(value);
988         break;
989     case PROP_DEFAULT_FONT_FAMILY:
990         priv->defaultFontFamily = g_value_get_string(value);
991         break;
992     case PROP_FANTASY_FONT_FAMILY:
993         priv->fantasyFontFamily = g_value_get_string(value);
994         break;
995     case PROP_MONOSPACE_FONT_FAMILY:
996         priv->monospaceFontFamily = g_value_get_string(value);
997         break;
998     case PROP_SANS_SERIF_FONT_FAMILY:
999         priv->sansSerifFontFamily = g_value_get_string(value);
1000         break;
1001     case PROP_SERIF_FONT_FAMILY:
1002         priv->serifFontFamily = g_value_get_string(value);
1003         break;
1004     case PROP_DEFAULT_FONT_SIZE:
1005         priv->defaultFontSize = g_value_get_int(value);
1006         break;
1007     case PROP_DEFAULT_MONOSPACE_FONT_SIZE:
1008         priv->defaultMonospaceFontSize = g_value_get_int(value);
1009         break;
1010     case PROP_MINIMUM_FONT_SIZE:
1011         priv->minimumFontSize = g_value_get_int(value);
1012         break;
1013     case PROP_MINIMUM_LOGICAL_FONT_SIZE:
1014         priv->minimumLogicalFontSize = g_value_get_int(value);
1015         break;
1016     case PROP_ENFORCE_96_DPI:
1017         priv->enforce96DPI = g_value_get_boolean(value);
1018         break;
1019     case PROP_AUTO_LOAD_IMAGES:
1020         priv->autoLoadImages = g_value_get_boolean(value);
1021         break;
1022     case PROP_AUTO_SHRINK_IMAGES:
1023         priv->autoShrinkImages = g_value_get_boolean(value);
1024         break;
1025     case PROP_PRINT_BACKGROUNDS:
1026         priv->printBackgrounds = g_value_get_boolean(value);
1027         break;
1028     case PROP_ENABLE_SCRIPTS:
1029         priv->enableScripts = g_value_get_boolean(value);
1030         break;
1031     case PROP_ENABLE_PLUGINS:
1032         priv->enablePlugins = g_value_get_boolean(value);
1033         break;
1034     case PROP_RESIZABLE_TEXT_AREAS:
1035         priv->resizableTextAreas = g_value_get_boolean(value);
1036         break;
1037     case PROP_USER_STYLESHEET_URI:
1038         priv->userStylesheetURI = g_value_get_string(value);
1039         break;
1040     case PROP_ZOOM_STEP:
1041         priv->zoomStep = g_value_get_float(value);
1042         break;
1043     case PROP_ENABLE_DEVELOPER_EXTRAS:
1044         priv->enableDeveloperExtras = g_value_get_boolean(value);
1045         break;
1046     case PROP_ENABLE_PRIVATE_BROWSING:
1047         priv->enablePrivateBrowsing = g_value_get_boolean(value);
1048         break;
1049     case PROP_ENABLE_CARET_BROWSING:
1050         priv->enableCaretBrowsing = g_value_get_boolean(value);
1051         break;
1052     case PROP_ENABLE_HTML5_DATABASE:
1053         priv->enableHTML5Database = g_value_get_boolean(value);
1054         break;
1055     case PROP_ENABLE_HTML5_LOCAL_STORAGE:
1056         priv->enableHTML5LocalStorage = g_value_get_boolean(value);
1057         break;
1058     case PROP_HTML5_LOCAL_STORAGE_DATABASE_PATH:
1059         priv->html5LocalStorageDatabasePath = g_value_get_string(value);
1060         break;
1061     case PROP_ENABLE_SPELL_CHECKING:
1062         priv->enableSpellChecking = g_value_get_boolean(value);
1063         break;
1064     case PROP_SPELL_CHECKING_LANGUAGES:
1065         priv->spellCheckingLanguages = g_value_get_string(value);
1066         break;
1067     case PROP_ENABLE_XSS_AUDITOR:
1068         priv->enableXSSAuditor = g_value_get_boolean(value);
1069         break;
1070     case PROP_ENABLE_SPATIAL_NAVIGATION:
1071         priv->enableSpatialNavigation = g_value_get_boolean(value);
1072         break;
1073     case PROP_ENABLE_FRAME_FLATTENING:
1074         priv->enableFrameFlattening = g_value_get_boolean(value);
1075         break;
1076     case PROP_USER_AGENT:
1077         if (!g_value_get_string(value) || !strlen(g_value_get_string(value)))
1078             priv->userAgent = standardUserAgent().utf8();
1079         else
1080             priv->userAgent = g_value_get_string(value);
1081         break;
1082     case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
1083         priv->javascriptCanOpenWindowsAutomatically = g_value_get_boolean(value);
1084         break;
1085     case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD:
1086         priv->javascriptCanAccessClipboard = g_value_get_boolean(value);
1087         break;
1088     case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
1089         priv->enableOfflineWebApplicationCache = g_value_get_boolean(value);
1090         break;
1091     case PROP_EDITING_BEHAVIOR:
1092         priv->editingBehavior = static_cast<WebKitEditingBehavior>(g_value_get_enum(value));
1093         break;
1094     case PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS:
1095         priv->enableUniversalAccessFromFileURIs = g_value_get_boolean(value);
1096         break;
1097     case PROP_ENABLE_FILE_ACCESS_FROM_FILE_URIS:
1098         priv->enableFileAccessFromFileURIs = g_value_get_boolean(value);
1099         break;
1100     case PROP_ENABLE_DOM_PASTE:
1101         priv->enableDOMPaste = g_value_get_boolean(value);
1102         break;
1103     case PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS:
1104         priv->tabKeyCyclesThroughElements = g_value_get_boolean(value);
1105         break;
1106     case PROP_ENABLE_DEFAULT_CONTEXT_MENU:
1107         priv->enableDefaultContextMenu = g_value_get_boolean(value);
1108         break;
1109     case PROP_ENABLE_SITE_SPECIFIC_QUIRKS:
1110         priv->enableSiteSpecificQuirks = g_value_get_boolean(value);
1111         break;
1112     case PROP_ENABLE_PAGE_CACHE:
1113         priv->enablePageCache = g_value_get_boolean(value);
1114         break;
1115     case PROP_AUTO_RESIZE_WINDOW:
1116         priv->autoResizeWindow = g_value_get_boolean(value);
1117         break;
1118     case PROP_ENABLE_JAVA_APPLET:
1119         priv->enableJavaApplet = g_value_get_boolean(value);
1120         break;
1121     case PROP_ENABLE_HYPERLINK_AUDITING:
1122         priv->enableHyperlinkAuditing = g_value_get_boolean(value);
1123         break;
1124     case PROP_ENABLE_FULLSCREEN:
1125         priv->enableFullscreen = g_value_get_boolean(value);
1126         break;
1127     case PROP_ENABLE_DNS_PREFETCHING:
1128         priv->enableDNSPrefetching = g_value_get_boolean(value);
1129         break;
1130     case PROP_ENABLE_WEBGL:
1131         priv->enableWebgl = g_value_get_boolean(value);
1132         break;
1133     case PROP_ENABLE_WEB_AUDIO:
1134         priv->enableWebAudio = g_value_get_boolean(value);
1135         break;
1136     case PROP_ENABLE_ACCELERATED_COMPOSITING:
1137         priv->enableAcceleratedCompositing = g_value_get_boolean(value);
1138         break;
1139     case PROP_ENABLE_SMOOTH_SCROLLING:
1140         priv->enableSmoothScrolling = g_value_get_boolean(value);
1141         break;
1142     case PROP_ENABLE_CSS_SHADERS:
1143         priv->enableCSSShaders = g_value_get_boolean(value);
1144         break;
1145     case PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE:
1146         priv->mediaPlaybackRequiresUserGesture = g_value_get_boolean(value);
1147         break;
1148     case PROP_MEDIA_PLAYBACK_ALLOWS_INLINE:
1149         priv->mediaPlaybackAllowsInline = g_value_get_boolean(value);
1150         break;
1151     default:
1152         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1153         break;
1154     }
1155 }
1156
1157 static void webkit_web_settings_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
1158 {
1159     WebKitWebSettings* web_settings = WEBKIT_WEB_SETTINGS(object);
1160     WebKitWebSettingsPrivate* priv = web_settings->priv;
1161
1162     switch (prop_id) {
1163     case PROP_DEFAULT_ENCODING:
1164         g_value_set_string(value, priv->defaultEncoding.data());
1165         break;
1166     case PROP_CURSIVE_FONT_FAMILY:
1167         g_value_set_string(value, priv->cursiveFontFamily.data());
1168         break;
1169     case PROP_DEFAULT_FONT_FAMILY:
1170         g_value_set_string(value, priv->defaultFontFamily.data());
1171         break;
1172     case PROP_FANTASY_FONT_FAMILY:
1173         g_value_set_string(value, priv->fantasyFontFamily.data());
1174         break;
1175     case PROP_MONOSPACE_FONT_FAMILY:
1176         g_value_set_string(value, priv->monospaceFontFamily.data());
1177         break;
1178     case PROP_SANS_SERIF_FONT_FAMILY:
1179         g_value_set_string(value, priv->sansSerifFontFamily.data());
1180         break;
1181     case PROP_SERIF_FONT_FAMILY:
1182         g_value_set_string(value, priv->serifFontFamily.data());
1183         break;
1184     case PROP_DEFAULT_FONT_SIZE:
1185         g_value_set_int(value, priv->defaultFontSize);
1186         break;
1187     case PROP_DEFAULT_MONOSPACE_FONT_SIZE:
1188         g_value_set_int(value, priv->defaultMonospaceFontSize);
1189         break;
1190     case PROP_MINIMUM_FONT_SIZE:
1191         g_value_set_int(value, priv->minimumFontSize);
1192         break;
1193     case PROP_MINIMUM_LOGICAL_FONT_SIZE:
1194         g_value_set_int(value, priv->minimumLogicalFontSize);
1195         break;
1196     case PROP_ENFORCE_96_DPI:
1197         g_value_set_boolean(value, priv->enforce96DPI);
1198         break;
1199     case PROP_AUTO_LOAD_IMAGES:
1200         g_value_set_boolean(value, priv->autoLoadImages);
1201         break;
1202     case PROP_AUTO_SHRINK_IMAGES:
1203         g_value_set_boolean(value, priv->autoShrinkImages);
1204         break;
1205     case PROP_PRINT_BACKGROUNDS:
1206         g_value_set_boolean(value, priv->printBackgrounds);
1207         break;
1208     case PROP_ENABLE_SCRIPTS:
1209         g_value_set_boolean(value, priv->enableScripts);
1210         break;
1211     case PROP_ENABLE_PLUGINS:
1212         g_value_set_boolean(value, priv->enablePlugins);
1213         break;
1214     case PROP_RESIZABLE_TEXT_AREAS:
1215         g_value_set_boolean(value, priv->resizableTextAreas);
1216         break;
1217     case PROP_USER_STYLESHEET_URI:
1218         g_value_set_string(value, priv->userStylesheetURI.data());
1219         break;
1220     case PROP_ZOOM_STEP:
1221         g_value_set_float(value, priv->zoomStep);
1222         break;
1223     case PROP_ENABLE_DEVELOPER_EXTRAS:
1224         g_value_set_boolean(value, priv->enableDeveloperExtras);
1225         break;
1226     case PROP_ENABLE_PRIVATE_BROWSING:
1227         g_value_set_boolean(value, priv->enablePrivateBrowsing);
1228         break;
1229     case PROP_ENABLE_CARET_BROWSING:
1230         g_value_set_boolean(value, priv->enableCaretBrowsing);
1231         break;
1232     case PROP_ENABLE_HTML5_DATABASE:
1233         g_value_set_boolean(value, priv->enableHTML5Database);
1234         break;
1235     case PROP_ENABLE_HTML5_LOCAL_STORAGE:
1236         g_value_set_boolean(value, priv->enableHTML5LocalStorage);
1237         break;
1238     case PROP_HTML5_LOCAL_STORAGE_DATABASE_PATH:
1239         g_value_set_string(value, priv->html5LocalStorageDatabasePath.data());
1240         break;
1241     case PROP_ENABLE_SPELL_CHECKING:
1242         g_value_set_boolean(value, priv->enableSpellChecking);
1243         break;
1244     case PROP_SPELL_CHECKING_LANGUAGES:
1245         g_value_set_string(value, priv->spellCheckingLanguages.data());
1246         break;
1247     case PROP_ENABLE_XSS_AUDITOR:
1248         g_value_set_boolean(value, priv->enableXSSAuditor);
1249         break;
1250     case PROP_ENABLE_SPATIAL_NAVIGATION:
1251         g_value_set_boolean(value, priv->enableSpatialNavigation);
1252         break;
1253     case PROP_ENABLE_FRAME_FLATTENING:
1254         g_value_set_boolean(value, priv->enableFrameFlattening);
1255         break;
1256     case PROP_USER_AGENT:
1257         g_value_set_string(value, priv->userAgent.data());
1258         break;
1259     case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
1260         g_value_set_boolean(value, priv->javascriptCanOpenWindowsAutomatically);
1261         break;
1262     case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD:
1263         g_value_set_boolean(value, priv->javascriptCanAccessClipboard);
1264         break;
1265     case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
1266         g_value_set_boolean(value, priv->enableOfflineWebApplicationCache);
1267         break;
1268     case PROP_EDITING_BEHAVIOR:
1269         g_value_set_enum(value, priv->editingBehavior);
1270         break;
1271     case PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS:
1272         g_value_set_boolean(value, priv->enableUniversalAccessFromFileURIs);
1273         break;
1274     case PROP_ENABLE_FILE_ACCESS_FROM_FILE_URIS:
1275         g_value_set_boolean(value, priv->enableFileAccessFromFileURIs);
1276         break;
1277     case PROP_ENABLE_DOM_PASTE:
1278         g_value_set_boolean(value, priv->enableDOMPaste);
1279         break;
1280     case PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS:
1281         g_value_set_boolean(value, priv->tabKeyCyclesThroughElements);
1282         break;
1283     case PROP_ENABLE_DEFAULT_CONTEXT_MENU:
1284         g_value_set_boolean(value, priv->enableDefaultContextMenu);
1285         break;
1286     case PROP_ENABLE_SITE_SPECIFIC_QUIRKS:
1287         g_value_set_boolean(value, priv->enableSiteSpecificQuirks);
1288         break;
1289     case PROP_ENABLE_PAGE_CACHE:
1290         g_value_set_boolean(value, priv->enablePageCache);
1291         break;
1292     case PROP_AUTO_RESIZE_WINDOW:
1293         g_value_set_boolean(value, priv->autoResizeWindow);
1294         break;
1295     case PROP_ENABLE_JAVA_APPLET:
1296         g_value_set_boolean(value, priv->enableJavaApplet);
1297         break;
1298     case PROP_ENABLE_HYPERLINK_AUDITING:
1299         g_value_set_boolean(value, priv->enableHyperlinkAuditing);
1300         break;
1301     case PROP_ENABLE_FULLSCREEN:
1302         g_value_set_boolean(value, priv->enableFullscreen);
1303         break;
1304     case PROP_ENABLE_DNS_PREFETCHING:
1305         g_value_set_boolean(value, priv->enableDNSPrefetching);
1306         break;
1307     case PROP_ENABLE_WEBGL:
1308         g_value_set_boolean(value, priv->enableWebgl);
1309         break;
1310     case PROP_ENABLE_WEB_AUDIO:
1311         g_value_set_boolean(value, priv->enableWebAudio);
1312         break;
1313     case PROP_ENABLE_ACCELERATED_COMPOSITING:
1314         g_value_set_boolean(value, priv->enableAcceleratedCompositing);
1315         break;
1316     case PROP_ENABLE_SMOOTH_SCROLLING:
1317         g_value_set_boolean(value, priv->enableSmoothScrolling);
1318         break;
1319     case PROP_ENABLE_CSS_SHADERS:
1320         g_value_set_boolean(value, priv->enableCSSShaders);
1321         break;
1322     case PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE:
1323         g_value_set_boolean(value, priv->mediaPlaybackRequiresUserGesture);
1324         break;
1325     case PROP_MEDIA_PLAYBACK_ALLOWS_INLINE:
1326         g_value_set_boolean(value, priv->mediaPlaybackAllowsInline);
1327         break;
1328     default:
1329         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1330         break;
1331     }
1332 }
1333
1334 /**
1335  * webkit_web_settings_new:
1336  *
1337  * Creates a new #WebKitWebSettings instance with default values. It must
1338  * be manually attached to a WebView.
1339  *
1340  * Returns: a new #WebKitWebSettings instance
1341  **/
1342 WebKitWebSettings* webkit_web_settings_new()
1343 {
1344     return WEBKIT_WEB_SETTINGS(g_object_new(WEBKIT_TYPE_WEB_SETTINGS, NULL));
1345 }
1346
1347 /**
1348  * webkit_web_settings_copy:
1349  * @web_settings: a #WebKitWebSettings to copy.
1350  *
1351  * Copies an existing #WebKitWebSettings instance.
1352  *
1353  * Returns: (transfer full): a new #WebKitWebSettings instance
1354  **/
1355 WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* original)
1356 {
1357     unsigned numberOfProperties = 0;
1358     GOwnPtr<GParamSpec*> properties(g_object_class_list_properties(
1359         G_OBJECT_CLASS(WEBKIT_WEB_SETTINGS_GET_CLASS(original)), &numberOfProperties));
1360     GOwnPtr<GParameter> parameters(g_new0(GParameter, numberOfProperties));
1361
1362     for (size_t i = 0; i < numberOfProperties; i++) {
1363         GParamSpec* property = properties.get()[i];
1364         GParameter* parameter = parameters.get() + i;
1365
1366         if (!(property->flags & (G_PARAM_CONSTRUCT | G_PARAM_READWRITE)))
1367             continue;
1368
1369         parameter->name = property->name;
1370         g_value_init(&parameter->value, property->value_type);
1371         g_object_get_property(G_OBJECT(original), property->name, &parameter->value);
1372     }
1373
1374     return WEBKIT_WEB_SETTINGS(g_object_newv(WEBKIT_TYPE_WEB_SETTINGS, numberOfProperties, parameters.get()));
1375
1376 }
1377
1378 /**
1379  * webkit_web_settings_add_extra_plugin_directory:
1380  * @web_view: a #WebKitWebView
1381  * @directory: the directory to add
1382  *
1383  * Adds the @directory to paths where @web_view will search for plugins.
1384  *
1385  * Since: 1.0.3
1386  */
1387 void webkit_web_settings_add_extra_plugin_directory(WebKitWebView* webView, const gchar* directory)
1388 {
1389     g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
1390     PluginDatabase::installedPlugins()->addExtraPluginDirectory(filenameToString(directory));
1391 }
1392
1393 /**
1394  * webkit_web_settings_get_user_agent:
1395  * @web_settings: a #WebKitWebSettings
1396  *
1397  * Returns: the User-Agent string currently used by the web view(s) associated
1398  * with the @web_settings.
1399  *
1400  * Since: 1.1.11
1401  */
1402 const gchar* webkit_web_settings_get_user_agent(WebKitWebSettings* webSettings)
1403 {
1404     g_return_val_if_fail(WEBKIT_IS_WEB_SETTINGS(webSettings), 0);
1405     return webSettings->priv->userAgent.data();
1406 }
1407
1408 static void initializeDomainsList(HashSet<String>& googleDomains)
1409 {
1410     // Google search domains.
1411     googleDomains.add("biz");
1412     googleDomains.add("com");
1413     googleDomains.add("net");
1414     googleDomains.add("org");
1415     googleDomains.add("ae");
1416     googleDomains.add("ag");
1417     googleDomains.add("am");
1418     googleDomains.add("at");
1419     googleDomains.add("az");
1420     googleDomains.add("be");
1421     googleDomains.add("bi");
1422     googleDomains.add("ca");
1423     googleDomains.add("cc");
1424     googleDomains.add("cd");
1425     googleDomains.add("cg");
1426     googleDomains.add("ch");
1427     googleDomains.add("cl");
1428     googleDomains.add("com.br");
1429     googleDomains.add("com.do");
1430     googleDomains.add("co.uk");
1431     googleDomains.add("co.kr");
1432     googleDomains.add("co.jp");
1433     googleDomains.add("de");
1434     googleDomains.add("dj");
1435     googleDomains.add("dk");
1436     googleDomains.add("ee");
1437     googleDomains.add("es");
1438     googleDomains.add("fi");
1439     googleDomains.add("fm");
1440     googleDomains.add("fr");
1441     googleDomains.add("gg");
1442     googleDomains.add("gl");
1443     googleDomains.add("gm");
1444     googleDomains.add("gs");
1445     googleDomains.add("hn");
1446     googleDomains.add("hu");
1447     googleDomains.add("ie");
1448     googleDomains.add("it");
1449     googleDomains.add("je");
1450     googleDomains.add("kz");
1451     googleDomains.add("li");
1452     googleDomains.add("lt");
1453     googleDomains.add("lu");
1454     googleDomains.add("lv");
1455     googleDomains.add("ma");
1456     googleDomains.add("ms");
1457     googleDomains.add("mu");
1458     googleDomains.add("mw");
1459     googleDomains.add("nl");
1460     googleDomains.add("no");
1461     googleDomains.add("nu");
1462     googleDomains.add("pl");
1463     googleDomains.add("pn");
1464     googleDomains.add("pt");
1465     googleDomains.add("ru");
1466     googleDomains.add("rw");
1467     googleDomains.add("sh");
1468     googleDomains.add("sk");
1469     googleDomains.add("sm");
1470     googleDomains.add("st");
1471     googleDomains.add("td");
1472     googleDomains.add("tk");
1473     googleDomains.add("tp");
1474     googleDomains.add("tv");
1475     googleDomains.add("us");
1476     googleDomains.add("uz");
1477     googleDomains.add("ws");
1478 }
1479
1480 static void initializeOtherGoogleDomains(Vector<String>& otherGoogleDomains)
1481 {
1482     otherGoogleDomains.append("gmail.com");
1483     otherGoogleDomains.append("youtube.com");
1484     otherGoogleDomains.append("gstatic.com");
1485     otherGoogleDomains.append("ytimg.com");
1486 }
1487
1488 static bool isGoogleDomain(String host)
1489 {
1490     DEFINE_STATIC_LOCAL(HashSet<String>, googleDomains, ());
1491     DEFINE_STATIC_LOCAL(Vector<String>, otherGoogleDomains, ());
1492
1493     if (googleDomains.isEmpty())
1494         initializeDomainsList(googleDomains);
1495
1496     if (otherGoogleDomains.isEmpty())
1497         initializeOtherGoogleDomains(otherGoogleDomains);
1498
1499     // First check if this is one of the various google.com international domains.
1500     int position = host.find(".google.");
1501     if (position > 0 && googleDomains.contains(host.substring(position + sizeof(".google.") - 1)))
1502         return true;
1503
1504     // Then we check the possibility of it being one of the other, .com-only google domains.
1505     for (unsigned int i = 0; i < otherGoogleDomains.size(); i++) {
1506         if (host.endsWith(otherGoogleDomains.at(i)))
1507             return true;
1508     }
1509
1510     return false;
1511 }
1512
1513 static String userAgentForURL(const KURL& url)
1514 {
1515     // For Google domains, drop the browser's custom User Agent string, and use the
1516     // standard Chrome one, so they don't give us a broken experience.
1517     if (isGoogleDomain(url.host()))
1518         return standardUserAgent();
1519
1520     return String();
1521 }
1522
1523 /*
1524  * Private usage only.
1525  * webkitWebSettingsUserAgentForURI:
1526  * @web_settings: the #WebKitWebSettings object to query
1527  * @uri: the URI we want to know the User-Agent for
1528  *
1529  * Some web sites have been using User-Agent parsing heavily to decide
1530  * the kind of content that is sent to the browser. When
1531  * WebKitWebSettings:enable-site-specific-quirks is enabled WebKitGTK+
1532  * will use its knowledge of sites doing bad things and lie to them by
1533  * sending either the default User-Agent, i.e. not using the one
1534  * specified by the browser in WebKitWebSettings:user-agent, or the
1535  * Safari one (including lying about the underlying operating system).
1536  *
1537  * This function allows the browser to figure out what User-Agent is
1538  * going to be sent to a particular URI.
1539  *
1540  * Please note that if WebKitWebSettings:use-site-specific-quirks is
1541  * turned off calling this function is the same as calling
1542  * webkit_web_settings_get_user_agent(), except you have to free the
1543  * result.
1544  *
1545  * Returns: (transfer full): a newly allocated string containing the
1546  * User-Agent that will be sent for the given URI.
1547  */
1548 char* webkitWebSettingsUserAgentForURI(WebKitWebSettings* webSettings, const char* uri)
1549 {
1550     if (webSettings->priv->enableSiteSpecificQuirks) {
1551         String userAgentString = userAgentForURL(WebCore::KURL(WebCore::KURL(), String::fromUTF8(uri)));
1552         if (!userAgentString.isEmpty())
1553             return g_strdup(userAgentString.utf8().data());
1554     }
1555
1556     return g_strdup(webkit_web_settings_get_user_agent(webSettings));
1557 }
1558
1559 namespace WebKit {
1560
1561 WebCore::EditingBehaviorType core(WebKitEditingBehavior type)
1562 {
1563     return static_cast<WebCore::EditingBehaviorType>(type);
1564 }
1565
1566 }