aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-web-view.h
blob: 5b6a28d4cb9e062fdec9cdcca3b614654fea34b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
 *  Copyright © 2008 Gustavo Noronha Silva
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *  $Id$
 */

#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION)
#error "Only <epiphany/epiphany.h> can be included directly."
#endif

#ifndef EPHY_WEB_VIEW_H
#define EPHY_WEB_VIEW_H

#include <glib-object.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <webkit/webkit.h>

#include "ephy-embed-event.h"

G_BEGIN_DECLS

#define EPHY_TYPE_WEB_VIEW         (ephy_web_view_get_type ())
#define EPHY_WEB_VIEW(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_WEB_VIEW, EphyWebView))
#define EPHY_WEB_VIEW_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_WEB_VIEW, EphyWebViewClass))
#define EPHY_IS_WEB_VIEW(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_WEB_VIEW))
#define EPHY_IS_WEB_VIEW_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_WEB_VIEW))
#define EPHY_WEB_VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_WEB_VIEW, EphyWebViewClass))

typedef struct _EphyWebViewClass  EphyWebViewClass;
typedef struct _EphyWebView    EphyWebView;
typedef struct _EphyWebViewPrivate  EphyWebViewPrivate;

typedef enum
{
    EPHY_WEB_VIEW_NAV_UP        = 1 << 0,
    EPHY_WEB_VIEW_NAV_BACK      = 1 << 1,
    EPHY_WEB_VIEW_NAV_FORWARD   = 1 << 2
} EphyWebViewNavigationFlags;

typedef enum
{
    EPHY_WEB_VIEW_STATE_UNKNOWN     = 0,
    EPHY_WEB_VIEW_STATE_START       = 1 << 0,
    EPHY_WEB_VIEW_STATE_REDIRECTING     = 1 << 1,
    EPHY_WEB_VIEW_STATE_TRANSFERRING    = 1 << 2,
    EPHY_WEB_VIEW_STATE_NEGOTIATING     = 1 << 3,
    EPHY_WEB_VIEW_STATE_STOP        = 1 << 4,

    EPHY_WEB_VIEW_STATE_IS_REQUEST  = 1 << 5,
    EPHY_WEB_VIEW_STATE_IS_DOCUMENT = 1 << 6,
    EPHY_WEB_VIEW_STATE_IS_NETWORK  = 1 << 7,
    EPHY_WEB_VIEW_STATE_IS_WINDOW   = 1 << 8,
    EPHY_WEB_VIEW_STATE_RESTORING   = 1 << 9
} EphyWebViewNetState;

typedef enum
{
    EPHY_WEB_VIEW_CHROME_MENUBAR        = 1 << 0,
    EPHY_WEB_VIEW_CHROME_TOOLBAR        = 1 << 1,
    EPHY_WEB_VIEW_CHROME_STATUSBAR      = 1 << 2,
    EPHY_WEB_VIEW_CHROME_BOOKMARKSBAR   = 1 << 3
} EphyWebViewChrome;

#define EPHY_WEB_VIEW_CHROME_ALL (EPHY_WEB_VIEW_CHROME_MENUBAR |    \
                   EPHY_WEB_VIEW_CHROME_TOOLBAR |   \
                   EPHY_WEB_VIEW_CHROME_STATUSBAR | \
                   EPHY_WEB_VIEW_CHROME_BOOKMARKSBAR)

typedef enum
{
    EPHY_WEB_VIEW_STATE_IS_UNKNOWN,
    EPHY_WEB_VIEW_STATE_IS_INSECURE,
    EPHY_WEB_VIEW_STATE_IS_BROKEN,
    EPHY_WEB_VIEW_STATE_IS_SECURE_LOW,
    EPHY_WEB_VIEW_STATE_IS_SECURE_MED,
    EPHY_WEB_VIEW_STATE_IS_SECURE_HIGH
} EphyWebViewSecurityLevel;

typedef enum
{
    EPHY_WEB_VIEW_DOCUMENT_HTML,
    EPHY_WEB_VIEW_DOCUMENT_XML,
    EPHY_WEB_VIEW_DOCUMENT_IMAGE,
    EPHY_WEB_VIEW_DOCUMENT_OTHER
} EphyWebViewDocumentType;

struct _EphyWebView
{
  WebKitWebView parent;

  /*< private >*/
  EphyWebViewPrivate *priv;
};

struct _EphyWebViewClass
{
  WebKitWebViewClass parent_class;

  /* Signals */
  void   (* feed_link)      (EphyWebView *view,
                                 const char *type,
                                 const char *title,
                                 const char *address);
  void   (* search_link)    (EphyWebView *view,
                                 const char *type,
                                 const char *title,
                                 const char *address);
  gboolean (* dom_mouse_click)  (EphyWebView *view,
                                 EphyEmbedEvent *event);
  gboolean (* dom_mouse_down)   (EphyWebView *view,
                                 EphyEmbedEvent *event);
  void   (* dom_content_loaded) (EphyWebView *view,
                                 gpointer event);
  void   (* popup_blocked)  (EphyWebView *view,
                                 const char *address,
                                 const char *target,
                                 const char *features);
  void   (* content_blocked)    (EphyWebView *view,
                                 const char *uri);
  gboolean (* modal_alert)  (EphyWebView *view);
  void   (* modal_alert_closed) (EphyWebView *view);
  void   (* new_window)     (EphyWebView *view,
                                 EphyWebView *new_view);
  gboolean (* search_key_press) (EphyWebView *view,
                                 GdkEventKey *event);
  gboolean (* close_request)    (EphyWebView *view);

  void   (* new_document_now)   (EphyWebView *view,
                                 const char *uri);
};

GType                      ephy_web_view_get_type                (void);
GType                      ephy_web_view_net_state_get_type      (void);
GType                      ephy_web_view_chrome_get_type         (void);
GType                      ephy_web_view_security_level_get_type (void);
GtkWidget *                ephy_web_view_new                     (void);
void                       ephy_web_view_load_request            (EphyWebView                     *view,
                                                                  WebKitNetworkRequest            *request);
void                       ephy_web_view_load_url                (EphyWebView                     *view,
                                                                  const char                      *url);
void                       ephy_web_view_copy_back_history       (EphyWebView                     *source,
                                                                  EphyWebView                     *dest);
void                       ephy_web_view_clear_history           (EphyWebView                     *view);
gboolean                   ephy_web_view_is_loading              (EphyWebView                     *view);
const char *               ephy_web_view_get_loading_title       (EphyWebView                     *view);
GdkPixbuf *                ephy_web_view_get_icon                (EphyWebView                     *view);
EphyWebViewDocumentType    ephy_web_view_get_document_type       (EphyWebView                     *view);
EphyWebViewNavigationFlags ephy_web_view_get_navigation_flags    (EphyWebView                     *view);
const char *               ephy_web_view_get_status_message      (EphyWebView                     *view);
const char *               ephy_web_view_get_link_message        (EphyWebView                     *view);
gboolean                   ephy_web_view_get_visibility          (EphyWebView                     *view);
void                       ephy_web_view_set_link_message        (EphyWebView                     *view,
                                                                  char                            *link_message);
void                       ephy_web_view_set_security_level      (EphyWebView                     *view,
                                                                  EphyWebViewSecurityLevel         level);
void                       ephy_web_view_set_visibility          (EphyWebView                     *view,
                                                                  gboolean                         visibility);
const char *               ephy_web_view_get_typed_address       (EphyWebView                     *view);
void                       ephy_web_view_set_typed_address       (EphyWebView                     *view,
                                                                  const char                      *address);
gboolean                   ephy_web_view_get_is_blank            (EphyWebView                     *view);
gboolean                   ephy_web_view_has_modified_forms      (EphyWebView                     *view);
char *                     ephy_web_view_get_location            (EphyWebView                     *view,
                                                                  gboolean                         toplevel);
void                       ephy_web_view_go_up                   (EphyWebView                     *view);
char *                     ephy_web_view_get_js_status           (EphyWebView                     *view);
void                       ephy_web_view_get_security_level      (EphyWebView                     *view,
                                                                  EphyWebViewSecurityLevel        *level,
                                                                  char                           **description);
void                       ephy_web_view_show_page_certificate   (EphyWebView                     *view);
void                       ephy_web_view_show_print_preview      (EphyWebView                     *view);
void                       ephy_web_view_print                   (EphyWebView                     *view);
GSList *                   ephy_web_view_get_go_up_list          (EphyWebView                     *view);
void                       ephy_web_view_set_title               (EphyWebView                     *view,
                                                                  const char                      *view_title);
const char *               ephy_web_view_get_title               (EphyWebView                     *view);
gboolean                   ephy_web_view_can_go_up               (EphyWebView                     *view);
const char *               ephy_web_view_get_address             (EphyWebView                     *view);
const char *               ephy_web_view_get_title_composite     (EphyWebView                     *view);

/* These should be private */
void                       ephy_web_view_set_address             (EphyWebView                     *view,
                                                                  const char                      *address);
void                       ephy_web_view_update_from_net_state   (EphyWebView                     *view,
                                                                  const char                      *uri,
                                                                  EphyWebViewNetState              state);
void                       ephy_web_view_location_changed        (EphyWebView                     *view,
                                                                  const char                      *location);
void                       ephy_web_view_set_loading_title       (EphyWebView                     *view,
                                                                  const char                      *title,
                                                                  gboolean                         is_address);
void                       ephy_web_view_popups_manager_reset    (EphyWebView                     *view);

void                       ephy_web_view_save                    (EphyWebView                     *view,
                                                                  const char                      *uri);

G_END_DECLS

#endif