summaryrefslogtreecommitdiffstats
path: root/mobile/android/chrome/content/Feedback.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /mobile/android/chrome/content/Feedback.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'mobile/android/chrome/content/Feedback.js')
-rw-r--r--mobile/android/chrome/content/Feedback.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/mobile/android/chrome/content/Feedback.js b/mobile/android/chrome/content/Feedback.js
new file mode 100644
index 000000000..8727c46c3
--- /dev/null
+++ b/mobile/android/chrome/content/Feedback.js
@@ -0,0 +1,64 @@
+/* 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/. */
+"use strict";
+
+var Feedback = {
+
+ get _feedbackURL() {
+ delete this._feedbackURL;
+ return this._feedbackURL = Services.urlFormatter.formatURLPref("app.feedbackURL");
+ },
+
+ observe: function(aMessage, aTopic, aData) {
+ if (aTopic !== "Feedback:Show") {
+ return;
+ }
+
+ // Don't prompt for feedback in distribution builds.
+ try {
+ Services.prefs.getCharPref("distribution.id");
+ return;
+ } catch (e) {}
+
+ let url = this._feedbackURL;
+ let browser = BrowserApp.selectOrAddTab(url, { parentId: BrowserApp.selectedTab.id }).browser;
+
+ browser.addEventListener("FeedbackClose", this, false, true);
+ browser.addEventListener("FeedbackMaybeLater", this, false, true);
+
+ // Dispatch a custom event to the page content when feedback is prompted by the browser.
+ // This will be used by the page to determine it's being loaded directly by the browser,
+ // instead of by the user visiting the page, e.g. through browser history.
+ function loadListener(event) {
+ browser.removeEventListener("DOMContentLoaded", loadListener, false);
+ browser.contentDocument.dispatchEvent(new CustomEvent("FeedbackPrompted"));
+ }
+ browser.addEventListener("DOMContentLoaded", loadListener, false);
+ },
+
+ handleEvent: function(event) {
+ if (!this._isAllowed(event.target)) {
+ return;
+ }
+
+ switch (event.type) {
+ case "FeedbackClose":
+ // Do nothing.
+ break;
+
+ case "FeedbackMaybeLater":
+ Messaging.sendRequest({ type: "Feedback:MaybeLater" });
+ break;
+ }
+
+ let win = event.target.ownerDocument.defaultView.top;
+ BrowserApp.closeTab(BrowserApp.getTabForWindow(win));
+ },
+
+ _isAllowed: function(node) {
+ let uri = node.ownerDocument.documentURIObject;
+ let feedbackURI = Services.io.newURI(this._feedbackURL, null, null);
+ return uri.prePath === feedbackURI.prePath;
+ }
+};