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