bug 1292317 - Make Flash click to play icon into a drop down when HLS is used r=mconley

This commit is contained in:
Brad Lassey 2016-09-09 10:39:58 -04:00
Родитель 75da566dc9
Коммит b616ea20c3
2 изменённых файлов: 33 добавлений и 3 удалений

Просмотреть файл

@ -54,6 +54,8 @@ PluginContent.prototype = {
global.addMessageListener("BrowserPlugins:NPAPIPluginProcessCrashed", this);
global.addMessageListener("BrowserPlugins:CrashReportSubmitted", this);
global.addMessageListener("BrowserPlugins:Test:ClearCrashData", this);
Services.obs.addObserver(this, "decoder-doctor-notification", false);
},
uninit: function() {
@ -75,6 +77,9 @@ PluginContent.prototype = {
global.removeMessageListener("BrowserPlugins:NPAPIPluginProcessCrashed", this);
global.removeMessageListener("BrowserPlugins:CrashReportSubmitted", this);
global.removeMessageListener("BrowserPlugins:Test:ClearCrashData", this);
Services.obs.removeObserver(this, "decoder-doctor-notification");
delete this.global;
delete this.content;
},
@ -118,6 +123,26 @@ PluginContent.prototype = {
}
},
observe: function observe(aSubject, aTopic, aData) {
switch (aTopic) {
case "decoder-doctor-notification":
let data = JSON.parse(aData);
if (this.haveShownNotification &&
aSubject.top.document == this.content.document &&
data.formats.toLowerCase().includes("application/x-mpegurl", 0)) {
let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
let principal = this.content.document.nodePrincipal;
let location = this.content.document.location.href;
this.global.content.pluginRequiresReload = true;
this.global.sendAsyncMessage("PluginContent:ShowClickToPlayNotification",
{ plugins: [... this.pluginData.values()],
showNow: true,
location: location,
}, null, principal);
}
}
},
onPageShow: function (event) {
// Ignore events that aren't from the main document.
if (!this.content || event.target != this.content.document) {
@ -140,6 +165,7 @@ PluginContent.prototype = {
this._finishRecordingFlashPluginTelemetry();
this.clearPluginCaches();
this.haveShownNotification = false;
},
getPluginUI: function (plugin, anonid) {
@ -725,9 +751,11 @@ PluginContent.prototype = {
}
}
// If there are no instances of the plugin on the page any more, what the
// If there are no instances of the plugin on the page any more or if we've
// noted that the content needs to be reloaded due to replacing HLS, what the
// user probably needs is for us to allow and then refresh.
if (newState != "block" && !pluginFound) {
if (newState != "block" &&
(!pluginFound || contentWindow.pluginRequiresReload)) {
this.reloadPage();
}
this.updateNotificationUI();
@ -789,6 +817,8 @@ PluginContent.prototype = {
this.pluginData.set(pluginInfo.permissionString, pluginInfo);
}
this.haveShownNotification = true;
this.global.sendAsyncMessage("PluginContent:ShowClickToPlayNotification", {
plugins: [... this.pluginData.values()],
showNow: showNow,

Просмотреть файл

@ -392,7 +392,7 @@ pref("media.gmp.storage.version.expected", 1);
// Filter what triggers user notifications.
// See DecoderDoctorDocumentWatcher::ReportAnalysis for details.
pref("media.decoder-doctor.notifications-allowed", "MediaWMFNeeded,MediaWidevineNoWMFNoSilverlight,MediaCannotInitializePulseAudio,MediaUnsupportedLibavcodec");
pref("media.decoder-doctor.notifications-allowed", "MediaWMFNeeded,MediaWidevineNoWMFNoSilverlight,MediaCannotInitializePulseAudio,MediaUnsupportedLibavcodec,MediaCannotPlayNoDecoders,MediaNoDecoders");
// Whether we report partial failures.
pref("media.decoder-doctor.verbose", false);
// Whether DD should consider WMF-disabled a WMF failure, useful for testing.