• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
26 using namespace WebCore;
27 
28 /**
29  * SECTION:webkitgeolocationpolicydecision
30  * @short_description: Liaison between WebKit and the application regarding asynchronous geolocation policy decisions
31  *
32  * #WebKitGeolocationPolicyDecision objects are given to the application when
33  * geolocation-policy-decision-requested signal is emitted. The application
34  * uses it to tell the engine whether it wants to allow or deny geolocation for
35  * a given frame.
36  */
37 
38 G_DEFINE_TYPE(WebKitGeolocationPolicyDecision, webkit_geolocation_policy_decision, G_TYPE_OBJECT);
39 
40 struct _WebKitGeolocationPolicyDecisionPrivate {
41     WebKitWebFrame* frame;
42     Geolocation* geolocation;
43 };
44 
webkit_geolocation_policy_decision_class_init(WebKitGeolocationPolicyDecisionClass * decisionClass)45 static void webkit_geolocation_policy_decision_class_init(WebKitGeolocationPolicyDecisionClass* decisionClass)
46 {
47     g_type_class_add_private(decisionClass, sizeof(WebKitGeolocationPolicyDecisionPrivate));
48 }
49 
webkit_geolocation_policy_decision_init(WebKitGeolocationPolicyDecision * decision)50 static void webkit_geolocation_policy_decision_init(WebKitGeolocationPolicyDecision* decision)
51 {
52     decision->priv = G_TYPE_INSTANCE_GET_PRIVATE(decision, WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION, WebKitGeolocationPolicyDecisionPrivate);
53 }
54 
webkit_geolocation_policy_decision_new(WebKitWebFrame * frame,Geolocation * geolocation)55 WebKitGeolocationPolicyDecision* webkit_geolocation_policy_decision_new(WebKitWebFrame* frame, Geolocation* geolocation)
56 {
57     g_return_val_if_fail(frame, NULL);
58     WebKitGeolocationPolicyDecision* decision = WEBKIT_GEOLOCATION_POLICY_DECISION(g_object_new(WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION, NULL));
59     WebKitGeolocationPolicyDecisionPrivate* priv = decision->priv;
60 
61     priv->frame = frame;
62     priv->geolocation = geolocation;
63     return decision;
64 }
65 
66 /**
67  * webkit_geolocation_policy_allow
68  * @decision: a #WebKitGeolocationPolicyDecision
69  *
70  * Will send the allow decision to the policy implementer.
71  *
72  * Since: 1.1.23
73  */
webkit_geolocation_policy_allow(WebKitGeolocationPolicyDecision * decision)74 void webkit_geolocation_policy_allow(WebKitGeolocationPolicyDecision* decision)
75 {
76     g_return_if_fail(WEBKIT_IS_GEOLOCATION_POLICY_DECISION(decision));
77 
78     WebKitGeolocationPolicyDecisionPrivate* priv = decision->priv;
79     priv->geolocation->setIsAllowed(TRUE);
80 }
81 
82 /**
83  * webkit_geolocation_policy_deny
84  * @decision: a #WebKitGeolocationPolicyDecision
85  *
86  * Will send the deny decision to the policy implementer.
87  *
88  * Since: 1.1.23
89  */
webkit_geolocation_policy_deny(WebKitGeolocationPolicyDecision * decision)90 void webkit_geolocation_policy_deny(WebKitGeolocationPolicyDecision* decision)
91 {
92     g_return_if_fail(WEBKIT_IS_GEOLOCATION_POLICY_DECISION(decision));
93 
94     WebKitGeolocationPolicyDecisionPrivate* priv = decision->priv;
95     priv->geolocation->setIsAllowed(FALSE);
96 }
97 
98