[gnome-online-accounts/wip/rishi/pocket-firefox: 3/8] oauth2: Add a new vfunc to influence the navigation policy
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/rishi/pocket-firefox: 3/8] oauth2: Add a new vfunc to influence the navigation policy
- Date: Thu, 21 Jul 2016 16:57:40 +0000 (UTC)
commit d2dda786786f783d0aa5c59e22f455f7b6cb22d3
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Jul 19 18:34:33 2016 +0200
oauth2: Add a new vfunc to influence the navigation policy
https://bugzilla.gnome.org/show_bug.cgi?id=755386
src/goabackend/goaoauth2provider.c | 39 ++++++++++++++++++++++++++++++++++++
src/goabackend/goaoauth2provider.h | 6 ++++-
2 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/src/goabackend/goaoauth2provider.c b/src/goabackend/goaoauth2provider.c
index 7948ec4..067dc9d 100644
--- a/src/goabackend/goaoauth2provider.c
+++ b/src/goabackend/goaoauth2provider.c
@@ -283,6 +283,44 @@ goa_oauth2_provider_build_authorization_uri (GoaOAuth2Provider *provider,
escaped_scope);
}
+/* ---------------------------------------------------------------------------------------------------- */
+
+static gboolean
+goa_oauth2_provider_decide_navigation_policy_default (GoaOAuth2Provider *provider,
+ WebKitNavigationPolicyDecision *decision)
+{
+ return FALSE;
+}
+
+/*
+ * goa_oauth2_provider_decide_navigation_policy_default:
+ * @provider: A #GoaOAuth2Provider.
+ * @decision: A #WebKitNavigationPolicyDecision
+ *
+ * Certain OAuth2-like, but not exactly <ulink
+ * url="http://tools.ietf.org/html/draft-ietf-oauth-v2-15">OAuth2</ulink>,
+ * providers may not send us to the redirect URI, as expected. They
+ * might need some special handling for that. This is a provider
+ * specific hook to accommodate them.
+ *
+ * This is a virtual method where the default implementation returns
+ * %FALSE.
+ *
+ * Returns: %TRUE if @provider decided what to do with @decision,
+ * %FALSE otherwise.
+ */
+gboolean
+goa_oauth2_provider_decide_navigation_policy (GoaOAuth2Provider *provider,
+ WebKitNavigationPolicyDecision *decision)
+{
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), FALSE);
+ g_return_val_if_fail (WEBKIT_IS_NAVIGATION_POLICY_DECISION (decision), FALSE);
+
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->decide_navigation_policy (provider, decision);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
/**
* goa_oauth2_provider_process_redirect_url:
* @provider: A #GoaOAuth2Provider.
@@ -1701,6 +1739,7 @@ goa_oauth2_provider_class_init (GoaOAuth2ProviderClass *klass)
provider_class->ensure_credentials_sync = goa_oauth2_provider_ensure_credentials_sync;
klass->build_authorization_uri = goa_oauth2_provider_build_authorization_uri_default;
+ klass->decide_navigation_policy = goa_oauth2_provider_decide_navigation_policy_default;
klass->get_token_uri = goa_oauth2_provider_get_token_uri_default;
klass->get_scope = goa_oauth2_provider_get_scope_default;
klass->get_use_mobile_browser = goa_oauth2_provider_get_use_mobile_browser_default;
diff --git a/src/goabackend/goaoauth2provider.h b/src/goabackend/goaoauth2provider.h
index a2a66e6..d6fb1b5 100644
--- a/src/goabackend/goaoauth2provider.h
+++ b/src/goabackend/goaoauth2provider.h
@@ -68,6 +68,7 @@ struct _GoaOAuth2Provider
* @build_authorization_uri: Virtual function for goa_oauth2_provider_build_authorization_uri().
* @get_use_mobile_browser: Virtual function for goa_oauth2_provider_get_use_mobile_browser().
* @add_account_key_values: Virtual function for goa_oauth2_provider_add_account_key_values().
+ * @decide_navigation_policy: Virtual function for goa_oauth2_provider_decide_navigation_policy().
* @process_redirect_url: Virtual function for goa_oauth2_provider_process_redirect_url().
* @is_deny_node: Virtual function for goa_oauth2_provider_is_deny_node().
* @is_identity_node: Virtual function for goa_oauth2_provider_is_identity_node().
@@ -112,7 +113,8 @@ struct _GoaOAuth2ProviderClass
WebKitDOMNode *node);
gboolean (*is_password_node) (GoaOAuth2Provider *provider,
WebKitDOMHTMLInputElement *element);
-
+ gboolean (*decide_navigation_policy) (GoaOAuth2Provider *provider,
+ WebKitNavigationPolicyDecision *decision);
gboolean (*process_redirect_url) (GoaOAuth2Provider *provider,
const gchar *redirect_url,
gchar **access_token,
@@ -161,6 +163,8 @@ gboolean goa_oauth2_provider_process_redirect_url (GoaOAuth2Provider
const gchar *redirect_url,
gchar
**authorization_code,
GError **error);
+gboolean goa_oauth2_provider_decide_navigation_policy (GoaOAuth2Provider *provider,
+ WebKitNavigationPolicyDecision *decision);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]