зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1733357 - Expose Nimbus API to all platforms r=necko-reviewers,valentin,k88hudson
Differential Revision: https://phabricator.services.mozilla.com/D127938
This commit is contained in:
Родитель
ec3416d756
Коммит
0de35978e5
|
@ -99,9 +99,7 @@
|
|||
# include "nsCocoaFeatures.h"
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID)
|
||||
#include "mozilla/browser/NimbusFeatures.h"
|
||||
#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "mozilla/net/HttpChannelChild.h"
|
||||
|
@ -129,10 +127,8 @@
|
|||
#define NS_HTTP_PROTOCOL_FLAGS \
|
||||
(URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP | URI_LOADABLE_BY_ANYONE)
|
||||
|
||||
#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID)
|
||||
#define UA_EXPERIMENT_NAME "firefox100"_ns
|
||||
#define UA_EXPERIMENT_VAR "firefoxVersion"_ns
|
||||
#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
@ -142,7 +138,6 @@ namespace mozilla::net {
|
|||
|
||||
LazyLogModule gHttpLog("nsHttp");
|
||||
|
||||
#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID)
|
||||
static void ExperimentUserAgentUpdated(const char* /* aNimbusPref */,
|
||||
void* aUserData) {
|
||||
MOZ_ASSERT(aUserData != nullptr);
|
||||
|
@ -176,7 +171,6 @@ static void ExperimentUserAgentUpdated(const char* /* aNimbusPref */,
|
|||
aExperimentUserAgent->Truncate();
|
||||
aExperimentUserAgent->AppendPrintf(uaFormat, firefoxVersion, firefoxVersion);
|
||||
}
|
||||
#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID
|
||||
|
||||
#ifdef ANDROID
|
||||
static nsCString GetDeviceModelId() {
|
||||
|
@ -279,9 +273,7 @@ nsHttpHandler::nsHttpHandler()
|
|||
|
||||
mUserAgentOverride.SetIsVoid(true);
|
||||
|
||||
#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID)
|
||||
mExperimentUserAgent.SetIsVoid(true);
|
||||
#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID
|
||||
|
||||
MOZ_ASSERT(!gHttpHandler, "HTTP handler already created!");
|
||||
|
||||
|
@ -389,14 +381,12 @@ nsresult nsHttpHandler::Init() {
|
|||
gCallbackPrefs, this);
|
||||
PrefsChanged(nullptr);
|
||||
|
||||
#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID)
|
||||
// monitor Firefox Version Experiment enrollment
|
||||
NimbusFeatures::OnUpdate(UA_EXPERIMENT_NAME, UA_EXPERIMENT_VAR,
|
||||
ExperimentUserAgentUpdated, &mExperimentUserAgent);
|
||||
|
||||
// Load the experiment state once for startup
|
||||
ExperimentUserAgentUpdated("", &mExperimentUserAgent);
|
||||
#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID
|
||||
|
||||
Telemetry::ScalarSet(Telemetry::ScalarID::NETWORKING_HTTP3_ENABLED,
|
||||
mHttp3Enabled);
|
||||
|
@ -759,13 +749,11 @@ const nsCString& nsHttpHandler::UserAgent() {
|
|||
return mUserAgentOverride;
|
||||
}
|
||||
|
||||
#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID)
|
||||
if (!mExperimentUserAgent.IsVoid()) {
|
||||
LOG(("using Firefox 100 Experiment User-Agent : %s\n",
|
||||
mExperimentUserAgent.get()));
|
||||
return mExperimentUserAgent;
|
||||
}
|
||||
#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID
|
||||
|
||||
if (mUserAgentIsDirty) {
|
||||
BuildUserAgent();
|
||||
|
|
|
@ -648,9 +648,7 @@ class nsHttpHandler final : public nsIHttpProtocolHandler,
|
|||
nsCString mSpoofedUserAgent;
|
||||
nsCString mUserAgentOverride;
|
||||
|
||||
#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID)
|
||||
nsCString mExperimentUserAgent;
|
||||
#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID
|
||||
|
||||
bool mUserAgentIsDirty{true}; // true if mUserAgent should be rebuilt
|
||||
bool mAcceptLanguagesIsDirty{true};
|
||||
|
|
|
@ -129,7 +129,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android":
|
|||
if CONFIG["MOZ_BUILD_APP"] == "browser":
|
||||
DIRS += ["normandy", "messaging-system"]
|
||||
|
||||
if CONFIG["MOZ_BUILD_APP"] in ["browser", "comm/mail"]:
|
||||
DIRS += ["nimbus"]
|
||||
|
||||
if CONFIG["MOZ_BACKGROUNDTASKS"]:
|
||||
|
|
|
@ -291,12 +291,15 @@ const ExperimentAPI = {
|
|||
*/
|
||||
const NimbusFeatures = {};
|
||||
for (let feature in FeatureManifest) {
|
||||
XPCOMUtils.defineLazyGetter(
|
||||
NimbusFeatures,
|
||||
feature,
|
||||
() => new _ExperimentFeature(feature)
|
||||
XPCOMUtils.defineLazyGetter(NimbusFeatures, feature, () => {
|
||||
if (AppConstants.MOZ_BUILD_APP !== "browser") {
|
||||
throw new Error(
|
||||
`NimbusFeatures.${feature} APIs are only available for browser builds.`
|
||||
);
|
||||
}
|
||||
return new _ExperimentFeature(feature);
|
||||
});
|
||||
}
|
||||
|
||||
class _ExperimentFeature {
|
||||
constructor(featureId, manifest) {
|
||||
|
|
|
@ -4,6 +4,9 @@ support-files =
|
|||
prefs =
|
||||
# This turns off the update interval for fetching recipes from Remote Settings
|
||||
app.normandy.run_interval_seconds=0
|
||||
skip-if =
|
||||
toolkit == "android"
|
||||
appname == "thunderbird"
|
||||
|
||||
[browser_experiment_single_feature_enrollment.js]
|
||||
[browser_remotesettingsexperimentloader_remote_defaults.js]
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
[DEFAULT]
|
||||
head = head.js
|
||||
tags = messaging-system
|
||||
tags = nimbus
|
||||
firefox-appdir = browser
|
||||
support-files =
|
||||
reference_aboutwelcome_experiment_content.json
|
||||
skip-if =
|
||||
toolkit == "android"
|
||||
appname == "thunderbird"
|
||||
|
||||
[test_ExperimentManager_context.js]
|
||||
[test_ExperimentManager_enroll.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче