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