1/*
2 * Copyright (C) 2012 Intel Corporation. All rights reserved.
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_navigation_policy_decision.h
28 * @brief   Describes the Ewk navigation policy decision API.
29 */
30
31#ifndef ewk_navigation_policy_decision_h
32#define ewk_navigation_policy_decision_h
33
34#include "ewk_url_request.h"
35#include <Eina.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/**
42 * Declare Ewk_Navigation_Policy_Decision as Ewk_Object.
43 *
44 * @see Ewk_Object
45 */
46typedef struct EwkObject Ewk_Navigation_Policy_Decision;
47
48/// Enum containing navigation types
49typedef enum  {
50    EWK_NAVIGATION_TYPE_LINK_ACTIVATED,
51    EWK_NAVIGATION_TYPE_FORM_SUBMITTED,
52    EWK_NAVIGATION_TYPE_BACK_FORWARD,
53    EWK_NAVIGATION_TYPE_RELOAD,
54    EWK_NAVIGATION_TYPE_FORM_RESUBMITTED,
55    EWK_NAVIGATION_TYPE_OTHER
56} Ewk_Navigation_Type;
57
58/// Enum containing button types
59typedef enum {
60    EVENT_MOUSE_BUTTON_NONE = -1,
61    EVENT_MOUSE_BUTTON_LEFT = 0,
62    EVENT_MOUSE_BUTTON_MIDDLE = 1,
63    EVENT_MOUSE_BUTTON_RIGHT = 2
64} Event_Mouse_Button;
65
66typedef enum {
67    EVENT_MODIFIER_KEY_SHIFT = 1 << 0,
68    EVENT_MODIFIER_KEY_CTRL = 1 << 1,
69    EVENT_MODIFIER_KEY_ALT = 1 << 2,
70    EVENT_MODIFIER_KEY_META = 1 << 3
71} Event_Modifier_Keys;
72
73/**
74 * Query type for this navigation policy decision.
75 *
76 * @param decision navigation policy decision object to query.
77 *
78 * @return the type of navigation.
79 */
80EAPI Ewk_Navigation_Type ewk_navigation_policy_navigation_type_get(const Ewk_Navigation_Policy_Decision *decision);
81
82/**
83 * Query mouse button for this navigation policy decision.
84 *
85 * @param decision navigation policy decision object to query.
86 *
87 * @return the mouse button clicked to trigger the navigation.
88 */
89EAPI Event_Mouse_Button ewk_navigation_policy_mouse_button_get(const Ewk_Navigation_Policy_Decision *decision);
90
91/**
92 * Query modifier keys for this navigation policy decision.
93 *
94 * @param decision navigation policy decision object to query.
95 *
96 * @return the modifier keys used when triggering the navigation.
97 */
98EAPI Event_Modifier_Keys ewk_navigation_policy_modifiers_get(const Ewk_Navigation_Policy_Decision *decision);
99
100/**
101 * Query frame name for this navigation policy decision.
102 *
103 * The frame name is non-null for new window policy decisions only.
104 *
105 * @param decision navigation policy decision object to query.
106 *
107 * @return the frame name pointer, that may be @c NULL. This pointer is
108 *         guaranteed to be eina_stringshare, so whenever possible
109 *         save yourself some cpu cycles and use
110 *         eina_stringshare_ref() instead of eina_stringshare_add() or
111 *         strdup().
112 */
113EAPI const char *ewk_navigation_policy_frame_name_get(const Ewk_Navigation_Policy_Decision *decision);
114
115/**
116 * Query URL request for this navigation policy decision.
117 *
118 * @param decision navigation policy decision object to query.
119 *
120 * @return The URL request pointer or @c NULL in case of error.
121 */
122EAPI Ewk_Url_Request *ewk_navigation_policy_request_get(const Ewk_Navigation_Policy_Decision *decision);
123
124/**
125 * Accepts the navigation request.
126 *
127 * The navigation will be accepted by default.
128 *
129 * @param decision navigation policy decision object to query.
130 */
131EAPI void ewk_navigation_policy_decision_accept(Ewk_Navigation_Policy_Decision *decision);
132
133/**
134 * Rejects the navigation request.
135 *
136 * @param decision navigation policy decision object to query.
137 */
138EAPI void ewk_navigation_policy_decision_reject(Ewk_Navigation_Policy_Decision *decision);
139
140/**
141 * Triggers a download instead of navigating to the url.
142 *
143 * @param decision navigation policy decision object to query.
144 */
145EAPI void ewk_navigation_policy_decision_download(Ewk_Navigation_Policy_Decision *decision);
146
147#ifdef __cplusplus
148}
149#endif
150
151#endif // ewk_navigation_policy_decision_h
152