1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* 3 * Copyright © 2008 Gustavo Noronha Silva 4 * Copyright © 2012 Igalia S.L. 5 * 6 * This file is part of Epiphany. 7 * 8 * Epiphany is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * Epiphany is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with Epiphany. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #pragma once 23 24 #include <webkit2/webkit2.h> 25 26 #include "ephy-embed-shell.h" 27 #include "ephy-history-types.h" 28 #include "ephy-security-levels.h" 29 30 G_BEGIN_DECLS 31 32 #define EPHY_TYPE_WEB_VIEW (ephy_web_view_get_type ()) 33 34 G_DECLARE_FINAL_TYPE (EphyWebView, ephy_web_view, EPHY, WEB_VIEW, WebKitWebView) 35 36 #define EPHY_WEB_VIEW_NON_SEARCH_REGEX "(" \ 37 "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9](:[0-9]+)?.*$|" \ 38 "^::[0-9a-f:]*$|" \ 39 "^[0-9a-f:]+:[0-9a-f:]*$|" \ 40 "^https?://[^/\\.[:space:]]+.*$|" \ 41 "^about:.*$|" \ 42 "^data:.*$|" \ 43 "^file:.*$|" \ 44 "^inspector://.*$|" \ 45 "^webkit://.*$|" \ 46 "^ephy-resource://.*$|" \ 47 "^ephy-reader:.*$" \ 48 ")" 49 50 #define EPHY_WEB_VIEW_DOMAIN_REGEX "^localhost(\\.[^[:space:]]+)?(:\\d+)?(:[0-9]+)?(/.*)?$|" \ 51 "^[^\\.[:space:]]+\\.[^\\.[:space:]]+.*$|" 52 53 typedef enum 54 { 55 EPHY_WEB_VIEW_NAV_BACK = 1 << 0, 56 EPHY_WEB_VIEW_NAV_FORWARD = 1 << 1 57 } EphyWebViewNavigationFlags; 58 59 typedef enum 60 { 61 EPHY_WEB_VIEW_DOCUMENT_HTML, 62 EPHY_WEB_VIEW_DOCUMENT_XML, 63 EPHY_WEB_VIEW_DOCUMENT_IMAGE, 64 EPHY_WEB_VIEW_DOCUMENT_PDF, 65 EPHY_WEB_VIEW_DOCUMENT_OTHER 66 } EphyWebViewDocumentType; 67 68 typedef enum { 69 EPHY_WEB_VIEW_ERROR_PAGE_NONE, 70 EPHY_WEB_VIEW_ERROR_PAGE_NETWORK_ERROR, 71 EPHY_WEB_VIEW_ERROR_PAGE_CRASH, 72 EPHY_WEB_VIEW_ERROR_PROCESS_CRASH, 73 EPHY_WEB_VIEW_ERROR_UNRESPONSIVE_PROCESS, 74 EPHY_WEB_VIEW_ERROR_INVALID_TLS_CERTIFICATE, 75 EPHY_WEB_VIEW_ERROR_UNSAFE_BROWSING, 76 EPHY_WEB_VIEW_ERROR_NO_SUCH_FILE, 77 } EphyWebViewErrorPage; 78 79 typedef void (* EphyPasswordSaveRequestCallback) (int response_id, 80 gpointer data); 81 82 GType ephy_web_view_chrome_get_type (void); 83 GType ephy_web_view_security_level_get_type (void); 84 GtkWidget * ephy_web_view_new (void); 85 GtkWidget *ephy_web_view_new_with_related_view (WebKitWebView *related_view); 86 void ephy_web_view_load_request (EphyWebView *view, 87 WebKitURIRequest *request); 88 void ephy_web_view_load_url (EphyWebView *view, 89 const char *url); 90 gboolean ephy_web_view_is_loading (EphyWebView *view); 91 gboolean ephy_web_view_load_failed (EphyWebView *view); 92 GdkPixbuf * ephy_web_view_get_icon (EphyWebView *view); 93 EphyWebViewDocumentType ephy_web_view_get_document_type (EphyWebView *view); 94 EphyWebViewNavigationFlags ephy_web_view_get_navigation_flags (EphyWebView *view); 95 const char * ephy_web_view_get_status_message (EphyWebView *view); 96 const char * ephy_web_view_get_link_message (EphyWebView *view); 97 void ephy_web_view_set_link_message (EphyWebView *view, 98 const char *address); 99 void ephy_web_view_set_security_level (EphyWebView *view, 100 EphySecurityLevel level); 101 const char * ephy_web_view_get_typed_address (EphyWebView *view); 102 void ephy_web_view_set_typed_address (EphyWebView *view, 103 const char *address); 104 gboolean ephy_web_view_get_should_bypass_safe_browsing (EphyWebView *view); 105 void ephy_web_view_set_should_bypass_safe_browsing (EphyWebView *view, 106 gboolean bypass_safe_browsing); 107 gboolean ephy_web_view_get_is_blank (EphyWebView *view); 108 gboolean ephy_web_view_is_overview (EphyWebView *view); 109 void ephy_web_view_has_modified_forms (EphyWebView *view, 110 GCancellable *cancellable, 111 GAsyncReadyCallback callback, 112 gpointer user_data); 113 gboolean ephy_web_view_has_modified_forms_finish (EphyWebView *view, 114 GAsyncResult *result, 115 GError **error); 116 void ephy_web_view_get_security_level (EphyWebView *view, 117 EphySecurityLevel *level, 118 const char **address, 119 GTlsCertificate **certificate, 120 GTlsCertificateFlags *errors); 121 void ephy_web_view_print (EphyWebView *view); 122 const char * ephy_web_view_get_address (EphyWebView *view); 123 const char * ephy_web_view_get_display_address (EphyWebView *view); 124 void ephy_web_view_set_placeholder (EphyWebView *view, 125 const char *uri, 126 const char *title); 127 EphyWebViewErrorPage ephy_web_view_get_error_page (EphyWebView *view); 128 void ephy_web_view_load_error_page (EphyWebView *view, 129 const char *uri, 130 EphyWebViewErrorPage page, 131 GError *error, 132 gpointer user_data); 133 void ephy_web_view_get_best_web_app_icon (EphyWebView *view, 134 GCancellable *cancellable, 135 GAsyncReadyCallback callback, 136 gpointer user_data); 137 gboolean ephy_web_view_get_best_web_app_icon_finish (EphyWebView *view, 138 GAsyncResult *result, 139 char **icon_uri, 140 GdkRGBA *icon_color, 141 GError **error); 142 void ephy_web_view_get_web_app_title (EphyWebView *view, 143 GCancellable *cancellable, 144 GAsyncReadyCallback callback, 145 gpointer user_data); 146 char *ephy_web_view_get_web_app_title_finish (EphyWebView *view, 147 GAsyncResult *result, 148 GError **error); 149 void ephy_web_view_get_web_app_mobile_capable (EphyWebView *view, 150 GCancellable *cancellable, 151 GAsyncReadyCallback callback, 152 gpointer user_data); 153 gboolean ephy_web_view_get_web_app_mobile_capable_finish (EphyWebView *view, 154 GAsyncResult *result, 155 GError **error); 156 157 void ephy_web_view_set_visit_type (EphyWebView *view, 158 EphyHistoryPageVisitType visit_type); 159 EphyHistoryPageVisitType ephy_web_view_get_visit_type (EphyWebView *view); 160 161 void ephy_web_view_save (EphyWebView *view, 162 const char *uri); 163 void ephy_web_view_load_homepage (EphyWebView *view); 164 void ephy_web_view_load_new_tab_page (EphyWebView *view); 165 166 char * ephy_web_view_create_web_application (EphyWebView *view, 167 const char *title, 168 GdkPixbuf *icon); 169 170 void ephy_web_view_toggle_reader_mode (EphyWebView *view, 171 gboolean active); 172 173 gboolean ephy_web_view_is_reader_mode_available (EphyWebView *view); 174 175 gboolean ephy_web_view_get_reader_mode_state (EphyWebView *view); 176 177 gboolean ephy_web_view_is_in_auth_dialog (EphyWebView *view); 178 179 void ephy_web_view_show_auth_form_save_request (EphyWebView *web_view, 180 const char *origin, 181 const char *username, 182 EphyPasswordSaveRequestCallback response_callback, 183 gpointer response_data, 184 GDestroyNotify response_destroy); 185 186 GtkWidget *ephy_web_view_new_with_user_content_manager (WebKitUserContentManager *ucm); 187 188 guint64 ephy_web_view_get_uid (EphyWebView *web_view); 189 190 G_END_DECLS 191