зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1649532 - Port DecoderDoctor notifications to fission. r=Gijs
Port handling of DecoderDoctor notifications for fission. This is done by moving the observing of 'decoder-doctor-notification' from browser-media.js to fission friendly actors. As browser-media.js had only code related to this patch left it is removed along with references to it. Same with ContentObservers.js. Differential Revision: https://phabricator.services.mozilla.com/D88322
This commit is contained in:
Родитель
72bf374f5c
Коммит
a90a447c1c
|
@ -0,0 +1,32 @@
|
|||
/* -*- mode: js; indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
||||
/* 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";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["DecoderDoctorChild"];
|
||||
|
||||
class DecoderDoctorChild extends JSWindowActorChild {
|
||||
// Observes 'decoder-doctor-notification'. This actor handles most such notifications, but does not deal with notifications with the 'cannot-play' type, which is handled
|
||||
// @param aSubject the nsPIDOMWindowInner associated with the notification.
|
||||
// @param aTopic should be "decoder-doctor-notification".
|
||||
// @param aData json data that contains analysis information from Decoder Doctor:
|
||||
// - 'type' is the type of issue, it determines which text to show in the
|
||||
// infobar.
|
||||
// - 'isSolved' is true when the notification actually indicates the
|
||||
// resolution of that issue, to be reported as telemetry.
|
||||
// - 'decoderDoctorReportId' is the Decoder Doctor issue identifier, to be
|
||||
// used here as key for the telemetry (counting infobar displays,
|
||||
// "Learn how" buttons clicks, and resolutions) and for the prefs used
|
||||
// to store at-issue formats.
|
||||
// - 'formats' contains a comma-separated list of formats (or key systems)
|
||||
// that suffer the issue. These are kept in a pref, which the backend
|
||||
// uses to later find when an issue is resolved.
|
||||
// - 'decodeIssue' is a description of the decode error/warning.
|
||||
// - 'resourceURL' is the resource with the issue.
|
||||
observe(aSubject, aTopic, aData) {
|
||||
this.sendAsyncMessage("DecoderDoctor:Notification", aData);
|
||||
}
|
||||
}
|
|
@ -1,42 +1,59 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- mode: js; indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
||||
/* 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";
|
||||
|
||||
const TELEMETRY_DDSTAT_SHOWN = 0;
|
||||
const TELEMETRY_DDSTAT_SHOWN_FIRST = 1;
|
||||
const TELEMETRY_DDSTAT_CLICKED = 2;
|
||||
const TELEMETRY_DDSTAT_CLICKED_FIRST = 3;
|
||||
const TELEMETRY_DDSTAT_SOLVED = 4;
|
||||
var EXPORTED_SYMBOLS = ["DecoderDoctorParent"];
|
||||
|
||||
let gDecoderDoctorHandler = {
|
||||
const { AppConstants } = ChromeUtils.import(
|
||||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gNavigatorBundle", function() {
|
||||
return Services.strings.createBundle(
|
||||
"chrome://browser/locale/browser.properties"
|
||||
);
|
||||
});
|
||||
|
||||
class DecoderDoctorParent extends JSWindowActorParent {
|
||||
getLabelForNotificationBox(type) {
|
||||
if (type == "platform-decoder-not-found") {
|
||||
if (AppConstants.platform == "win") {
|
||||
return gNavigatorBundle.getString("decoder.noHWAcceleration.message");
|
||||
return gNavigatorBundle.GetStringFromName(
|
||||
"decoder.noHWAcceleration.message"
|
||||
);
|
||||
}
|
||||
if (AppConstants.platform == "linux") {
|
||||
return gNavigatorBundle.getString("decoder.noCodecsLinux.message");
|
||||
return gNavigatorBundle.GetStringFromName(
|
||||
"decoder.noCodecsLinux.message"
|
||||
);
|
||||
}
|
||||
}
|
||||
if (type == "cannot-initialize-pulseaudio") {
|
||||
return gNavigatorBundle.getString("decoder.noPulseAudio.message");
|
||||
return gNavigatorBundle.GetStringFromName("decoder.noPulseAudio.message");
|
||||
}
|
||||
if (type == "unsupported-libavcodec" && AppConstants.platform == "linux") {
|
||||
return gNavigatorBundle.getString(
|
||||
return gNavigatorBundle.GetStringFromName(
|
||||
"decoder.unsupportedLibavcodec.message"
|
||||
);
|
||||
}
|
||||
if (type == "decode-error") {
|
||||
return gNavigatorBundle.getString("decoder.decodeError.message");
|
||||
return gNavigatorBundle.GetStringFromName("decoder.decodeError.message");
|
||||
}
|
||||
if (type == "decode-warning") {
|
||||
return gNavigatorBundle.getString("decoder.decodeWarning.message");
|
||||
return gNavigatorBundle.GetStringFromName(
|
||||
"decoder.decodeWarning.message"
|
||||
);
|
||||
}
|
||||
return "";
|
||||
},
|
||||
}
|
||||
|
||||
getSumoForLearnHowButton(type) {
|
||||
if (
|
||||
|
@ -49,7 +66,7 @@ let gDecoderDoctorHandler = {
|
|||
return "fix-common-audio-and-video-issues";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
}
|
||||
|
||||
getEndpointForReportIssueButton(type) {
|
||||
if (type == "decode-error" || type == "decode-warning") {
|
||||
|
@ -59,20 +76,33 @@ let gDecoderDoctorHandler = {
|
|||
);
|
||||
}
|
||||
return "";
|
||||
},
|
||||
}
|
||||
|
||||
receiveMessage({ target: browser, data: data }) {
|
||||
let box = gBrowser.getNotificationBox(browser);
|
||||
receiveMessage(aMessage) {
|
||||
// The top level browsing context's embedding element should be a xul browser element.
|
||||
let browser = this.browsingContext.top.embedderElement;
|
||||
// The xul browser is owned by a window.
|
||||
let window = browser?.ownerGlobal;
|
||||
|
||||
if (!browser || !window) {
|
||||
// We don't have a browser or window so bail!
|
||||
return;
|
||||
}
|
||||
|
||||
let box = browser.getTabBrowser().getNotificationBox(browser);
|
||||
let notificationId = "decoder-doctor-notification";
|
||||
if (box.getNotificationWithValue(notificationId)) {
|
||||
// We already have a notification showing, bail.
|
||||
return;
|
||||
}
|
||||
|
||||
let parsedData;
|
||||
try {
|
||||
parsedData = JSON.parse(data);
|
||||
parsedData = JSON.parse(aMessage.data);
|
||||
} catch (ex) {
|
||||
Cu.reportError("Malformed Decoder Doctor message with data: " + data);
|
||||
Cu.reportError(
|
||||
"Malformed Decoder Doctor message with data: " + aMessage.data
|
||||
);
|
||||
return;
|
||||
}
|
||||
// parsedData (the result of parsing the incoming 'data' json string)
|
||||
|
@ -104,7 +134,7 @@ let gDecoderDoctorHandler = {
|
|||
if (!/^\w+$/im.test(decoderDoctorReportId)) {
|
||||
return;
|
||||
}
|
||||
let title = gDecoderDoctorHandler.getLabelForNotificationBox(type);
|
||||
let title = this.getLabelForNotificationBox(type);
|
||||
if (!title) {
|
||||
return;
|
||||
}
|
||||
|
@ -146,11 +176,13 @@ let gDecoderDoctorHandler = {
|
|||
}
|
||||
|
||||
let buttons = [];
|
||||
let sumo = gDecoderDoctorHandler.getSumoForLearnHowButton(type);
|
||||
let sumo = this.getSumoForLearnHowButton(type);
|
||||
if (sumo) {
|
||||
buttons.push({
|
||||
label: gNavigatorBundle.getString("decoder.noCodecs.button"),
|
||||
accessKey: gNavigatorBundle.getString("decoder.noCodecs.accesskey"),
|
||||
label: gNavigatorBundle.GetStringFromName("decoder.noCodecs.button"),
|
||||
accessKey: gNavigatorBundle.GetStringFromName(
|
||||
"decoder.noCodecs.accesskey"
|
||||
),
|
||||
callback() {
|
||||
let clickedInPref = Services.prefs.getBoolPref(
|
||||
buttonClickedPref,
|
||||
|
@ -163,17 +195,17 @@ let gDecoderDoctorHandler = {
|
|||
let baseURL = Services.urlFormatter.formatURLPref(
|
||||
"app.support.baseURL"
|
||||
);
|
||||
openTrustedLinkIn(baseURL + sumo, "tab");
|
||||
window.openTrustedLinkIn(baseURL + sumo, "tab");
|
||||
},
|
||||
});
|
||||
}
|
||||
let endpoint = gDecoderDoctorHandler.getEndpointForReportIssueButton(
|
||||
type
|
||||
);
|
||||
let endpoint = this.getEndpointForReportIssueButton(type);
|
||||
if (endpoint) {
|
||||
buttons.push({
|
||||
label: gNavigatorBundle.getString("decoder.decodeError.button"),
|
||||
accessKey: gNavigatorBundle.getString(
|
||||
label: gNavigatorBundle.GetStringFromName(
|
||||
"decoder.decodeError.button"
|
||||
),
|
||||
accessKey: gNavigatorBundle.GetStringFromName(
|
||||
"decoder.decodeError.accesskey"
|
||||
),
|
||||
callback() {
|
||||
|
@ -197,7 +229,7 @@ let gDecoderDoctorHandler = {
|
|||
}
|
||||
|
||||
params.append("details", JSON.stringify(details));
|
||||
openTrustedLinkIn(endpoint + "?" + params.toString(), "tab");
|
||||
window.openTrustedLinkIn(endpoint + "?" + params.toString(), "tab");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -215,14 +247,5 @@ let gDecoderDoctorHandler = {
|
|||
Services.prefs.clearUserPref(formatsPref);
|
||||
Services.prefs.clearUserPref(buttonClickedPref);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
window
|
||||
.getGroupMessageManager("browsers")
|
||||
.addMessageListener("DecoderDoctor:Notification", gDecoderDoctorHandler);
|
||||
window.addEventListener("unload", function() {
|
||||
window
|
||||
.getGroupMessageManager("browsers")
|
||||
.removeMessageListener("DecoderDoctor:Notification", gDecoderDoctorHandler);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -55,6 +55,8 @@ FINAL_TARGET_FILES.actors += [
|
|||
'ContentSearchParent.jsm',
|
||||
'ContextMenuChild.jsm',
|
||||
'ContextMenuParent.jsm',
|
||||
'DecoderDoctorChild.jsm',
|
||||
'DecoderDoctorParent.jsm',
|
||||
'DOMFullscreenChild.jsm',
|
||||
'DOMFullscreenParent.jsm',
|
||||
'EncryptedMediaChild.jsm',
|
||||
|
|
|
@ -96,7 +96,6 @@
|
|||
if (!AppConstants.MOZILLA_OFFICIAL) {
|
||||
Services.scriptloader.loadSubScript("chrome://browser/content/browser-development-helpers.js", this);
|
||||
}
|
||||
Services.scriptloader.loadSubScript("chrome://browser/content/browser-media.js", this);
|
||||
Services.scriptloader.loadSubScript("chrome://browser/content/browser-pageActions.js", this);
|
||||
Services.scriptloader.loadSubScript("chrome://browser/content/browser-sidebar.js", this);
|
||||
Services.scriptloader.loadSubScript("chrome://browser/content/browser-tabsintitlebar.js", this);
|
||||
|
|
|
@ -139,9 +139,6 @@ with Files("browser-fullZoom.js"):
|
|||
with Files("browser-gestureSupport.js"):
|
||||
BUG_COMPONENT = ("Core", "Widget: Cocoa")
|
||||
|
||||
with Files("browser-media.js"):
|
||||
BUG_COMPONENT = ("Core", "Audio/Video: Playback")
|
||||
|
||||
with Files("browser-pageActions.js"):
|
||||
BUG_COMPONENT = ("Firefox", "Toolbars and Customization")
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ const known_scripts = {
|
|||
]),
|
||||
processScripts: new Set([
|
||||
"chrome://global/content/process-content.js",
|
||||
"resource:///modules/ContentObservers.js",
|
||||
"resource://gre/modules/extensionProcessScriptLoader.js",
|
||||
]),
|
||||
};
|
||||
|
|
|
@ -60,7 +60,6 @@ const known_scripts = {
|
|||
]),
|
||||
processScripts: new Set([
|
||||
"chrome://global/content/process-content.js",
|
||||
"resource:///modules/ContentObservers.js",
|
||||
"resource://gre/modules/extensionProcessScriptLoader.js",
|
||||
]),
|
||||
};
|
||||
|
|
|
@ -48,7 +48,6 @@ browser.jar:
|
|||
content/browser/browser-fullScreenAndPointerLock.js (content/browser-fullScreenAndPointerLock.js)
|
||||
content/browser/browser-fullZoom.js (content/browser-fullZoom.js)
|
||||
content/browser/browser-gestureSupport.js (content/browser-gestureSupport.js)
|
||||
content/browser/browser-media.js (content/browser-media.js)
|
||||
content/browser/browser-pageActions.js (content/browser-pageActions.js)
|
||||
content/browser/browser-places.js (content/browser-places.js)
|
||||
content/browser/browser-safebrowsing.js (content/browser-safebrowsing.js)
|
||||
|
|
|
@ -377,6 +377,20 @@ let JSWINDOWACTORS = {
|
|||
allFrames: true,
|
||||
},
|
||||
|
||||
DecoderDoctor: {
|
||||
parent: {
|
||||
moduleURI: "resource:///actors/DecoderDoctorParent.jsm",
|
||||
},
|
||||
|
||||
child: {
|
||||
moduleURI: "resource:///actors/DecoderDoctorChild.jsm",
|
||||
observers: ["decoder-doctor-notification"],
|
||||
},
|
||||
|
||||
messageManagerGroups: ["browsers"],
|
||||
allFrames: true,
|
||||
},
|
||||
|
||||
DOMFullscreen: {
|
||||
parent: {
|
||||
moduleURI: "resource:///actors/DOMFullscreenParent.jsm",
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
/**
|
||||
* This process script is for small observers that we want to register
|
||||
* once per content process, usually in order to forward content-based
|
||||
* observer service notifications to the chrome process through
|
||||
* message passing. Using a process script avoids having them in
|
||||
* content.js and thereby registering N observers for N open tabs,
|
||||
* which is bad for perf.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var gDecoderDoctorObserver = function(subject, topic, data) {
|
||||
let win = subject.top;
|
||||
let mm = getMessageManagerForWindow(win);
|
||||
if (mm) {
|
||||
mm.sendAsyncMessage("DecoderDoctor:Notification", data);
|
||||
}
|
||||
};
|
||||
|
||||
function getMessageManagerForWindow(aContentWindow) {
|
||||
return aContentWindow.docShell.messageManager;
|
||||
}
|
||||
|
||||
Services.obs.addObserver(gDecoderDoctorObserver, "decoder-doctor-notification");
|
|
@ -131,7 +131,6 @@ EXTRA_JS_MODULES += [
|
|||
'BrowserUsageTelemetry.jsm',
|
||||
'BrowserWindowTracker.jsm',
|
||||
'ContentCrashHandlers.jsm',
|
||||
'ContentObservers.js',
|
||||
'Discovery.jsm',
|
||||
'EveryWindow.jsm',
|
||||
'ExtensionsUI.jsm',
|
||||
|
|
|
@ -236,7 +236,8 @@ enum class ReportParam : uint8_t {
|
|||
};
|
||||
|
||||
struct NotificationAndReportStringId {
|
||||
// Notification type, handled by browser-media.js.
|
||||
// Notification type, handled by DecoderDoctorChild.jsm and
|
||||
// DecoderDoctorParent.jsm.
|
||||
dom::DecoderDoctorNotificationType mNotificationType;
|
||||
// Console message id. Key in dom/locales/.../chrome/dom/dom.properties.
|
||||
const char* mReportStringId;
|
||||
|
|
|
@ -35,10 +35,6 @@ MainProcessSingleton.prototype = {
|
|||
"chrome://global/content/process-content.js",
|
||||
true
|
||||
);
|
||||
Services.ppmm.loadProcessScript(
|
||||
"resource:///modules/ContentObservers.js",
|
||||
true
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
"content-process.jsm": ["init"],
|
||||
"content.jsm": ["registerContentFrame"],
|
||||
"ContentCrashHandlers.jsm": ["TabCrashHandler", "SubframeCrashHandler", "UnsubmittedCrashHandler"],
|
||||
"ContentObservers.js": [],
|
||||
"ContentPrefUtils.jsm": ["ContentPref", "cbHandleResult", "cbHandleError", "cbHandleCompletion", "safeCallback", "_methodsCallableFromChild"],
|
||||
"cookies.js": ["Cookies"],
|
||||
"CoverageUtils.jsm": ["CoverageCollector"],
|
||||
|
|
Загрузка…
Ссылка в новой задаче