Bug 1014367 - Add support for translation API key. r=ted

This commit is contained in:
Felipe Gomes 2014-05-23 13:21:06 -03:00
parent 14bc4f010a
commit 2f35edcb94
3 changed files with 22 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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
},