mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 544597 - Remap plugin names to a more readable form for plugin-crashed UI. r=gavin, r=jst
This commit is contained in:
parent
465b1bf745
commit
f72ceb215b
@ -50,6 +50,7 @@
|
||||
# Rob Arnold <robarnold@cmu.edu>
|
||||
# Dietrich Ayala <dietrich@mozilla.com>
|
||||
# Gavin Sharp <gavin@gavinsharp.com>
|
||||
# Justin Dolske <dolske@mozilla.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -5936,6 +5937,17 @@ var gMissingPluginInstaller = {
|
||||
return this.crashReportHelpURL;
|
||||
},
|
||||
|
||||
// Map the plugin's name to a filtered version more suitable for user UI.
|
||||
makeNicePluginName : function (aName, aFilename) {
|
||||
if (aName == "Shockwave Flash")
|
||||
return "Adobe Flash";
|
||||
|
||||
// Clean up the plugin name by stripping off any trailing version numbers
|
||||
// or "plugin". EG, "Foo Bar Plugin 1.23_02" --> "Foo Bar"
|
||||
let newName = aName.replace(/\bplug-?in\b/i, "").replace(/[\s\d\.\-\_\(\)]+$/, "");
|
||||
return newName;
|
||||
},
|
||||
|
||||
addLinkClickCallback: function (linkNode, callbackName /*callbackArgs...*/) {
|
||||
// XXX just doing (callback)(arg) was giving a same-origin error. bug?
|
||||
let self = this;
|
||||
@ -6175,20 +6187,22 @@ var gMissingPluginInstaller = {
|
||||
if (!aEvent.isTrusted)
|
||||
return;
|
||||
|
||||
if (!(aEvent instanceof Ci.nsIDOMDataContainerEvent))
|
||||
// Ensure the plugin and event are of the right type.
|
||||
let plugin = aEvent.target;
|
||||
if (!(aEvent instanceof Ci.nsIDOMDataContainerEvent) ||
|
||||
!(plugin instanceof Ci.nsIObjectLoadingContent))
|
||||
return;
|
||||
|
||||
let submittedReport = aEvent.getData("submittedCrashReport");
|
||||
let doPrompt = true; // XXX followup for .getData("doPrompt");
|
||||
let submitReports = true; // XXX followup for .getData("submitReports");
|
||||
let pluginName = aEvent.getData("pluginName");
|
||||
let pluginFilename = aEvent.getData("pluginFilename");
|
||||
let pluginDumpID = aEvent.getData("pluginDumpID");
|
||||
let browserDumpID = aEvent.getData("browserDumpID");
|
||||
|
||||
// We're expecting this to be a plugin.
|
||||
let plugin = aEvent.target;
|
||||
if (!(plugin instanceof Ci.nsIObjectLoadingContent))
|
||||
return;
|
||||
// Remap the plugin name to a more user-presentable form.
|
||||
pluginName = self.makeNicePluginName(pluginName, pluginFilename);
|
||||
|
||||
// Force a style flush, so that we ensure our binding is attached.
|
||||
plugin.clientTop;
|
||||
|
@ -21,6 +21,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Justin Dolske <dolske@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -224,17 +225,20 @@ public:
|
||||
nsString mPluginDumpID;
|
||||
nsString mBrowserDumpID;
|
||||
nsString mPluginName;
|
||||
nsString mPluginFilename;
|
||||
PRBool mSubmittedCrashReport;
|
||||
|
||||
nsPluginCrashedEvent(nsIContent* aContent,
|
||||
const nsAString& aPluginDumpID,
|
||||
const nsAString& aBrowserDumpID,
|
||||
const nsAString& aPluginName,
|
||||
const nsAString& aPluginFilename,
|
||||
PRBool submittedCrashReport)
|
||||
: mContent(aContent),
|
||||
mPluginDumpID(aPluginDumpID),
|
||||
mBrowserDumpID(aBrowserDumpID),
|
||||
mPluginName(aPluginName),
|
||||
mPluginFilename(aPluginFilename),
|
||||
mSubmittedCrashReport(submittedCrashReport)
|
||||
{}
|
||||
|
||||
@ -299,6 +303,15 @@ nsPluginCrashedEvent::Run()
|
||||
variant->SetAsAString(mPluginName);
|
||||
containerEvent->SetData(NS_LITERAL_STRING("pluginName"), variant);
|
||||
|
||||
// add a "pluginFilename" property to this event
|
||||
variant = do_CreateInstance("@mozilla.org/variant;1");
|
||||
if (!variant) {
|
||||
NS_WARNING("Couldn't create pluginFilename variant for PluginCrashed event!");
|
||||
return NS_OK;
|
||||
}
|
||||
variant->SetAsAString(mPluginFilename);
|
||||
containerEvent->SetData(NS_LITERAL_STRING("pluginFilename"), variant);
|
||||
|
||||
// add a "submittedCrashReport" property to this event
|
||||
variant = do_CreateInstance("@mozilla.org/variant;1");
|
||||
if (!variant) {
|
||||
@ -2046,11 +2059,14 @@ nsObjectLoadingContent::PluginCrashed(nsIPluginTag* aPluginTag,
|
||||
// out any data we need now.
|
||||
nsCAutoString pluginName;
|
||||
aPluginTag->GetName(pluginName);
|
||||
nsCAutoString pluginFilename;
|
||||
aPluginTag->GetFilename(pluginFilename);
|
||||
|
||||
nsCOMPtr<nsIRunnable> ev = new nsPluginCrashedEvent(thisContent,
|
||||
pluginDumpID,
|
||||
browserDumpID,
|
||||
NS_ConvertUTF8toUTF16(pluginName),
|
||||
NS_ConvertUTF8toUTF16(pluginFilename),
|
||||
submittedCrashReport);
|
||||
nsresult rv = NS_DispatchToCurrentThread(ev);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -29,8 +29,7 @@ var testObserver = {
|
||||
is(topic, "plugin-crashed", "Checking correct topic");
|
||||
is(data, null, "Checking null data");
|
||||
ok((subject instanceof Components.interfaces.nsIPropertyBag2), "got Propbag");
|
||||
ok((subject instanceof Components.interfaces.nsIWritablePropertyBag2),
|
||||
"got writable Propbag");
|
||||
ok((subject instanceof Components.interfaces.nsIWritablePropertyBag2), "got writable Propbag");
|
||||
|
||||
var id = subject.getPropertyAsAString("pluginDumpID");
|
||||
isnot(id, "", "got a non-empty crash id");
|
||||
@ -73,8 +72,13 @@ function onPluginCrashed(aEvent) {
|
||||
|
||||
ok(aEvent instanceof Components.interfaces.nsIDOMDataContainerEvent,
|
||||
"plugin crashed event has the right interface");
|
||||
|
||||
var minidumpID = aEvent.getData("minidumpID");
|
||||
isnot(minidumpID, "", "got a non-empty dump ID");
|
||||
var pluginName = aEvent.getData("pluginName");
|
||||
is(pluginName, "Test Plug-in");
|
||||
is(pluginName, "Test Plug-in", "got correct plugin name");
|
||||
var pluginFilename = aEvent.getData("pluginFilename");
|
||||
isnot(pluginFilename, "", "got a non-empty filename");
|
||||
var didReport = aEvent.getData("submittedCrashReport");
|
||||
// The app itself may or may not have decided to submit the report, so
|
||||
// allow either true or false here.
|
||||
|
Loading…
Reference in New Issue
Block a user