Bug 1373650. Move Report Site Issue button from CUI to PageActions API. r=adw
authorMike Taylor <miket@mozilla.com>
Thu, 03 Aug 2017 23:18:29 -0500
changeset 374148 a0b6db321f82
parent 374147 5a5bf9b4754a
child 374149 0f9b774eac91
push id48578
push usermitaylor@mozilla.com
push dateFri, 11 Aug 2017 18:29:20 +0000
treeherderautoland@449c8d0f859e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1373650
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1373650. Move Report Site Issue button from CUI to PageActions API. r=adw MozReview-Commit-ID: 5fxJkR2PUuc
browser/extensions/webcompat-reporter/content/TabListener.jsm
browser/extensions/webcompat-reporter/content/WebCompatReporter.jsm
browser/extensions/webcompat-reporter/jar.mn
browser/extensions/webcompat-reporter/skin/lightbulb.svg
browser/extensions/webcompat-reporter/skin/linux/lightbulb-inverted.png
browser/extensions/webcompat-reporter/skin/linux/lightbulb-inverted@2x.png
browser/extensions/webcompat-reporter/skin/linux/lightbulb.png
browser/extensions/webcompat-reporter/skin/linux/lightbulb@2x.png
browser/extensions/webcompat-reporter/skin/osx/lightbulb-inverted.png
browser/extensions/webcompat-reporter/skin/osx/lightbulb-inverted@2x.png
browser/extensions/webcompat-reporter/skin/osx/lightbulb-yosemite.png
browser/extensions/webcompat-reporter/skin/osx/lightbulb-yosemite@2x.png
browser/extensions/webcompat-reporter/skin/osx/lightbulb.png
browser/extensions/webcompat-reporter/skin/osx/lightbulb@2x.png
browser/extensions/webcompat-reporter/skin/shared/lightbulb.css
browser/extensions/webcompat-reporter/skin/shared/lightbulb.svg
browser/extensions/webcompat-reporter/skin/windows/lightbulb-inverted.png
browser/extensions/webcompat-reporter/skin/windows/lightbulb-inverted@2x.png
browser/extensions/webcompat-reporter/skin/windows/lightbulb-win7.png
browser/extensions/webcompat-reporter/skin/windows/lightbulb-win7@2x.png
browser/extensions/webcompat-reporter/skin/windows/lightbulb-win8.png
browser/extensions/webcompat-reporter/skin/windows/lightbulb-win8@2x.png
browser/extensions/webcompat-reporter/skin/windows/lightbulb.png
browser/extensions/webcompat-reporter/skin/windows/lightbulb@2x.png
deleted file mode 100644
--- a/browser/extensions/webcompat-reporter/content/TabListener.jsm
+++ /dev/null
@@ -1,63 +0,0 @@
-/* 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.EXPORTED_SYMBOLS = ["TabListener"];
-
-let { classes: Cc, interfaces: Ci, utils: Cu } = Components;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
- "resource:///modules/CustomizableUI.jsm");
-
-const WIDGET_ID = "webcompat-reporter-button";
-
-// Class that watches for url/location/tab changes and enables or disables
-// the Report Site Issue button accordingly
-class TabListener {
-  constructor(win) {
-    this.win = win;
-    this.browser = win.gBrowser;
-    this.addListeners();
-  }
-
-  addListeners() {
-    this.browser.addTabsProgressListener(this);
-    this.browser.tabContainer.addEventListener("TabSelect", this);
-  }
-
-  removeListeners() {
-    this.browser.removeTabsProgressListener(this);
-    this.browser.tabContainer.removeEventListener("TabSelect", this);
-  }
-
-  handleEvent(e) {
-    switch (e.type) {
-      case "TabSelect":
-        this.setButtonState(e.target.linkedBrowser.currentURI.scheme);
-        break;
-    }
-  }
-
-  onLocationChange(browser, webProgress, request, uri, flags) {
-    this.setButtonState(uri.scheme);
-  }
-
-  static isReportableScheme(scheme) {
-    return ["http", "https"].some((prefix) => scheme.startsWith(prefix));
-  }
-
-  setButtonState(scheme) {
-    // Bail early if the button is in the palette.
-    if (!CustomizableUI.getPlacementOfWidget(WIDGET_ID)) {
-      return;
-    }
-
-    if (TabListener.isReportableScheme(scheme)) {
-      CustomizableUI.getWidget(WIDGET_ID).forWindow(this.win).node.removeAttribute("disabled");
-    } else {
-      CustomizableUI.getWidget(WIDGET_ID).forWindow(this.win).node.setAttribute("disabled", true);
-    }
-  }
-}
--- a/browser/extensions/webcompat-reporter/content/WebCompatReporter.jsm
+++ b/browser/extensions/webcompat-reporter/content/WebCompatReporter.jsm
@@ -4,94 +4,54 @@
 
 this.EXPORTED_SYMBOLS = ["WebCompatReporter"];
 
 let { classes: Cc, interfaces: Ci, utils: Cu } = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
-const TABLISTENER_JSM = "chrome://webcompat-reporter/content/TabListener.jsm";
-const WIDGET_ID = "webcompat-reporter-button";
 const PREF_STYLO_ENABLED = "layout.css.servo.enabled";
 
-XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
-  "resource:///modules/CustomizableUI.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "PageActions",
+  "resource:///modules/PageActions.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "wcStrings", function() {
   return Services.strings.createBundle(
     "chrome://webcompat-reporter/locale/webcompat.properties");
 });
 
-XPCOMUtils.defineLazyGetter(this, "wcStyleURI", function() {
-  return Services.io.newURI("chrome://webcompat-reporter/skin/lightbulb.css");
-});
-
 let WebCompatReporter = {
   get endpoint() {
     return Services.urlFormatter.formatURLPref(
       "extensions.webcompat-reporter.newIssueEndpoint");
   },
 
   init() {
-    let styleSheetService = Cc["@mozilla.org/content/style-sheet-service;1"]
-      .getService(Ci.nsIStyleSheetService);
-    this._sheetType = styleSheetService.AUTHOR_SHEET;
-    this._cachedSheet = styleSheetService.preloadSheet(wcStyleURI,
-                                                       this._sheetType);
-
-    XPCOMUtils.defineLazyModuleGetter(this, "TabListener", TABLISTENER_JSM);
-
-    CustomizableUI.createWidget({
-      id: WIDGET_ID,
-      label: wcStrings.GetStringFromName("wc-reporter.label"),
-      tooltiptext: wcStrings.GetStringFromName("wc-reporter.tooltip"),
-      defaultArea: CustomizableUI.AREA_PANEL,
-      disabled: true,
-      onCommand: (e) => this.reportIssue(e.target.ownerDocument),
-    });
-
-    for (let win of CustomizableUI.windows) {
-      this.onWindowOpened(win);
-    }
-
-    CustomizableUI.addListener(this);
-  },
-
-  onWindowOpened(win) {
-    // Attach stylesheet for the button icon.
-    win.QueryInterface(Ci.nsIInterfaceRequestor)
-      .getInterface(Ci.nsIDOMWindowUtils)
-      .addSheet(this._cachedSheet, this._sheetType);
-    // Attach listeners to new window.
-    win._webcompatReporterTabListener = new this.TabListener(win);
-  },
-
-  onWindowClosed(win) {
-    if (win._webcompatReporterTabListener) {
-      win._webcompatReporterTabListener.removeListeners();
-      delete win._webcompatReporterTabListener;
-    }
+    PageActions.addAction(new PageActions.Action({
+      id: "webcompat-reporter-button",
+      title: wcStrings.GetStringFromName("wc-reporter.label"),
+      iconURL: "chrome://webcompat-reporter/skin/lightbulb.svg",
+      onCommand: (e) => this.reportIssue(e.target.ownerGlobal),
+      onShowingInPanel: (buttonNode) => this.onShowingInPanel(buttonNode)
+    }));
   },
 
   uninit() {
-    CustomizableUI.destroyWidget(WIDGET_ID);
-
-    for (let win of CustomizableUI.windows) {
-      this.onWindowClosed(win);
+    let action = PageActions.actionForID("webcompat-reporter-button");
+    action.remove();
+  },
 
-      win.QueryInterface(Ci.nsIInterfaceRequestor)
-        .getInterface(Ci.nsIDOMWindowUtils)
-        .removeSheet(wcStyleURI, this._sheetType);
-    }
-
-    CustomizableUI.removeListener(this);
-
-    if (Cu.isModuleLoaded(TABLISTENER_JSM)) {
-      Cu.unload(TABLISTENER_JSM);
+  onShowingInPanel(buttonNode) {
+    let browser = buttonNode.ownerGlobal.gBrowser;
+    let scheme = browser.currentURI.scheme;
+    if (["http", "https"].includes(scheme)) {
+      buttonNode.removeAttribute("disabled");
+    } else {
+      buttonNode.setAttribute("disabled", "true");
     }
   },
 
   // This method injects a framescript that should send back a screenshot blob
   // of the top-level window of the currently selected tab, resolved as a
   // Promise.
   getScreenshot(gBrowser) {
     const FRAMESCRIPT = "chrome://webcompat-reporter/content/tab-frame.js";
@@ -164,13 +124,13 @@ let WebCompatReporter = {
           }
         }
       };
 
       browser.addProgressListener(loadedListener);
     }
   },
 
-  reportIssue(xulDoc) {
-    this.getScreenshot(xulDoc.defaultView.gBrowser).then(this.openWebCompatTab)
-                                                   .catch(Cu.reportError);
+  reportIssue(global) {
+    this.getScreenshot(global.gBrowser).then(this.openWebCompatTab)
+                                       .catch(Cu.reportError);
   }
 };
--- a/browser/extensions/webcompat-reporter/jar.mn
+++ b/browser/extensions/webcompat-reporter/jar.mn
@@ -1,25 +1,9 @@
 # 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/.
 
 [features/webcompat-reporter@mozilla.org] chrome.jar:
 % content webcompat-reporter %content/
   content/ (content/*)
 % skin webcompat-reporter classic/1.0 %skin/
-#ifdef XP_WIN
-  skin/   (skin/windows/*)
-% override chrome://webcompat-reporter/skin/lightbulb.png    chrome://webcompat-reporter/skin/lightbulb-win7.png    osversion=6.1
-% override chrome://webcompat-reporter/skin/lightbulb@2x.png chrome://webcompat-reporter/skin/lightbulb-win7@2x.png osversion=6.1
-% override chrome://webcompat-reporter/skin/lightbulb.png    chrome://webcompat-reporter/skin/lightbulb-win8.png    osversion=6.2
-% override chrome://webcompat-reporter/skin/lightbulb@2x.png chrome://webcompat-reporter/skin/lightbulb-win8@2x.png osversion=6.2
-% override chrome://webcompat-reporter/skin/lightbulb.png    chrome://webcompat-reporter/skin/lightbulb-win8.png    osversion=6.3
-% override chrome://webcompat-reporter/skin/lightbulb@2x.png chrome://webcompat-reporter/skin/lightbulb-win8@2x.png osversion=6.3
-#elifdef XP_MACOSX
-  skin/   (skin/osx/*)
-% override chrome://webcompat-reporter/skin/lightbulb.png    chrome://webcompat-reporter/skin/lightbulb-yosemite.png    osversion>=10.10
-% override chrome://webcompat-reporter/skin/lightbulb@2x.png chrome://webcompat-reporter/skin/lightbulb-yosemite@2x.png osversion>=10.10
-#else
-  skin/   (skin/linux/*)
-#endif
-  skin/lightbulb.css (skin/shared/lightbulb.css)
-* skin/lightbulb.svg (skin/shared/lightbulb.svg)
+  skin/  (skin/*)
new file mode 100644
--- /dev/null
+++ b/browser/extensions/webcompat-reporter/skin/lightbulb.svg
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!-- 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/. -->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="32" height="32" fill="context-fill">
+  <path d="M11.5,8.3h.1l9-1a.8.8,0,0,0-.2-1.5l-9,1a.8.8,0,0,0,.1,1.5Zm2.4,13.5a.3.3,0,0,0,.1.2h.9a.3.3,0,0,0,.1-.2,1.8,1.8,0,0,0-.5-1.1A1.8,1.8,0,0,0,13.9,21.7ZM11.5,6.3h.1l8-1a.7.7,0,0,0,.7-.8.7.7,0,0,0-.3-.5A4.4,4.4,0,0,0,16,1c-3,0-4,3-4,3h5.5l-6,.8a.7.7,0,0,0,.1,1.5ZM17,21.8c0,.1,0,.3.5.3h.4a.4.4,0,0,0,.1-.3,1.8,1.8,0,0,0-.4-1A1.9,1.9,0,0,0,17,21.8Zm5.3-8.9-1.1-2.2a1,1,0,0,0-.9-.6H13.8l6.8-.8a.8.8,0,0,0-.2-1.5l-9,1a.8.8,0,0,0-.7.8.7.7,0,0,0,.4.6l-.4.5L9.7,12.8C8.5,15,6,17,6,21.5A9.6,9.6,0,0,0,16,31a9.6,9.6,0,0,0,10-9.5C26,17,23.5,15,22.3,12.8Zm0,7.7a.5.5,0,0,1-.6,0,3.8,3.8,0,0,0-2.2-.8l-1.1.3a2.7,2.7,0,0,1,.6,1.6,1.4,1.4,0,0,1-.4,1,1.6,1.6,0,0,1-1.1.4A1.3,1.3,0,0,1,16,21.8a2.8,2.8,0,0,1,.8-1.8,1.8,1.8,0,0,0-1.7,0,2.8,2.8,0,0,1,.7,1.7,1.3,1.3,0,0,1-.4.9,1.5,1.5,0,0,1-1,.4,1.8,1.8,0,0,1-1.2-.4,1.3,1.3,0,0,1-.4-1,2.7,2.7,0,0,1,.7-1.7,2.5,2.5,0,0,0-1.2-.3,3.8,3.8,0,0,0-2.1.7.5.5,0,0,1-.7-.6l4.6-8.5a.5.5,0,1,1,.9.5l-3.9,7.2,1.2-.2a3.6,3.6,0,0,1,2,.6,2.8,2.8,0,0,1,3.3,0,3.5,3.5,0,0,1,1.9-.5l1.3.2L17,11.8a.5.5,0,1,1,.9-.5l4.5,8.6A.5.5,0,0,1,22.3,20.6Z"/>
+</svg>
deleted file mode 100644
index 5d3cb8ee0e226444efbfc1f9f4d912de9895fb56..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index d1c896a29277884d1f9ff8f3165bac47bf19868c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 06825536dbaa39d94ae2b538ac859c8a212d31f5..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 636e434ffd354e4f84a31ec0a8bc792fc7571f81..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index caa8d308e2e581336f24eee1a05e63ad63aa0636..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 6a9ae138176e3f738d1bd77cf11bfcfd5cc515ed..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index b0bf2360bc5d0bd26a18793fa17f1580db6ee65e..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 940e340f3f240f0c3df2a33c59e890ec132907f0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index f82fb2d1de735c9e8d411d4ebc613d9b72c5bec1..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 3831e75c4bad6e7d01a21e25e2a7f24dfa183065..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/browser/extensions/webcompat-reporter/skin/shared/lightbulb.css
+++ /dev/null
@@ -1,27 +0,0 @@
-/* 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/. */
-#webcompat-reporter-button[cui-areatype="menu-panel"],
-toolbarpaletteitem[place="palette"] > #webcompat-reporter-button {
-  list-style-image: url("chrome://webcompat-reporter/skin/lightbulb.svg");
-}
-
-#webcompat-reporter-button[cui-areatype="toolbar"] {
-  list-style-image: url("chrome://webcompat-reporter/skin/lightbulb.png");
-  -moz-image-region: rect(0, 18px, 18px, 0);
-}
-
-toolbar[brighttext] #webcompat-reporter-button {
- list-style-image: url("chrome://webcompat-reporter/skin/lightbulb-inverted.png");
-}
-
-@media (min-resolution: 1.1dppx) {
-  #webcompat-reporter-button[cui-areatype="toolbar"] {
-    list-style-image: url("chrome://webcompat-reporter/skin/lightbulb@2x.png");
-    -moz-image-region: rect(0, 36px, 36px, 0px);
-  }
-
-  toolbar[brighttext] #webcompat-reporter-button {
-    list-style-image: url("chrome://webcompat-reporter/skin/lightbulb-inverted@2x.png");
-  }
-}
deleted file mode 100644
--- a/browser/extensions/webcompat-reporter/skin/shared/lightbulb.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0"?>
-<!-- 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/. -->
-<svg xmlns="http://www.w3.org/2000/svg"
-     width="32" height="32" class="fieldtext">
-#include ../../../../../browser/themes/shared/icon-colors.inc.svg
-
-  <path d="M11.5,8.3h.1l9-1a.8.8,0,0,0-.2-1.5l-9,1a.8.8,0,0,0,.1,1.5Zm2.4,13.5a.3.3,0,0,0,.1.2h.9a.3.3,0,0,0,.1-.2,1.8,1.8,0,0,0-.5-1.1A1.8,1.8,0,0,0,13.9,21.7ZM11.5,6.3h.1l8-1a.7.7,0,0,0,.7-.8.7.7,0,0,0-.3-.5A4.4,4.4,0,0,0,16,1c-3,0-4,3-4,3h5.5l-6,.8a.7.7,0,0,0,.1,1.5ZM17,21.8c0,.1,0,.3.5.3h.4a.4.4,0,0,0,.1-.3,1.8,1.8,0,0,0-.4-1A1.9,1.9,0,0,0,17,21.8Zm5.3-8.9-1.1-2.2a1,1,0,0,0-.9-.6H13.8l6.8-.8a.8.8,0,0,0-.2-1.5l-9,1a.8.8,0,0,0-.7.8.7.7,0,0,0,.4.6l-.4.5L9.7,12.8C8.5,15,6,17,6,21.5A9.6,9.6,0,0,0,16,31a9.6,9.6,0,0,0,10-9.5C26,17,23.5,15,22.3,12.8Zm0,7.7a.5.5,0,0,1-.6,0,3.8,3.8,0,0,0-2.2-.8l-1.1.3a2.7,2.7,0,0,1,.6,1.6,1.4,1.4,0,0,1-.4,1,1.6,1.6,0,0,1-1.1.4A1.3,1.3,0,0,1,16,21.8a2.8,2.8,0,0,1,.8-1.8,1.8,1.8,0,0,0-1.7,0,2.8,2.8,0,0,1,.7,1.7,1.3,1.3,0,0,1-.4.9,1.5,1.5,0,0,1-1,.4,1.8,1.8,0,0,1-1.2-.4,1.3,1.3,0,0,1-.4-1,2.7,2.7,0,0,1,.7-1.7,2.5,2.5,0,0,0-1.2-.3,3.8,3.8,0,0,0-2.1.7.5.5,0,0,1-.7-.6l4.6-8.5a.5.5,0,1,1,.9.5l-3.9,7.2,1.2-.2a3.6,3.6,0,0,1,2,.6,2.8,2.8,0,0,1,3.3,0,3.5,3.5,0,0,1,1.9-.5l1.3.2L17,11.8a.5.5,0,1,1,.9-.5l4.5,8.6A.5.5,0,0,1,22.3,20.6Z"/>
-</svg>
deleted file mode 100644
index 5d3cb8ee0e226444efbfc1f9f4d912de9895fb56..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index d1c896a29277884d1f9ff8f3165bac47bf19868c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 8efdc9366d0892c500e8d8df721303dd9c567138..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 2ecd5866c930286321e19dc83895570a2e8e247d..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 932445d769fabe2c234d810970186a802a21324e..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 5fd6b8a0bca78b2d641eb2590a644f57e055ad67..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 72415ae9ac8bec7a5aa8e5cb92db90839b3b1318..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index d2dbc54d611e234da39c6ea515b4328689e5949f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001