summaryrefslogtreecommitdiff
path: root/mobile/android/chrome/content/PresentationView.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/PresentationView.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloaduxp-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
Add m-esr52 at 52.6.0
Diffstat (limited to 'mobile/android/chrome/content/PresentationView.js')
-rw-r--r--mobile/android/chrome/content/PresentationView.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/mobile/android/chrome/content/PresentationView.js b/mobile/android/chrome/content/PresentationView.js
new file mode 100644
index 0000000000..4f7e02870c
--- /dev/null
+++ b/mobile/android/chrome/content/PresentationView.js
@@ -0,0 +1,63 @@
+/* -*- Mode: tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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";
+
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+
+const TOPIC_PRESENTATION_VIEW_READY = "presentation-view-ready";
+const TOPIC_PRESENTATION_RECEIVER_LAUNCH = "presentation-receiver:launch";
+const TOPIC_PRESENTATION_RECEIVER_LAUNCH_RESPONSE = "presentation-receiver:launch:response";
+
+// globals Services
+Cu.import("resource://gre/modules/Services.jsm");
+
+function log(str) {
+ // dump("-*- PresentationView.js -*-: " + str + "\n");
+}
+
+let PresentationView = {
+ _id: null,
+
+ startup: function startup() {
+ // use hash as the ID of this top level window
+ this._id = window.location.hash.substr(1);
+
+ // Listen "presentation-receiver:launch" sent from
+ // PresentationRequestUIGlue.
+ Services.obs.addObserver(this,TOPIC_PRESENTATION_RECEIVER_LAUNCH, false);
+
+ // Notify PresentationView is ready.
+ Services.obs.notifyObservers(null, TOPIC_PRESENTATION_VIEW_READY, this._id);
+ },
+
+ stop: function stop() {
+ Services.obs.removeObserver(this, TOPIC_PRESENTATION_RECEIVER_LAUNCH);
+ },
+
+ observe: function observe(aSubject, aTopic, aData) {
+ log("Got observe: aTopic=" + aTopic);
+
+ let requestData = JSON.parse(aData);
+ if (this._id != requestData.windowId) {
+ return;
+ }
+
+ let browser = document.getElementById("content");
+ browser.setAttribute("mozpresentation", requestData.url);
+ try {
+ browser.loadURI(requestData.url);
+ Services.obs.notifyObservers(browser,
+ TOPIC_PRESENTATION_RECEIVER_LAUNCH_RESPONSE,
+ JSON.stringify({ result: "success",
+ requestId: requestData.requestId }));
+ } catch (e) {
+ Services.obs.notifyObservers(null,
+ TOPIC_PRESENTATION_RECEIVER_LAUNCH_RESPONSE,
+ JSON.stringify({ result: "error",
+ reason: e.message }));
+ }
+ }
+};