Bug 1384509 - Move Bing, Google, Mozilla API key definitions to AppConstants.jsm and stop using preprocessor in nsURLFormatter.js. r=mossop

This commit is contained in:
Marco Castelluccio
2017-07-27 02:20:37 +02:00
parent 59cb8e2717
commit afb6fcf901
5 changed files with 16 additions and 20 deletions

View File

@@ -1,4 +0,0 @@
#define MOZ_MOZILLA_API_KEY @MOZ_MOZILLA_API_KEY@
#define MOZ_GOOGLE_API_KEY @MOZ_GOOGLE_API_KEY@
#define MOZ_BING_API_KEY @MOZ_BING_API_KEY@
#define MOZ_BING_API_CLIENTID @MOZ_BING_API_CLIENTID@

View File

@@ -16,15 +16,8 @@ XPIDL_SOURCES += [
XPIDL_MODULE = 'urlformatter'
EXTRA_COMPONENTS += [
'nsURLFormatter.js',
'nsURLFormatter.manifest',
]
EXTRA_PP_COMPONENTS += [
'nsURLFormatter.js',
]
CONFIGURE_SUBST_FILES += [
'api_keys',
]
DEFINES['OBJDIR'] = OBJDIR

View File

@@ -1,6 +1,3 @@
#filter substitution
#include @OBJDIR@/api_keys
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
@@ -22,6 +19,7 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
const PREF_APP_DISTRIBUTION = "distribution.id";
const PREF_APP_DISTRIBUTION_VERSION = "distribution.version";
@@ -112,10 +110,10 @@ nsURLFormatterService.prototype = {
BUILD_TARGET: function() { return this.appInfo.OS + "_" + this.ABI; },
OS_VERSION: function() { return this.OSVersion; },
CHANNEL: () => UpdateUtils.UpdateChannel,
MOZILLA_API_KEY: () => "@MOZ_MOZILLA_API_KEY@",
GOOGLE_API_KEY: () => "@MOZ_GOOGLE_API_KEY@",
BING_API_CLIENTID:() => "@MOZ_BING_API_CLIENTID@",
BING_API_KEY: () => "@MOZ_BING_API_KEY@",
MOZILLA_API_KEY: () => AppConstants.MOZ_MOZILLA_API_KEY,
GOOGLE_API_KEY: () => AppConstants.MOZ_GOOGLE_API_KEY,
BING_API_CLIENTID:() => AppConstants.MOZ_BING_API_CLIENTID,
BING_API_KEY: () => AppConstants.MOZ_BING_API_KEY,
DISTRIBUTION: function() { return this.distribution.id; },
DISTRIBUTION_VERSION: function() { return this.distribution.version; }
},
@@ -157,7 +155,7 @@ nsURLFormatterService.prototype = {
trimSensitiveURLs: function uf_trimSensitiveURLs(aMsg) {
// Only the google API key is sensitive for now.
return "@MOZ_GOOGLE_API_KEY@" ? aMsg.replace(/@MOZ_GOOGLE_API_KEY@/g,
return AppConstants.MOZ_GOOGLE_API_KEY ? aMsg.replace(RegExp(AppConstants.MOZ_GOOGLE_API_KEY, 'g'),
"[trimmed-google-api-key]")
: aMsg;
}

View File

@@ -331,6 +331,11 @@ this.AppConstants = Object.freeze({
DEBUG_JS_MODULES: "@DEBUG_JS_MODULES@",
MOZ_BING_API_CLIENTID: "@MOZ_BING_API_CLIENTID@",
MOZ_BING_API_KEY: "@MOZ_BING_API_KEY@",
MOZ_GOOGLE_API_KEY: "@MOZ_GOOGLE_API_KEY@",
MOZ_MOZILLA_API_KEY: "@MOZ_MOZILLA_API_KEY@",
// URL to the hg revision this was built from (e.g.
// "https://hg.mozilla.org/mozilla-central/rev/6256ec9113c1")
// On unofficial builds, this is an empty string.

View File

@@ -297,7 +297,11 @@ for var in ('ANDROID_PACKAGE_NAME',
'MOZ_APP_NAME',
'MOZ_APP_VERSION',
'MOZ_APP_VERSION_DISPLAY',
'MOZ_BING_API_CLIENTID',
'MOZ_BING_API_KEY',
'MOZ_GOOGLE_API_KEY',
'MOZ_MACBUNDLE_NAME',
'MOZ_MOZILLA_API_KEY',
'MOZ_WIDGET_TOOLKIT',
'DLL_PREFIX',
'DLL_SUFFIX',