forked from mirrors/gecko-dev
This patch ultimately overrides the user-agent which Fennec users send to Google Search pages, choosing a phone- or tablet-specific UA as appropriate. It involves adding four new metadata keys to the webcompat addon's metadata for user-agent overrides: blocks, permanentPref, experiment, telemetryKey: - "blocks" specifies URLs for which any requests should be aborted. This allows us to block the Google service worker for now, as it has caused "content corrupted" issues in the past with other enhanced search addons (see https://github.com/wisniewskit/google-search-fixer/issues/1). - "permanentPref" specifies an about:config preference, which dictates whether the injection is used. Users may set this to `false` to disable the injection outright, and permanently; `true` or `undefined` values allow the injection to function normally. - "experiment" specifies the name of the experiment this feature is optionally gated behind. Only a Fennec-specific implementation is provided in this patch. The implementation simply queries Switchboard to determine if the experiment is active. - "telemetryKey" specifies which telemetry key should be flipped to "true" when this injection runs. We will use this to note whether enhanced search has actually been enabled for this profile. Only a Fennec-specific implementation is given in this patch, which actually just sets a Fennec Shared Preference, which Fennec's core telemetry ping later reads in Java to know what the ping should contain. Differential Revision: https://phabricator.services.mozilla.com/D41074 --HG-- extra : moz-landing-system : lando
34 lines
999 B
JavaScript
34 lines
999 B
JavaScript
/* 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/. */
|
|
|
|
"use strict";
|
|
|
|
/* global ExtensionAPI, Services, XPCOMUtils */
|
|
|
|
XPCOMUtils.defineLazyModuleGetters(this, {
|
|
EventDispatcher: "resource://gre/modules/Messaging.jsm",
|
|
Services: "resource://gre/modules/Services.jsm",
|
|
});
|
|
|
|
this.experiments = class extends ExtensionAPI {
|
|
getAPI(context) {
|
|
function promiseActiveExperiments() {
|
|
return EventDispatcher.instance.sendRequestForResult({
|
|
type: "Experiments:GetActive",
|
|
});
|
|
}
|
|
return {
|
|
experiments: {
|
|
async isActive(name) {
|
|
if (!Services.androidBridge || !Services.androidBridge.isFennec) {
|
|
return undefined;
|
|
}
|
|
return promiseActiveExperiments().then(experiments => {
|
|
return experiments.includes(name);
|
|
});
|
|
},
|
|
},
|
|
};
|
|
}
|
|
};
|