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