[Gtk] Webkit fails to build with --disable-geolocation
[WebKit-https.git] / Source / WebKit / gtk / webkit / webkitgeolocationpolicydecision.cpp
1 /*
2  * Copyright (C) 2010 Arno Renevier
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 "webkitgeolocationpolicydecision.h"
22
23 #include "Geolocation.h"
24 #include "webkitgeolocationpolicydecisionprivate.h"
25 #include "webkitglobalsprivate.h"
26
27 /**
28  * SECTION:webkitgeolocationpolicydecision
29  * @short_description: Liaison between WebKit and the application regarding asynchronous geolocation policy decisions
30  *
31  * #WebKitGeolocationPolicyDecision objects are given to the application when
32  * geolocation-policy-decision-requested signal is emitted. The application
33  * uses it to tell the engine whether it wants to allow or deny geolocation for
34  * a given frame.
35  */
36
37 G_DEFINE_TYPE(WebKitGeolocationPolicyDecision, webkit_geolocation_policy_decision, G_TYPE_OBJECT);
38
39 struct _WebKitGeolocationPolicyDecisionPrivate {
40     WebKitWebFrame* frame;
41 #if ENABLE(GEOLOCATION)
42     WebCore::Geolocation* geolocation;
43 #endif
44 };
45
46 static void webkit_geolocation_policy_decision_class_init(WebKitGeolocationPolicyDecisionClass* decisionClass)
47 {
48     g_type_class_add_private(decisionClass, sizeof(WebKitGeolocationPolicyDecisionPrivate));
49 }
50
51 static void webkit_geolocation_policy_decision_init(WebKitGeolocationPolicyDecision* decision)
52 {
53     decision->priv = G_TYPE_INSTANCE_GET_PRIVATE(decision, WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION, WebKitGeolocationPolicyDecisionPrivate);
54 }
55
56 #if ENABLE(GEOLOCATION)
57 WebKitGeolocationPolicyDecision* webkit_geolocation_policy_decision_new(WebKitWebFrame* frame, WebCore::Geolocation* geolocation)
58 {
59     g_return_val_if_fail(frame, NULL);
60     WebKitGeolocationPolicyDecision* decision = WEBKIT_GEOLOCATION_POLICY_DECISION(g_object_new(WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION, NULL));
61     WebKitGeolocationPolicyDecisionPrivate* priv = decision->priv;
62
63     priv->frame = frame;
64     priv->geolocation = geolocation;
65     return decision;
66 }
67 #endif
68
69 /**
70  * webkit_geolocation_policy_allow
71  * @decision: a #WebKitGeolocationPolicyDecision
72  *
73  * Will send the allow decision to the policy implementer.
74  *
75  * Since: 1.1.23
76  */
77 void webkit_geolocation_policy_allow(WebKitGeolocationPolicyDecision* decision)
78 {
79 #if ENABLE(GEOLOCATION)
80     g_return_if_fail(WEBKIT_IS_GEOLOCATION_POLICY_DECISION(decision));
81
82     WebKitGeolocationPolicyDecisionPrivate* priv = decision->priv;
83     priv->geolocation->setIsAllowed(TRUE);
84 #else
85     WEBKIT_WARN_FEATURE_NOT_PRESENT("Geolocation")
86 #endif
87 }
88
89 /**
90  * webkit_geolocation_policy_deny
91  * @decision: a #WebKitGeolocationPolicyDecision
92  *
93  * Will send the deny decision to the policy implementer.
94  *
95  * Since: 1.1.23
96  */
97 void webkit_geolocation_policy_deny(WebKitGeolocationPolicyDecision* decision)
98 {
99 #if ENABLE(GEOLOCATION)
100     g_return_if_fail(WEBKIT_IS_GEOLOCATION_POLICY_DECISION(decision));
101
102     WebKitGeolocationPolicyDecisionPrivate* priv = decision->priv;
103     priv->geolocation->setIsAllowed(FALSE);
104 #else
105     WEBKIT_WARN_FEATURE_NOT_PRESENT("Geolocation")
106 #endif
107 }
108