1 /*
2  * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
3  * Copyright 2006 James Bursa <bursa@users.sourceforge.net>
4  *
5  * This file is part of NetSurf, http://www.netsurf-browser.org/
6  *
7  * NetSurf is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License.
10  *
11  * NetSurf is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 /**
21  * \file
22  * Browser window creation and manipulation interface.
23  */
24 
25 #ifndef NETSURF_BROWSER_WINDOW_H_
26 #define NETSURF_BROWSER_WINDOW_H_
27 
28 #include <stdbool.h>
29 #include <stdio.h>
30 
31 #include "utils/errors.h"
32 #include "netsurf/mouse.h"
33 #include "netsurf/console.h"
34 
35 struct browser_window;
36 struct hlcache_handle;
37 struct gui_window;
38 struct history;
39 struct selection;
40 struct fetch_multipart_data;
41 struct form_control;
42 struct nsurl;
43 struct rect;
44 struct redraw_context;
45 struct cert_chain;
46 enum content_debug;
47 
48 /**
49  * type of browser window drag in progess
50  */
51 typedef enum {
52 	DRAGGING_NONE,
53 	DRAGGING_SELECTION,
54 	DRAGGING_PAGE_SCROLL,
55 	DRAGGING_FRAME,
56 	DRAGGING_SCR_X,
57 	DRAGGING_SCR_Y,
58 	DRAGGING_CONTENT_SCROLLBAR,
59 	DRAGGING_OTHER
60 } browser_drag_type;
61 
62 /**
63  * Browser window page information states
64  */
65 typedef enum {
66 	PAGE_STATE_UNKNOWN,		/**< Unable to determine */
67 	PAGE_STATE_INTERNAL,		/**< Page loaded from internal handler */
68 	PAGE_STATE_LOCAL,		/**< Page loaded from file:/// etc */
69 	PAGE_STATE_INSECURE,		/**< Insecure page load */
70 	PAGE_STATE_SECURE_OVERRIDE,	/**< Secure load, but had to override */
71 	PAGE_STATE_SECURE_ISSUES,	/**< Secure load, but has insecure elements */
72 	PAGE_STATE_SECURE,		/**< Secure load */
73 	PAGE_STATE__COUNT,		/**< Count of number of valid page states */
74 } browser_window_page_info_state;
75 
76 typedef enum {
77 	BW_EDITOR_NONE		=  0,		/**< No selection, no editing */
78 	BW_EDITOR_CAN_COPY	= (1 << 0),	/**< Have selection */
79 	BW_EDITOR_CAN_CUT  	= (1 << 1),	/**< Selection not read-only */
80 	BW_EDITOR_CAN_PASTE	= (1 << 2)	/**< Can paste, input */
81 } browser_editor_flags;
82 
83 typedef enum {
84 	BW_SCROLLING_AUTO,
85 	BW_SCROLLING_YES,
86 	BW_SCROLLING_NO
87 } browser_scrolling;
88 
89 /** flags to browser_window_create */
90 enum browser_window_create_flags {
91 	/** No flags set */
92 	BW_CREATE_NONE			= 0,
93 
94 	/** this will form a new history node (don't set for back/reload/etc) */
95 	BW_CREATE_HISTORY		= (1 << 0),
96 
97 	/** New gui_window to be tab in same window as "existing" gui_window */
98 	BW_CREATE_TAB			= (1 << 1),
99 
100 	/** New gui_window to be clone of "existing" gui_window */
101 	BW_CREATE_CLONE			= (1 << 2),
102 
103 	/** Window not opened by user interaction (e.g. JS popup)
104 	 *
105 	 * rfc2965:
106 	 *    A transaction is verifiable if the user, or a
107 	 *    user-designated agent, has the option to review
108 	 *    the request-URI prior to its use in the transaction.
109 	 *    A transaction is unverifiable if the user does not
110 	 *    have that option.
111 	 */
112 	BW_CREATE_UNVERIFIABLE		= (1 << 3),
113 
114 	/** Request foreground opening. */
115 	BW_CREATE_FOREGROUND		= (1 << 4),
116 
117 	/** Request location bar focus. */
118 	BW_CREATE_FOCUS_LOCATION	= (1 << 5),
119 };
120 
121 /** flags to browser_window_navigate  */
122 enum browser_window_nav_flags {
123 	/** No flags set */
124 	BW_NAVIGATE_NONE		= 0,
125 
126 	/** this will form a new history node (don't set for back/reload/etc) */
127 	BW_NAVIGATE_HISTORY		= (1 << 0),
128 
129 	/** download rather than render the uri */
130 	BW_NAVIGATE_DOWNLOAD		= (1 << 1),
131 
132 	/** Transation not caused by user interaction (e.g. JS-caused)
133 	 *
134 	 * rfc2965:
135 	 *    A transaction is verifiable if the user, or a
136 	 *    user-designated agent, has the option to review
137 	 *    the request-URI prior to its use in the transaction.
138 	 *    A transaction is unverifiable if the user does not
139 	 *    have that option.
140 	 */
141 	BW_NAVIGATE_UNVERIFIABLE	= (1 << 2),
142 
143 	/** suppress initial history updates (used by back/fwd/etc) */
144 	BW_NAVIGATE_NO_TERMINAL_HISTORY_UPDATE = (1 << 3),
145 
146 	/** Internal navigation (set only by core features using such) */
147 	BW_NAVIGATE_INTERNAL            = (1 << 4)
148 };
149 
150 /**
151  * Page features at a specific spatial location.
152  */
153 struct browser_window_features {
154 	/** URL of a link or NULL. */
155 	struct nsurl *link;
156 
157 	/** Object at position or NULL. */
158 	struct hlcache_handle *object;
159 
160 	/** handle of top level content. */
161 	struct hlcache_handle *main;
162 
163 	/** type of form feature. */
164 	enum {
165 		CTX_FORM_NONE,
166 		CTX_FORM_TEXT,
167 		CTX_FORM_FILE
168 	} form_features;
169 };
170 
171 /**
172  * Create and open a new root browser window with the given page.
173  *
174  * \param flags		Flags to control operation
175  * \param url		URL to fetch in the new window or NULL for blank
176  * \param referrer	The referring uri or NULL if none
177  * \param existing	The an existing bw or NULL, required for some flags.
178  * \param bw		Updated to created browser window or untouched on error.
179  * \return NSERROR_OK, or appropriate error otherwise.
180  */
181 nserror browser_window_create(enum browser_window_create_flags flags,
182 		struct nsurl *url, struct nsurl *referrer,
183 		struct browser_window *existing,
184 		struct browser_window **bw);
185 
186 /**
187  * Start fetching a page in a browser window.
188  *
189  * \param bw		  browser window
190  * \param url		  URL to start fetching
191  * \param flags           Flags to control operation
192  * \param referrer	  The referring uri or NULL if none
193  * \param post_urlenc	  url encoded post data or NULL if none
194  * \param post_multipart  multipart post data or NULL if none
195  * \param parent	  Parent content or NULL if none
196  *
197  * Any existing fetches in the window are aborted.
198  *
199  * If post_urlenc and post_multipart are NULL the url is fetched using
200  * GET rather than POST.
201  *
202  */
203 nserror browser_window_navigate(struct browser_window *bw,
204 			     struct nsurl *url,
205 			     struct nsurl *referrer,
206 			     enum browser_window_nav_flags flags,
207 			     char *post_urlenc,
208 			     struct fetch_multipart_data *post_multipart,
209 			     struct hlcache_handle *parent);
210 
211 /**
212  * Return true if a browser window can navigate upwards.
213  *
214  * \param bw the browser window to test.
215  * \return true if navigation up is possible otherwise false.
216  */
217 bool browser_window_up_available(struct browser_window *bw);
218 
219 /**
220  * Navigate to a browser_window's parent URL.
221  *
222  * \param bw		browser window
223  * \param new_window	whether to open parent in a new window, or existing
224  */
225 nserror browser_window_navigate_up(struct browser_window *bw, bool new_window);
226 
227 /**
228  * Access a browser window's URL.  This URL is always without any fragment.
229  *
230  * \param bw browser window
231  * \return pointer to nsurl. Doesn't create a ref for caller.
232  *
233  * \note guaranteed to return a valid nsurl ptr, never returns NULL.
234  */
235 struct nsurl* browser_window_access_url(const struct browser_window *bw);
236 
237 /**
238  * Access a browser window's URL.
239  *
240  * \param[in]  bw        browser window
241  * \param[in]  fragment  Whether to include any URL fragment.
242  * \param[out] url_out   Returns a ref to the URL on success.
243  * \return NSERROR_OK, or appropriate error otherwise.
244  */
245 nserror browser_window_get_url(
246 		struct browser_window *bw,
247 		bool fragment,
248 		struct nsurl** url_out);
249 
250 /**
251  * Get the title of a browser_window.
252  *
253  * \param bw The browser window.
254  */
255 const char* browser_window_get_title(struct browser_window *bw);
256 
257 /**
258  * Get a browser window's history object.
259  *
260  * \param bw	  browser window
261  * \return pointer browser window's history object
262  *
263  * Clients need history object to make use of the history_* functions.
264  */
265 struct history * browser_window_get_history(struct browser_window *bw);
266 
267 /**
268  * Get a browser window's content extents.
269  *
270  * \param bw	  browser window
271  * \param scaled  whether to apply current browser window scale
272  * \param width   updated to content width extent in px
273  * \param height  updated to content height extent in px
274  * \return NSERROR_OK, or appropriate error otherwise.
275  */
276 nserror browser_window_get_extents(struct browser_window *bw, bool scaled,
277 		int *width, int *height);
278 
279 /**
280  * Find out if a browser window is currently showing a content.
281  *
282  * \param bw	  browser window
283  * \return true iff browser window is showing a content, else false.
284  */
285 bool browser_window_has_content(struct browser_window *bw);
286 
287 /**
288  * Get a cache handle for the content within a browser window.
289  */
290 struct hlcache_handle *browser_window_get_content(struct browser_window *bw);
291 
292 
293 /**
294  * Set the dimensions of the area a browser window occupies
295  *
296  * \param  bw      The browser window to set dimensions of
297  * \param  width   Width in pixels
298  * \param  height  Height in pixels
299  */
300 void browser_window_set_dimensions(struct browser_window *bw,
301 		int width, int height);
302 
303 
304 /**
305  * Redraw browser window, set extent to content, and update title.
306  *
307  * \param  bw		  browser_window
308  * \param  scroll_to_top  move view to top of page
309  */
310 void browser_window_update(struct browser_window *bw, bool scroll_to_top);
311 
312 
313 /**
314  * Stop all fetching activity in a browser window.
315  *
316  * \param bw The browser window to stop activity in.
317  */
318 void browser_window_stop(struct browser_window *bw);
319 
320 
321 /**
322  * Reload the page in a browser window.
323  *
324  * \param bw browser window
325  * \param all whether to reload all objects associated with the page
326  * \return NSERROR_OK on success else error code.
327  */
328 nserror browser_window_reload(struct browser_window *bw, bool all);
329 
330 
331 /**
332  * Close and destroy a browser window.
333  *
334  * \param  bw  browser window
335  */
336 void browser_window_destroy(struct browser_window *bw);
337 
338 
339 /**
340  * Reformat a browser window contents to a new width or height.
341  *
342  * This API is not safe to call from all contexts and care must be used.
343  *
344  * \warning This API is generally only useful within the browser core
345  * and is only exposed for historical reasons. A frontend almost
346  * certianly actually wants browser_window_schedule_reformat() and not
347  * this.
348  *
349  * \param bw         The browser window to reformat.
350  * \param background Reformat in the background.
351  * \param width      new width
352  * \param height     new height
353  */
354 void browser_window_reformat(struct browser_window *bw, bool background, int width, int height);
355 
356 
357 /**
358  * Sets the scale of a browser window.
359  *
360  * \param bw The browser window to scale.
361  * \param scale The new scale.
362  * \param absolute If the scale value is absolute or relative to current value
363  * \return NSERROR_OK and scale applied else other error code caused by reflow etc.
364  */
365 nserror browser_window_set_scale(struct browser_window *bw, float scale, bool absolute);
366 
367 
368 /**
369  * Gets the scale of a browser window
370  *
371  * \param bw The browser window to get the scale of.
372  * \return The scale of the window.
373  */
374 float browser_window_get_scale(struct browser_window *bw);
375 
376 
377 /**
378  * Get access to any page features at the given coordinates.
379  *
380  * Fetches page features like content, link URLs and objects (images)
381  * at the specified co-ordinates within the browsing context.
382  *
383  * Fields within the supplied features structure are updated with
384  * pointers to any relevent content, or set to NULL if none.
385  *
386  * \param[in] bw browser window to examine.
387  * \param[in] x x-coordinate of point of interest
388  * \param[in] y y-coordinate of point of interest
389  * \param[out] data Feature structure to update.
390  * \return NSERROR_OK or appropriate error code on faliure.
391  */
392 nserror browser_window_get_features(struct browser_window *bw,
393 		int x, int y, struct browser_window_features *data);
394 
395 
396 /**
397  * Send a scroll request to a browser window at a particular point.  The
398  * 'deepest' scrollable object which can be scrolled in the requested
399  * direction at the given point will consume the scroll.
400  *
401  * \param bw	browser window to look inside
402  * \param x	x-coordinate of point of interest
403  * \param y	y-coordinate of point of interest
404  * \param scrx	number of px try to scroll something in x direction
405  * \param scry	number of px try to scroll something in y direction
406  * \return true iff scroll request has been consumed
407  */
408 bool browser_window_scroll_at_point(struct browser_window *bw,
409 		int x, int y, int scrx, int scry);
410 
411 
412 /**
413  * Drop a file onto a browser window at a particular point, or determine if a
414  * file may be dropped onto the content at given point.
415  *
416  * \param bw	browser window to look inside
417  * \param x	x-coordinate of point of interest
418  * \param y	y-coordinate of point of interest
419  * \param file	path to file to be dropped, or NULL to know if drop allowed
420  * \return true iff file drop has been handled, or if drop possible (NULL file)
421  */
422 bool browser_window_drop_file_at_point(struct browser_window *bw,
423 		int x, int y, char *file);
424 
425 
426 /**
427  * set filename on form control.
428  *
429  * \param bw browser window to look inside.
430  * \param gadget form control.
431  * \param fn filename to set.
432  */
433 void browser_window_set_gadget_filename(struct browser_window *bw,
434 		struct form_control *gadget, const char *fn);
435 
436 
437 /**
438  * Update URL bar for a given browser window to bw's content's URL
439  *
440  * \param bw Browser window to update URL bar for.
441  */
442 nserror browser_window_refresh_url_bar(struct browser_window *bw);
443 
444 
445 /**
446  * Handle mouse clicks in a browser window.
447  *
448  * \param  bw	  browser window
449  * \param  mouse  state of mouse buttons and modifier keys
450  * \param  x	  coordinate of mouse
451  * \param  y	  coordinate of mouse
452  */
453 void browser_window_mouse_click(struct browser_window *bw,
454 		browser_mouse_state mouse, int x, int y);
455 
456 
457 /**
458  * Handle non-click mouse action in a browser window. (drag ends, movements)
459  *
460  * \param  bw	  browser window
461  * \param  mouse  state of mouse buttons and modifier keys
462  * \param  x	  coordinate of mouse
463  * \param  y	  coordinate of mouse
464  */
465 void browser_window_mouse_track(struct browser_window *bw,
466 		browser_mouse_state mouse, int x, int y);
467 
468 
469 /**
470  * Locate a browser window in the specified stack according.
471  *
472  * \param bw  the browser_window to search all relatives of
473  * \param target  the target to locate
474  * \param mouse The current mouse state
475  * \return The browser window the mouse is in
476  */
477 struct browser_window *browser_window_find_target(
478 		struct browser_window *bw, const char *target,
479 		browser_mouse_state mouse);
480 
481 
482 /**
483  * Reformat the browser window contents in a safe context.
484  *
485  * The browser_window_reformat() call cannot safely be called from some
486  * contexts, This interface allows for the reformat to happen from a safe
487  * top level context.
488  *
489  * The reformat uses the window table get_dimensions() callback as the
490  * correct viewport dimensions are only available to the frontend.
491  *
492  * \param bw The browser window to reformat the content of.
493  * \return NSERROR_OK on success else appropriate error code.
494  */
495 nserror browser_window_schedule_reformat(struct browser_window *bw);
496 
497 
498 /**
499  * Change the shape of the mouse pointer
500  *
501  * \param bw Browser window to set shape in
502  * \param shape The pointer shape to use
503  */
504 void browser_window_set_pointer(struct browser_window *bw,
505 		browser_pointer_shape shape);
506 
507 
508 /**
509  * Start drag scrolling the contents of the browser window
510  *
511  * \param bw  browser window
512  * \param x   x ordinate of initial mouse position
513  * \param y   y ordinate
514  */
515 void browser_window_page_drag_start(struct browser_window *bw, int x, int y);
516 
517 
518 /**
519  * Check availability of Back action for a given browser window
520  *
521  * \param bw  browser window
522  * \return true if Back action is available
523  */
524 bool browser_window_back_available(struct browser_window *bw);
525 
526 
527 /**
528  * Check availability of Forward action for a given browser window
529  *
530  * \param bw  browser window
531  * \return true if Forward action is available
532  */
533 bool browser_window_forward_available(struct browser_window *bw);
534 
535 
536 /**
537  * Check availability of Reload action for a given browser window
538  *
539  * \param bw  browser window
540  * \return true if Reload action is available
541  */
542 bool browser_window_reload_available(struct browser_window *bw);
543 
544 
545 /**
546  * Check availability of Stop action for a given browser window
547  *
548  * \param bw  browser window
549  * \return true if Stop action is available
550  */
551 bool browser_window_stop_available(struct browser_window *bw);
552 
553 
554 /**
555  * Redraw an area of a window.
556  *
557  * Calls the redraw function for the content.
558  *
559  * \param  bw    The window to redraw
560  * \param  x     coordinate for top-left of redraw
561  * \param  y     coordinate for top-left of redraw
562  * \param  clip  clip rectangle coordinates
563  * \param  ctx   redraw context
564  * \return true if successful, false otherwise
565  *
566  * The clip rectangle is guaranteed to be filled to its extents, so there is
567  * no need to render a solid background first.
568  *
569  * x, y and clip are coordinates from the top left of the canvas area.
570  *
571  * The top left corner of the clip rectangle is (x0, y0) and
572  * the bottom right corner of the clip rectangle is (x1, y1).
573  * Units for x, y and clip are pixels.
574  */
575 bool browser_window_redraw(struct browser_window *bw, int x, int y,
576 		const struct rect *clip, const struct redraw_context *ctx);
577 
578 
579 /**
580  * Check whether browser window is ready for redraw
581  *
582  * \param  bw    The window to redraw
583  * \return true if browser window is ready for redraw
584  */
585 bool browser_window_redraw_ready(struct browser_window *bw);
586 
587 /**
588  * Get the position of the current browser window with respect to the root or
589  * parent browser window
590  *
591  * \param  bw     browser window to get the position of
592  * \param  root   true if we want position wrt root bw, false if wrt parent bw
593  * \param  pos_x  updated to x position of bw
594  * \param  pos_y  updated to y position of bw
595  */
596 void browser_window_get_position(struct browser_window *bw, bool root,
597 		int *pos_x, int *pos_y);
598 
599 /**
600  * Set the position of the current browser window with respect to the parent
601  * browser window
602  *
603  * \param  bw     browser window to set the position of
604  * \param  x      x position of bw
605  * \param  y      y position of bw
606  */
607 void browser_window_set_position(struct browser_window *bw, int x, int y);
608 
609 
610 /**
611  * Set drag type for a browser window, and inform front end
612  *
613  * \param  bw     browser window to set the type of the current drag for
614  * \param  type   drag type
615  * \param  rect   area pointer may be confined to, during drag, or NULL
616  */
617 void browser_window_set_drag_type(struct browser_window *bw,
618 		browser_drag_type type, const struct rect *rect);
619 
620 /**
621  * Get type of any current drag for a browser window
622  *
623  * \param  bw     browser window to set the type of the current drag for
624  * \return  drag type
625  */
626 browser_drag_type browser_window_get_drag_type(struct browser_window *bw);
627 
628 /**
629  * Check whether browser window can accept a cut/copy/paste, or has a selection
630  * that could be saved.
631  *
632  * \param  bw    The browser window
633  * \return flags indicating editor flags
634  */
635 browser_editor_flags browser_window_get_editor_flags(struct browser_window *bw);
636 
637 /**
638  * Find out if given browser window content is selectable
639  *
640  * \param bw	browser window to look at
641  * \return true iff browser window is selectable
642  */
643 bool browser_window_can_select(struct browser_window *bw);
644 
645 /**
646  * Get the current selection from a root browser window, ownership passed to
647  * caller, who must free() it.
648  *
649  * \param  bw    The browser window
650  * \return the selected text string, or NULL
651  */
652 char * browser_window_get_selection(struct browser_window *bw);
653 
654 /**
655  * Find out if given browser window can be searched
656  *
657  * \param bw	browser window to look at
658  * \return true iff browser window is searchable
659  */
660 bool browser_window_can_search(struct browser_window *bw);
661 
662 /**
663  * Find out if a browser window contains a frameset
664  *
665  * \param bw	browser window to look at
666  * \return true iff browser window contains a frameset
667  */
668 bool browser_window_is_frameset(struct browser_window *bw);
669 
670 /**
671  * Get the browser window's scrollbar details.
672  *
673  * Vertical and horizontal scrollbars may be {YES|NO|AUTO}, although
674  * it is entirely up to the front end whether this is implemented.
675  * e.g. if the gui toolkit style-guide says all windows must have
676  * scrollbars then this API can be ignored.
677  *
678  * \param bw  browser window to look at
679  * \param h   Updated to indicate horizontal scrollbar type
680  * \param v   Updated to indicate vertical scrollbar type
681  * \return NSERROR_OK, or appropriate error otherwise
682  */
683 nserror browser_window_get_scrollbar_type(struct browser_window *bw,
684 		browser_scrolling *h, browser_scrolling *v);
685 
686 
687 /**
688  * Dump debug info concerning the browser window's contents to file
689  *
690  * \param bw The browser window.
691  * \param f The file to dump to.
692  * \param op The debug operation type to dump.
693  * \return NSERROR_OK on success or error code on faliure.
694  */
695 nserror browser_window_debug_dump(struct browser_window *bw, FILE *f, enum content_debug op);
696 
697 /**
698  * Set debug options on a window
699  *
700  * \param bw The browser window.
701  * \param op The debug operation type.
702  * \return NSERROR_OK on success or error code on faliure.
703  */
704 nserror browser_window_debug(struct browser_window *bw, enum content_debug op);
705 
706 /**
707  * Obtain a browsing contexts name.
708  *
709  * The returned pointer is owned bu the browsing context and is only
710  *  valid untill the next operation on that context.
711  * The returned name may be NULL if no name has been set.
712  * \todo This does not consider behaviour wrt frames
713  *
714  * \param bw The browser window.
715  * \param name recives result string.
716  * \return NSERROR_OK
717  */
718 nserror browser_window_get_name(struct browser_window *bw, const char **name);
719 
720 /**
721  * Set a browsing contexts name.
722  *
723  * Changes a browsing contexts name to a copy of that passed and the
724  *  value is not subsequently referenced.
725  *
726  * \param bw The browser window.
727  * \param name The name string to set.
728  * \return NSERROR_OK and the name is updated or NSERROR_NOMEM and the
729  *         original name is untouched.
730  */
731 nserror browser_window_set_name(struct browser_window *bw, const char *name);
732 
733 /**
734  * Execute some JavaScript code in a browsing context.
735  *
736  * Runs the passed in JavaScript code in the browsing context.
737  *
738  * \param bw The browser window
739  * \param src The JavaScript source code
740  * \param srclen The length of the source code
741  * \return Whether the JS function was successfully injected into the content
742  */
743 bool browser_window_exec(struct browser_window *bw, const char *src, size_t srclen);
744 
745 /**
746  * Log a console message into the browser window console.
747  *
748  * If the targetted browser window is a frame, the message will be bubbled
749  * to the outermost window to be logged.
750  *
751  * \param bw The browser window
752  * \param src The source of the message
753  * \param msg The text of the message
754  * \param msglen The length of the text of the message
755  * \param flags Flags for the message
756  * \return Whether or not the logged message succeeded in being stored
757  */
758 nserror browser_window_console_log(struct browser_window *bw,
759 				   browser_window_console_source src,
760 				   const char *msg,
761 				   size_t msglen,
762 				   browser_window_console_flags flags);
763 
764 /**
765  * Request the current browser window page info state.
766  *
767  * The page information state is an indicator enumeration to be used by
768  * frontends to indicate to the user if the page they are viewing is able
769  * to be trusted.  This is often shown as a padlock of some kind.
770  *
771  * This is also used by the internal page information corewindow to render
772  * to the user what the situation is.
773  *
774  * \param bw The browser window
775  * \return The state of the browser window
776  */
777 browser_window_page_info_state browser_window_get_page_info_state(
778 		const struct browser_window *bw);
779 
780 /**
781  * Request the current browser window SSL certificate chain.
782  *
783  * When the page has SSL information, this will retrieve the certificate chain.
784  *
785  * If there is no chain available, this will return NSERROR_NOT_FOUND
786  *
787  * \param bw The browser window
788  * \param chain Pointer to be filled out with certificate chain
789  * \return Whether or not the chain is available
790  */
791 nserror browser_window_get_ssl_chain(struct browser_window *bw, struct cert_chain **chain);
792 
793 /**
794  * Get the number of cookies in use for the current page.
795  *
796  * \param bw  A browser window.
797  * \return Number of cookies in use, or 0 on error.
798  */
799 int browser_window_get_cookie_count(
800 		const struct browser_window *bw);
801 
802 /**
803  * Open cookie viewer for the current page.
804  *
805  * \param bw  A browser window.
806  * \return NSERROR_OK, or appropriate error otherwise.
807  */
808 nserror browser_window_show_cookies(
809 		const struct browser_window *bw);
810 
811 /**
812  * Show the certificate page for the current page.
813  *
814  * Does nothing for a page without certificates.
815  *
816  * \param bw  A browser window.
817  * \return NSERROR_OK, or appropriate error otherwise.
818  */
819 nserror browser_window_show_certificates(
820 		struct browser_window *bw);
821 
822 #endif
823