Bug 1098123 - Add telemetry for onbeforeunload usage. r=jst

This commit is contained in:
Justin Dolske 2014-11-20 14:50:01 -08:00
parent 2a290c84fd
commit 850a5ff980
2 changed files with 16 additions and 0 deletions

View File

@ -121,6 +121,7 @@ static const char sPrintOptionsContractID[] =
#include <stdio.h>
#include "mozilla/dom/Element.h"
#include "mozilla/Telemetry.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -1198,6 +1199,7 @@ nsDocumentViewer::PermitUnloadInternal(bool aCallerClosesWindow,
nsAutoSyncOperation sync(mDocument);
mInPermitUnloadPrompt = true;
mozilla::Telemetry::Accumulate(mozilla::Telemetry::ONBEFOREUNLOAD_PROMPT_COUNT, 1);
rv = prompt->ConfirmEx(title, message, buttonFlags,
leaveLabel, stayLabel, nullptr, nullptr,
&dummy, &buttonPressed);
@ -1212,12 +1214,15 @@ nsDocumentViewer::PermitUnloadInternal(bool aCallerClosesWindow,
// XXX: Are there other cases where prompts can abort? Is it ok to
// prevent unloading the page in those cases?
if (NS_FAILED(rv)) {
mozilla::Telemetry::Accumulate(mozilla::Telemetry::ONBEFOREUNLOAD_PROMPT_ACTION, 2);
*aPermitUnload = false;
return NS_OK;
}
// Button 0 == leave, button 1 == stay
*aPermitUnload = (buttonPressed == 0);
mozilla::Telemetry::Accumulate(mozilla::Telemetry::ONBEFOREUNLOAD_PROMPT_ACTION,
(*aPermitUnload ? 1 : 0));
// If the user decided to go ahead, make sure not to prompt the user again
// by toggling the internal prompting bool to false:
if (*aPermitUnload) {

View File

@ -6861,5 +6861,16 @@
"expires_in_version": "40",
"kind": "boolean",
"description": "Whether the e10s pref was set but it was blocked from running due to blacklisted conditions"
},
"ONBEFOREUNLOAD_PROMPT_ACTION" : {
"expires_in_version": "45",
"kind": "enumerated",
"n_values": 3,
"description": "What button a user clicked in an onbeforeunload prompt. (Stay on Page = 0, Leave Page = 1, prompt aborted = 2)"
},
"ONBEFOREUNLOAD_PROMPT_COUNT" : {
"expires_in_version": "45",
"kind": "count",
"description": "How many onbeforeunload prompts has the user encountered in their session?"
}
}