[GTK] Make libsecret optional
authormrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Apr 2013 21:24:14 +0000 (21:24 +0000)
committermrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Apr 2013 21:24:14 +0000 (21:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=113821

Reviewed by Gustavo Noronha Silva.

.:

Add a configuration option to disable credential storage and thus remove
the libsecret dependency. This should make it possible to build WebKit 2.x
on Windows again.

* Source/autotools/FindDependencies.m4: Only look for libsecret if credential storage is active.
* Source/autotools/PrintBuildConfiguration.m4: Print whether or not credential storage is active.
* Source/autotools/ReadCommandLineArguments.m4: Added an option to control credential storage.
* Source/autotools/SetupAutoconfHeader.m4: Expose credential storage setting to code.

Source/WebCore:

Don't try to use libsecret if credential storage is disabled.

* platform/gtk/GRefPtrGtk.cpp: Protect libsecret sections.
* platform/gtk/GRefPtrGtk.h: Ditto.
* platform/network/gtk/CredentialBackingStore.cpp: Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@147499 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/platform/gtk/GRefPtrGtk.cpp
Source/WebCore/platform/gtk/GRefPtrGtk.h
Source/WebCore/platform/network/gtk/CredentialBackingStore.cpp
Source/autotools/FindDependencies.m4
Source/autotools/PrintBuildConfiguration.m4
Source/autotools/ReadCommandLineArguments.m4
Source/autotools/SetupAutoconfHeader.m4

index f46c645..30aa790 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2013-04-02  Martin Robinson  <mrobinson@igalia.com>
+
+        [GTK] Make libsecret optional
+        https://bugs.webkit.org/show_bug.cgi?id=113821
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Add a configuration option to disable credential storage and thus remove
+        the libsecret dependency. This should make it possible to build WebKit 2.x
+        on Windows again.
+
+        * Source/autotools/FindDependencies.m4: Only look for libsecret if credential storage is active.
+        * Source/autotools/PrintBuildConfiguration.m4: Print whether or not credential storage is active.
+        * Source/autotools/ReadCommandLineArguments.m4: Added an option to control credential storage.
+        * Source/autotools/SetupAutoconfHeader.m4: Expose credential storage setting to code.
+
 2013-04-02  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r147401.
index 4d7a187..c9a57ca 100644 (file)
@@ -1,3 +1,16 @@
+2013-04-02  Martin Robinson  <mrobinson@igalia.com>
+
+        [GTK] Make libsecret optional
+        https://bugs.webkit.org/show_bug.cgi?id=113821
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Don't try to use libsecret if credential storage is disabled.
+
+        * platform/gtk/GRefPtrGtk.cpp: Protect libsecret sections.
+        * platform/gtk/GRefPtrGtk.h: Ditto.
+        * platform/network/gtk/CredentialBackingStore.cpp: Ditto.
+
 2013-04-02  Bem Jones-Bey  <bjonesbe@adobe.com>
 
         [CSS Exclusions] refactor shape-outside code to use isFloatingWithShapeOutside() helper method
index fa506df..3c28eb7 100644 (file)
 #include "config.h"
 #include "GRefPtrGtk.h"
 
-#define SECRET_WITH_UNSTABLE 1
-#define SECRET_API_SUBJECT_TO_CHANGE 1
-
 #include <glib.h>
 #include <gtk/gtk.h>
+
+#if ENABLE(CREDENTIAL_STORAGE)
+#define SECRET_WITH_UNSTABLE 1
+#define SECRET_API_SUBJECT_TO_CHANGE 1
 #include <libsecret/secret.h>
+#endif
 
 namespace WTF {
 
@@ -42,6 +44,7 @@ template <> void derefGPtr(GtkTargetList* ptr)
         gtk_target_list_unref(ptr);
 }
 
+#if ENABLE(CREDENTIAL_STORAGE)
 template <> SecretValue* refGPtr(SecretValue* ptr)
 {
     if (ptr)
@@ -54,6 +57,7 @@ template <> void derefGPtr(SecretValue* ptr)
     if (ptr)
         secret_value_unref(ptr);
 }
+#endif
 
 #ifdef GTK_API_VERSION_2
 template <> GdkCursor* refGPtr(GdkCursor* ptr)
index 9192864..cdc7b7e 100644 (file)
@@ -30,8 +30,10 @@ namespace WTF {
 template <> GtkTargetList* refGPtr(GtkTargetList* ptr);
 template <> void derefGPtr(GtkTargetList* ptr);
 
+#if ENABLE(CREDENTIAL_STORAGE)
 template <> SecretValue* refGPtr(SecretValue* ptr);
 template <> void derefGPtr(SecretValue* ptr);
+#endif
 
 #ifdef GTK_API_VERSION_2
 template <> GdkCursor* refGPtr(GdkCursor* ptr);
index 3423fa5..5f1e4c5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Igalia S.L.
+ * Copyright (C) 2012, 2013 Igalia S.L.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "CredentialBackingStore.h"
 
+#if ENABLE(CREDENTIAL_STORAGE)
 #define SECRET_WITH_UNSTABLE 1
 #define SECRET_API_SUBJECT_TO_CHANGE 1
 #include "AuthenticationChallenge.h"
@@ -35,6 +36,7 @@
 #include <libsoup/soup.h>
 #include <wtf/gobject/GOwnPtr.h>
 #include <wtf/text/CString.h>
+#endif
 
 namespace WebCore {
 
@@ -44,6 +46,7 @@ CredentialBackingStore& credentialBackingStore()
     return backingStore;
 }
 
+#if ENABLE(CREDENTIAL_STORAGE)
 static GRefPtr<GHashTable> createAttributeHashTableFromChallenge(const AuthenticationChallenge& challenge, const Credential& credential = Credential())
 {
     SoupURI* uri = soup_message_get_uri(challenge.soupMessage());
@@ -95,9 +98,11 @@ static void credentialForChallengeAsyncReadyCallback(SecretService* service, GAs
 
     callback(Credential(user, password, CredentialPersistencePermanent), data);
 }
+#endif // ENABLE(CREDENTIAL_STORAGE)
 
 void CredentialBackingStore::credentialForChallenge(const AuthenticationChallenge& challenge, CredentialForChallengeCallback callback, void* data)
 {
+#if ENABLE(CREDENTIAL_STORAGE)
     // The default flag only returns the most recent item, not all of them.
     SecretSearchFlags searchFlags = static_cast<SecretSearchFlags>(SECRET_SEARCH_UNLOCK | SECRET_SEARCH_LOAD_SECRETS);
     CredentialForChallengeAsyncReadyCallbackData* callbackData = new CredentialForChallengeAsyncReadyCallbackData;
@@ -112,10 +117,14 @@ void CredentialBackingStore::credentialForChallenge(const AuthenticationChalleng
         0, // cancellable
         reinterpret_cast<GAsyncReadyCallback>(credentialForChallengeAsyncReadyCallback),
         callbackData);
+#else
+    callback(Credential(), data);
+#endif // ENABLE(CREDENTIAL_STORAGE)
 }
 
 void CredentialBackingStore::storeCredentialsForChallenge(const AuthenticationChallenge& challenge, const Credential& credential)
 {
+#if ENABLE(CREDENTIAL_STORAGE)
     CString utf8Password = credential.password().utf8();
     GRefPtr<SecretValue> newSecretValue = adoptGRef(secret_value_new(utf8Password.data(), utf8Password.length(), "text/plain"));
 
@@ -129,6 +138,7 @@ void CredentialBackingStore::storeCredentialsForChallenge(const AuthenticationCh
         0, // cancellable
         0, // callback
         0); // data
+#endif // ENABLE(CREDENTIAL_STORAGE)
 }
 
 } // namespace WebCore
index 5536714..847ab35 100644 (file)
@@ -359,9 +359,11 @@ PKG_CHECK_MODULES([LIBSOUP], [libsoup-2.4 >= libsoup_required_version])
 AC_SUBST([LIBSOUP_CFLAGS])
 AC_SUBST([LIBSOUP_LIBS])
 
-PKG_CHECK_MODULES([LIBSECRET], [libsecret-1])
-AC_SUBST([LIBSECRET_CFLAGS])
-AC_SUBST([LIBSECRET_LIBS])
+if test "$enable_credential_storage" = "yes"; then
+    PKG_CHECK_MODULES([LIBSECRET], [libsecret-1])
+    AC_SUBST([LIBSECRET_CFLAGS])
+    AC_SUBST([LIBSECRET_LIBS])
+fi
 
 # Check if FreeType/FontConfig are available.
 if test "$with_target" = "directfb"; then
index 64d95ee..be9c520 100644 (file)
@@ -24,6 +24,7 @@ Features:
  SVG fonts support                                        : $enable_svg_fonts
  SVG support                                              : $enable_svg
  Spellcheck support                                       : $enable_spellcheck
+ Credential storage support                               : $enable_credential_storage
  Web Audio support                                        : $enable_web_audio
  WebGL                                                    : $enable_webgl
 
index 60e2b4c..ce40895 100644 (file)
@@ -64,6 +64,13 @@ AC_ARG_ENABLE([spellcheck],
     [enable_spellcheck="yes"])
 AC_MSG_RESULT([$enable_spellcheck])
 
+AC_MSG_CHECKING([whether to enable credential storage])
+AC_ARG_ENABLE([credential_storage],
+    [AS_HELP_STRING([--enable-credential-storage],[enable support for credential storage using libsecret [default=yes]])],
+    [],
+    [enable_credential_storage="yes"])
+AC_MSG_RESULT([$enable_credential_storage])
+
 AC_ARG_ENABLE(glx, 
     AC_HELP_STRING([--enable-glx], [enable support for GLX [default=auto]]),
     [],
index 8101d3c..fad82f6 100644 (file)
@@ -115,4 +115,7 @@ if test "$enable_spellcheck" = "yes"; then
     AC_DEFINE([ENABLE_SPELLCHECK], [1], [ ])
 fi
 
+if test "$enable_credential_storage" = "yes"; then
+    AC_DEFINE([WTF_ENABLE_CREDENTIAL_STORAGE], [1], [ ])
+fi