From 2f35edcb94f205cdfac5ee1b6903d111b216085d Mon Sep 17 00:00:00 2001 From: Felipe Gomes Date: Fri, 23 May 2014 13:21:06 -0300 Subject: [PATCH] Bug 1014367 - Add support for translation API key. r=ted --- configure.in | 13 +++++++++++++ toolkit/components/urlformatter/Makefile.in | 10 +++++++--- toolkit/components/urlformatter/nsURLFormatter.js | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 5cc5dfa93ba..e8ec9830a16 100644 --- a/configure.in +++ b/configure.in @@ -4052,6 +4052,19 @@ if test -z "$MOZ_GOOGLE_API_KEY"; then fi AC_SUBST(MOZ_GOOGLE_API_KEY) +# Allow specifying a Bing API key file that contains the client ID and the +# secret key to be used for the Bing Translation API requests. +MOZ_ARG_WITH_STRING(bing-api-keyfile, +[ --with-bing-api-keyfile=file Use the client id and secret key contained in the given keyfile for Bing API requests], + [MOZ_BING_API_CLIENTID=`cat $withval | cut -f 1 -d " "` + MOZ_BING_API_KEY=`cat $withval | cut -f 2 -d " "`]) +if test -z "$MOZ_BING_API_CLIENTID"; then + MOZ_BING_API_CLIENTID=no-bing-api-clientid + MOZ_BING_API_KEY=no-bing-api-key +fi +AC_SUBST(MOZ_BING_API_CLIENTID) +AC_SUBST(MOZ_BING_API_KEY) + # Allow the application to influence configure with a confvars.sh script. AC_MSG_CHECKING([if app-specific confvars.sh exists]) if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then diff --git a/toolkit/components/urlformatter/Makefile.in b/toolkit/components/urlformatter/Makefile.in index 771a8dd5b0a..eb0aec89899 100644 --- a/toolkit/components/urlformatter/Makefile.in +++ b/toolkit/components/urlformatter/Makefile.in @@ -3,9 +3,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -export:: mozilla_api_key google_api_key +export:: mozilla_api_key google_api_key bing_api_key -EXTRA_PP_COMPONENTS_FLAGS = -I mozilla_api_key -I google_api_key +EXTRA_PP_COMPONENTS_FLAGS = -I mozilla_api_key -I google_api_key -I bing_api_key include $(topsrcdir)/config/rules.mk @@ -15,4 +15,8 @@ mozilla_api_key: google_api_key: @echo '#define MOZ_GOOGLE_API_KEY $(MOZ_GOOGLE_API_KEY)' > $@ -GARBAGE += google_api_key moz_google_api_key +bing_api_key: + @echo '#define MOZ_BING_API_KEY $(MOZ_BING_API_KEY)' > $@ + @echo '#define MOZ_BING_API_CLIENTID $(MOZ_BING_API_CLIENTID)' >> $@ + +GARBAGE += mozilla_api_key google_api_key bing_api_key diff --git a/toolkit/components/urlformatter/nsURLFormatter.js b/toolkit/components/urlformatter/nsURLFormatter.js index 06ad5216505..ca4d5b088e5 100644 --- a/toolkit/components/urlformatter/nsURLFormatter.js +++ b/toolkit/components/urlformatter/nsURLFormatter.js @@ -105,6 +105,8 @@ nsURLFormatterService.prototype = { CHANNEL: function() UpdateChannel.get(), MOZILLA_API_KEY: function() "@MOZ_MOZILLA_API_KEY@", GOOGLE_API_KEY: function() "@MOZ_GOOGLE_API_KEY@", + BING_API_CLIENTID:function() "@MOZ_BING_API_CLIENTID@", + BING_API_KEY: function() "@MOZ_BING_API_KEY@", DISTRIBUTION: function() this.distribution.id, DISTRIBUTION_VERSION: function() this.distribution.version },