| 1 | /* |
| 2 | * Copyright (C) 2012 Igalia S.L. |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Library General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Library General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Library General Public License |
| 15 | * along with this library; see the file COPYING.LIB. If not, write to |
| 16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | #include "config.h" |
| 21 | #include "WebKitPermissionRequest.h" |
| 22 | |
| 23 | /** |
| 24 | * SECTION: WebKitPermissionRequest |
| 25 | * @Short_description: A permission request |
| 26 | * @Title: WebKitPermissionRequest |
| 27 | * @See_also: #WebKitWebView |
| 28 | * |
| 29 | * There are situations where an embedder would need to ask the user |
| 30 | * for permission to do certain types of operations, such as switching |
| 31 | * to fullscreen mode or reporting the user's location through the |
| 32 | * standard Geolocation API. In those cases, WebKit will emit a |
| 33 | * #WebKitWebView::permission-request signal with a |
| 34 | * #WebKitPermissionRequest object attached to it. |
| 35 | */ |
| 36 | |
| 37 | typedef WebKitPermissionRequestIface WebKitPermissionRequestInterface; |
| 38 | G_DEFINE_INTERFACE(WebKitPermissionRequest, webkit_permission_request, G_TYPE_OBJECT) |
| 39 | |
| 40 | static void webkit_permission_request_default_init(WebKitPermissionRequestIface*) |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * webkit_permission_request_allow: |
| 46 | * @request: a #WebKitPermissionRequest |
| 47 | * |
| 48 | * Allow the action which triggered this request. |
| 49 | */ |
| 50 | void webkit_permission_request_allow(WebKitPermissionRequest* request) |
| 51 | { |
| 52 | g_return_if_fail(WEBKIT_IS_PERMISSION_REQUEST(request)); |
| 53 | |
| 54 | WebKitPermissionRequestIface* iface = WEBKIT_PERMISSION_REQUEST_GET_IFACE(request); |
| 55 | if (iface->allow) |
| 56 | iface->allow(request); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * webkit_permission_request_deny: |
| 61 | * @request: a #WebKitPermissionRequest |
| 62 | * |
| 63 | * Deny the action which triggered this request. |
| 64 | */ |
| 65 | void webkit_permission_request_deny(WebKitPermissionRequest* request) |
| 66 | { |
| 67 | g_return_if_fail(WEBKIT_IS_PERMISSION_REQUEST(request)); |
| 68 | |
| 69 | WebKitPermissionRequestIface* iface = WEBKIT_PERMISSION_REQUEST_GET_IFACE(request); |
| 70 | if (iface->deny) |
| 71 | iface->deny(request); |
| 72 | } |
| 73 | |