Bug 1276027 - Add a Telemetry probe to track how often Firefox is used as the default handler. r=bsmedberg,rstrong, a=sylvestre
authorJared Wein <jwein@mozilla.com>
Mon, 06 Jun 2016 19:36:45 -0400
changeset 339607 73286271d4769104a91633e8ae9fd50f0d090d1d
parent 339606 1c3037d99f3af964fb481169d9eb6b65a81bd081
child 339608 dca560586c399c3ae3a7ce96d5c3681ee2cbf5b4
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, rstrong, sylvestre
bugs1276027
milestone49.0a2
Bug 1276027 - Add a Telemetry probe to track how often Firefox is used as the default handler. r=bsmedberg,rstrong, a=sylvestre MozReview-Commit-ID: Ar3MaKeUIdz
browser/components/nsBrowserContentHandler.js
toolkit/components/telemetry/Histograms.json
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -705,16 +705,28 @@ nsDefaultCommandLineHandler.prototype = 
 
     return this;
   },
 
   _haveProfile: false,
 
   /* nsICommandLineHandler */
   handle : function dch_handle(cmdLine) {
+    // The -url flag is inserted by the operating system when the default
+    // application handler is used. We check for default browser to remove
+    // instances where users explicitly decide to "open with" the browser.
+    // Note that users who launch firefox manually with the -url flag will
+    // get erroneously counted.
+    if (cmdLine.findFlag("url", false) &&
+        ShellService.isDefaultBrowser(false, false)) {
+      try {
+        Services.telemetry.getHistogramById("FX_STARTUP_EXTERNAL_CONTENT_HANDLER").add();
+      } catch (e) {}
+    }
+
     var urilist = [];
 
     if (AppConstants.platform == "win") {
       // If we don't have a profile selected yet (e.g. the Profile Manager is
       // displayed) we will crash if we open an url and then select a profile. To
       // prevent this handle all url command line flags and set the command line's
       // preventDefault to true to prevent the display of the ui. The initial
       // command line will be retained when nsAppRunner calls LaunchChild though
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -4447,16 +4447,23 @@
     "bug_numbers": [1275114],
     "alert_emails": ["gijs@mozilla.com"],
     "expires_in_version": "53",
     "kind": "enumerated",
     "n_values": 15,
     "releaseChannelCollection": "opt-out",
     "description": "The browser that was the default on the initial profile migration. The values correspond to the internal browser ID (see MigrationUtils.jsm)"
   },
+  "FX_STARTUP_EXTERNAL_CONTENT_HANDLER": {
+    "bug_numbers": [1276027],
+    "alert_emails": ["jaws@mozilla.com"],
+    "expires_in_version": "53",
+    "kind": "count",
+    "description": "Count how often the browser is opened as an external app handler. This is generally used when the browser is set as the default browser."
+  },
   "INPUT_EVENT_RESPONSE_MS": {
     "alert_emails": ["perf-telemetry-alerts@mozilla.com"],
     "bug_numbers": [1235908],
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 10000,
     "n_buckets": 50,
     "description": "Time (ms) from the Input event being created to the end of it being handled"