1/*
2 * Copyright (C) 2012 Samsung Electronics
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26/**
27 * @file    ewk_settings.h
28 * @brief   Describes the settings API.
29 *
30 * @note The ewk_settings is for setting the preference of specific ewk_view.
31 * We can get the ewk_settings from ewk_view using ewk_view_settings_get() API.
32 */
33
34#ifndef ewk_settings_h
35#define ewk_settings_h
36
37#include <Eina.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43/** Creates a type name for Ewk_Settings */
44typedef struct EwkSettings Ewk_Settings;
45
46
47/**
48 * Enables/disables the Javascript Fullscreen API. The Javascript API allows
49 * to request full screen mode, for more information see:
50 * http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
51 *
52 * Default value for Javascript Fullscreen API setting is @c EINA_TRUE .
53 *
54 * @param settings settings object to enable Javascript Fullscreen API
55 * @param enable @c EINA_TRUE to enable Javascript Fullscreen API or
56 *               @c EINA_FALSE to disable
57 *
58 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
59 */
60EAPI Eina_Bool ewk_settings_fullscreen_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
61
62/**
63 * Returns whether the Javascript Fullscreen API is enabled or not.
64 *
65 * @param settings settings object to query whether Javascript Fullscreen API is enabled
66 *
67 * @return @c EINA_TRUE if the Javascript Fullscreen API is enabled
68 *         @c EINA_FALSE if not or on failure
69 */
70EAPI Eina_Bool ewk_settings_fullscreen_enabled_get(const Ewk_Settings *settings);
71
72/**
73 * Enables/disables the javascript executing.
74 *
75 * By default, JavaScript execution is enabled.
76 *
77 * @param settings settings object to set javascript executing
78 * @param enable @c EINA_TRUE to enable javascript executing
79 *               @c EINA_FALSE to disable
80 *
81 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
82 */
83EAPI Eina_Bool ewk_settings_javascript_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
84
85/**
86 * Returns whether JavaScript execution is enabled.
87 *
88 * @param settings settings object to query if the javascript can be executed
89 *
90 * @return @c EINA_TRUE if the javascript can be executed
91 *         @c EINA_FALSE if not or on failure
92 */
93EAPI Eina_Bool ewk_settings_javascript_enabled_get(const Ewk_Settings *settings);
94
95/**
96 * Enables/disables auto loading of the images.
97 *
98 * By default, auto loading of the images is enabled.
99 *
100 * @param settings settings object to set auto loading of the images
101 * @param automatic @c EINA_TRUE to enable auto loading of the images
102 *                  @c EINA_FALSE to disable
103 *
104 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
105 */
106EAPI Eina_Bool ewk_settings_loads_images_automatically_set(Ewk_Settings *settings, Eina_Bool automatic);
107
108/**
109 * Returns whether the images can be loaded automatically or not.
110 *
111 * @param settings settings object to get auto loading of the images
112 *
113 * @return @c EINA_TRUE if the images are loaded automatically
114 *         @c EINA_FALSE if not or on failure
115 */
116EAPI Eina_Bool ewk_settings_loads_images_automatically_get(const Ewk_Settings *settings);
117
118/**
119 * Enables/disables developer extensions.
120 *
121 * By default, the developer extensions are disabled.
122 *
123 * @param settings settings object to set developer extensions
124 * @param enable @c EINA_TRUE to enable developer extensions
125 *               @c EINA_FALSE to disable
126 *
127 * @return @c EINA_TRUE on success or @EINA_FALSE on failure
128 */
129EAPI Eina_Bool ewk_settings_developer_extras_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
130
131/**
132 * Queries if developer extensions are enabled.
133 *
134 * By default, the developer extensions are disabled.
135 *
136 * @param settings settings object to set developer extensions
137 *
138 * @return @c EINA_TRUE if developer extensions are enabled
139           @c EINA_FALSE if not or on failure
140 */
141EAPI Eina_Bool ewk_settings_developer_extras_enabled_get(const Ewk_Settings *settings);
142
143/**
144 * Allow / Disallow file access from file:// URLs.
145 *
146 * By default, file access from file:// URLs is not allowed.
147 *
148 * @param settings settings object to set file access permission
149 * @param enable @c EINA_TRUE to enable file access permission
150 *               @c EINA_FALSE to disable
151 *
152 * @return @c EINA_TRUE on success or @EINA_FALSE on failure
153 */
154EAPI Eina_Bool ewk_settings_file_access_from_file_urls_allowed_set(Ewk_Settings *settings, Eina_Bool enable);
155
156/**
157 * Queries if  file access from file:// URLs is allowed.
158 *
159 * By default, file access from file:// URLs is not allowed.
160 *
161 * @param settings settings object to query file access permission
162 *
163 * @return @c EINA_TRUE if file access from file:// URLs is allowed
164 *         @c EINA_FALSE if not or on failure
165 */
166EAPI Eina_Bool ewk_settings_file_access_from_file_urls_allowed_get(const Ewk_Settings *settings);
167
168/**
169 * Enables/disables frame flattening.
170 *
171 * By default, the frame flattening is disabled.
172 *
173 * @param settings settings object to set the frame flattening
174 * @param enable @c EINA_TRUE to enable the frame flattening
175 *               @c EINA_FALSE to disable
176 *
177 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
178 *
179 * @see ewk_settings_enable_frame_flattening_get()
180 */
181EAPI Eina_Bool ewk_settings_frame_flattening_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
182
183/**
184 * Returns whether the frame flattening is enabled.
185 *
186 * The frame flattening is a feature which expands sub frames until all the frames become
187 * one scrollable page.
188 *
189 * @param settings settings object to get the frame flattening.
190 *
191 * @return @c EINA_TRUE if the frame flattening is enabled
192 *         @c EINA_FALSE if not or on failure
193 */
194EAPI Eina_Bool ewk_settings_frame_flattening_enabled_get(const Ewk_Settings *settings);
195
196/**
197 * Enables/disables DNS prefetching.
198 *
199 * By default, DNS prefetching is disabled.
200 *
201 * @param settings settings object to set DNS prefetching
202 * @param enable @c EINA_TRUE to enable DNS prefetching or
203 *               @c EINA_FALSE to disable
204 *
205 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
206 *
207 * @see ewk_settings_DNS_prefetching_enabled_get()
208 */
209EAPI Eina_Bool ewk_settings_dns_prefetching_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
210
211/**
212 * Returns whether DNS prefetching is enabled or not.
213 *
214 * DNS prefetching is an attempt to resolve domain names before a user tries to follow a link.
215 *
216 * @param settings settings object to get DNS prefetching
217 *
218 * @return @c EINA_TRUE if DNS prefetching is enabled
219 *         @c EINA_FALSE if not or on failure
220 */
221EAPI Eina_Bool ewk_settings_dns_prefetching_enabled_get(const Ewk_Settings *settings);
222
223/**
224 * Enables/disables the encoding detector.
225 *
226 * By default, the encoding detector is disabled.
227 *
228 * @param settings settings object to set the encoding detector
229 * @param enable @c EINA_TRUE to enable the encoding detector,
230 *        @c EINA_FALSE to disable
231 *
232 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
233 */
234EAPI Eina_Bool ewk_settings_encoding_detector_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
235
236/**
237 * Returns whether the encoding detector is enabled or not.
238 *
239 * @param settings settings object to query whether encoding detector is enabled
240 *
241 * @return @c EINA_TRUE if the encoding detector is enabled
242 *         @c EINA_FALSE if not or on failure
243 */
244EAPI Eina_Bool ewk_settings_encoding_detector_enabled_get(const Ewk_Settings *settings);
245
246/**
247 * Sets the default text encoding name.
248 *
249 * @param settings settings object to set default text encoding name
250 * @param encoding default text encoding name
251 *
252 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
253 */
254EAPI Eina_Bool ewk_settings_default_text_encoding_name_set(Ewk_Settings *settings, const char *encoding);
255
256/**
257 * Gets the default text encoding name.
258 *
259 * The returned string is guaranteed to be stringshared.
260 *
261 * @param settings settings object to query default text encoding name
262 *
263 * @return default text encoding name
264 */
265EAPI const char *ewk_settings_default_text_encoding_name_get(const Ewk_Settings *settings);
266
267/**
268 * Sets preferred minimum contents width which is used as default minimum contents width
269 * for non viewport meta element sites.
270 *
271 * By default, preferred minimum contents width is equal to @c 980.
272 *
273 * @param settings settings object to set the encoding detector
274 * @param enable @c EINA_TRUE to enable the encoding detector,
275 *        @c EINA_FALSE to disable
276 *
277 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
278 */
279EAPI Eina_Bool ewk_settings_preferred_minimum_contents_width_set(Ewk_Settings *settings, unsigned width);
280
281/**
282 * Returns preferred minimum contents width or @c 0 on failure.
283 *
284 * @param settings settings object to query preferred minimum contents width
285 *
286 * @return preferred minimum contents width
287 *         @c 0 on failure
288 */
289EAPI unsigned ewk_settings_preferred_minimum_contents_width_get(const Ewk_Settings *settings);
290
291/**
292 * Enables/disables the offline application cache.
293 *
294 * By default, the offline application cache is enabled.
295 *
296 * @param settings settings object to set the offline application cache state
297 * @param enable @c EINA_TRUE to enable the offline application cache,
298 *        @c EINA_FALSE to disable
299 *
300 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
301 */
302EAPI Eina_Bool ewk_settings_offline_web_application_cache_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
303
304/**
305 * Returns whether the offline application cache is enabled or not.
306 *
307 * @param settings settings object to query whether offline application cache is enabled
308 *
309 * @return @c EINA_TRUE if the offline application cache is enabled
310 *         @c EINA_FALSE if disabled or on failure
311 */
312EAPI Eina_Bool ewk_settings_offline_web_application_cache_enabled_get(const Ewk_Settings *settings);
313
314/**
315 * Enables/disables if the scripts can open new windows.
316 *
317 * By default, the scripts can open new windows.
318 *
319 * @param settings settings object to set if the scripts can open new windows
320 * @param enable @c EINA_TRUE if the scripts can open new windows
321 *        @c EINA_FALSE if not
322 *
323 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure (scripts are disabled)
324 */
325EAPI Eina_Bool ewk_settings_scripts_can_open_windows_set(Ewk_Settings *settings, Eina_Bool enable);
326
327/**
328 * Returns whether the scripts can open new windows.
329 *
330 * @param settings settings object to query whether the scripts can open new windows
331 *
332 * @return @c EINA_TRUE if the scripts can open new windows
333 *         @c EINA_FALSE if not or on failure (scripts are disabled)
334 */
335EAPI Eina_Bool ewk_settings_scripts_can_open_windows_get(const Ewk_Settings *settings);
336
337/**
338 * Enables/disables the HTML5 local storage functionality.
339 *
340 * Local storage provides simple synchronous storage access.
341 * HTML5 local storage specification is available at
342 * http://dev.w3.org/html5/webstorage/.
343 *
344 * By default, the HTML5 local storage is enabled.
345 *
346 * @param settings settings object to set the HTML5 local storage state
347 * @param enable @c EINA_TRUE to enable HTML5 local storage,
348 *        @c EINA_FALSE to disable
349 *
350 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
351 */
352EAPI Eina_Bool ewk_settings_local_storage_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
353
354/**
355 * Returns whether the HTML5 local storage functionality is enabled or not.
356 *
357 * Local storage provides simple synchronous storage access.
358 * HTML5 local storage specification is available at
359 * http://dev.w3.org/html5/webstorage/.
360 *
361 * By default, the HTML5 local storage is enabled.
362 *
363 * @param settings settings object to query whether HTML5 local storage is enabled
364 *
365 * @return @c EINA_TRUE if the HTML5 local storage is enabled
366 *         @c EINA_FALSE if disabled or on failure
367 */
368EAPI Eina_Bool ewk_settings_local_storage_enabled_get(const Ewk_Settings *settings);
369
370/**
371 * Toggles plug-ins support.
372 *
373 * By default, plug-ins support is enabled.
374 *
375 * @param settings settings object to set plug-ins support
376 * @param enable @c EINA_TRUE to enable plug-ins support
377 *        @c EINA_FALSE to disable
378 *
379 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
380 */
381EAPI Eina_Bool ewk_settings_plugins_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
382
383/**
384 * Returns whether plug-ins support is enabled or not.
385 *
386 * @param settings settings object to query whether plug-ins support is enabled
387 *
388 * @return @c EINA_TRUE if plug-ins support is enabled
389 *         @c EINA_FALSE if not or on failure
390 */
391EAPI Eina_Bool ewk_settings_plugins_enabled_get(const Ewk_Settings *settings);
392
393/**
394 * Sets the default font size.
395 *
396 * By default, the default font size is @c 16.
397 *
398 * @param settings settings object to set the default font size
399 * @param size a new default font size to set
400 *
401 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
402 */
403EAPI Eina_Bool ewk_settings_default_font_size_set(Ewk_Settings *settings, int size);
404
405/**
406 * Returns the default font size.
407 *
408 * @param settings settings object to get the default font size
409 *
410 * @return @c the default font size or @c 0 on failure
411 */
412EAPI int ewk_settings_default_font_size_get(const Ewk_Settings *settings);
413
414/**
415 * Enables/disables private browsing.
416 *
417 * By default, private browsing is disabled.
418 *
419 * @param settings settings object to set private browsing
420 * @param enable @c EINA_TRUE to enable private browsing
421 *        @c EINA_FALSE to disable
422 *
423 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
424 */
425EAPI Eina_Bool ewk_settings_private_browsing_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
426
427/**
428 * Returns whether private browsing is enabled or not.
429 *
430 * Private Browsing allows a user to browse the Internet without saving any information
431 * about which sites and pages a user has visited.
432 *
433 * @param settings settings object to query whether private browsing is enabled
434 *
435 * @return @c EINA_TRUE if private browsing is enabled
436 *         @c EINA_FALSE if not or on failure
437 */
438EAPI Eina_Bool ewk_settings_private_browsing_enabled_get(const Ewk_Settings *settings);
439
440/**
441 * Enables/disables text autosizing.
442 *
443 * By default, the text autosizing is disabled.
444 *
445 * @param settings settings object to set the text autosizing
446 * @param enable @c EINA_TRUE to enable the text autosizing
447 *               @c EINA_FALSE to disable
448 *
449 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
450 *
451 * @see ewk_settings_text_autosizing_enabled_get()
452 */
453EAPI Eina_Bool ewk_settings_text_autosizing_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
454
455/**
456 * Returns whether the text autosizing is enabled.
457 *
458 * The text autosizing is a feature which adjusts the font size of text in wide
459 * columns, and makes text more legible.
460 *
461 * @param settings settings object to query whether text autosizing is enabled
462 *
463 * @return @c EINA_TRUE if the text autosizing is enabled
464 *         @c EINA_FALSE if not or on failure
465 */
466EAPI Eina_Bool ewk_settings_text_autosizing_enabled_get(const Ewk_Settings *settings);
467
468/**
469 * Enables/disables web security.
470 *
471 * By default, the web security is enabled.
472 *
473 * @param settings settings object to set the web security
474 * @param enable @c EINA_TRUE to enable the web security
475 *               @c EINA_FALSE to disable
476 *
477 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
478 *
479 * @see ewk_settings_web_security_enabled_get()
480 */
481EAPI Eina_Bool ewk_settings_web_security_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
482
483/**
484 * Returns whether the web security is enabled.
485 *
486 * @param settings settings object to query whether web security is enabled
487 *
488 * @return @c EINA_TRUE if the web security is enabled
489 *         @c EINA_FALSE if not or on failure
490 */
491EAPI Eina_Bool ewk_settings_web_security_enabled_get(const Ewk_Settings *settings);
492
493/**
494 * Changes spatial navigation state.
495 *
496 * @param settings settings object to enable/disable spatial navigation
497 * @param enabled @c EINA_TRUE to enable spatial navigation
498 *                @c EINA_FALSE to disable spatial navigation
499 *
500 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
501 */
502EAPI Eina_Bool ewk_settings_spatial_navigation_enabled_set(Ewk_Settings *settings, Eina_Bool enable);
503
504/**
505 * Returns current state of spatial navigation.
506 *
507 * @param settings settings object to get whether spatial navigation is enabled
508 *
509 * @return @c EINA_TRUE if spatial navigation is enabled
510 *         @c EINA_FALSE if spatial navigation is disabled
511 */
512EAPI Eina_Bool ewk_settings_spatial_navigation_enabled_get(const Ewk_Settings *settings);
513
514#ifdef __cplusplus
515}
516#endif
517#endif // ewk_settings_h
518