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