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