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