Skip to content
This repository was archived by the owner on Dec 1, 2017. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions add-on/chrome/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
"resource:///modules/CustomizableUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AboutLoop",
"chrome://loop/content/modules/AboutLoop.jsm");

// See LOG_LEVELS in Console.jsm. Common examples: "All", "Info", "Warn", & "Error".
const PREF_LOG_LEVEL = "loop.debug.loglevel";
Expand Down Expand Up @@ -347,6 +349,41 @@ var WindowListener = {

this.maybeAddCopyPanel();
this.updateToolbarState();

this.addSidebar();
},

/* XXX akita make this into it's own object. */
addSidebar: function() {
let ownerDocument = gBrowser.ownerDocument;
var browser = ownerDocument.getElementById("browser");

let sidebarBrowser = document.createElementNS(kNSXUL, "browser");
sidebarBrowser.setAttribute("id", "loop-side-browser");
sidebarBrowser.setAttribute("disable-history", "true");
sidebarBrowser.setAttribute("disable-global-history", "true");

// XXX akita something like these seem likely to be required once we
// electrolyze this along with a URI_MUST_LOAD_IN_CHILD in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sidebar is already URI_MUST_LOAD_IN_CHILD. I think this probably doesn't apply, however, lets change the XXX to XXX akita and verify it before too much longer.

Actually I think having the must load in child forces it into a remote browser, but specifying the browser element remote by default optimises the process.

So just update the XXX for now please.

// AboutLoop.jsm
// sidebarBrowser.setAttribute("message-manager-group", "social");
// sidebarBrowser.setAttribute("message", "true");
// sidebarBrowser.setAttribute("remote", "true");

sidebarBrowser.setAttribute("type", "content");

this.sidebar = sidebarBrowser;
this.sidebar.width = 250;

browser.appendChild(sidebarBrowser);
},

loadSidebar: function(token) {
log.info("loadSidebar called:", token, this.sidebar);
let url = "about:loopconversation#" + token;
Services.perms.add(Services.io.newURI(url, null, null), "camera",
Services.perms.ALLOW_ACTION, Services.perms.EXPIRE_SESSION);
this.sidebar.setAttribute("src", url);
},

/**
Expand Down Expand Up @@ -1360,6 +1397,11 @@ function startup(data) {
return;
}

// register about: handlers
AboutLoop.conversation.register(); // eslint-disable-line no-undef
AboutLoop.panel.register(); // eslint-disable-line no-undef
AboutLoop.toc.register(); // eslint-disable-line no-undef

createLoopButton();

// Attach to hidden window (for OS X).
Expand Down Expand Up @@ -1431,6 +1473,11 @@ function shutdown(data, reason) {
// Stop waiting for browser windows to open.
wm.removeListener(WindowListener);

// unregister about: handlers
AboutLoop.conversation.unregister(); // eslint-disable-line no-undef
AboutLoop.panel.unregister(); // eslint-disable-line no-undef
AboutLoop.toc.unregister(); // eslint-disable-line no-undef
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think this was mentioned in Mark's original review comments. Do we still need to go through and address his original comments now that we've unforked?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see the comment you're talking about

#329

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @dmose is thinking about the comments on #360. I'm happy for those comments to be addressed separately there, landed on master, and then de-forked when merging to akita.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I got confused; never mind!


// If the app is shutting down, don't worry about cleaning up, just let
// it fade away...
if (reason == APP_SHUTDOWN) {
Expand Down
114 changes: 114 additions & 0 deletions add-on/chrome/modules/AboutLoop.jsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/* 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";

/* Basic code borrowed and adapted from PocketAbout stuff in mozilla-central
*/

const { interfaces: Ci, results: Cr, manager: Cm, utils: Cu } = Components;

Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");

// See LOG_LEVELS in Console.jsm. Common examples: "All", "Info", "Warn", & "Error".
const PREF_LOG_LEVEL = "loop.debug.loglevel";

XPCOMUtils.defineLazyGetter(this, "log", () => {
let ConsoleAPI = Cu.import("resource://gre/modules/Console.jsm", {}).ConsoleAPI;
let consoleOptions = {
maxLogLevelPref: PREF_LOG_LEVEL,
prefix: "Loop"
};
return new ConsoleAPI(consoleOptions);
});


function AboutPage(chromeURL, aboutHost, classID, description, uriFlags) {
this.chromeURL = chromeURL;
this.aboutHost = aboutHost;
this.classID = Components.ID(classID);
this.description = description;
this.uriFlags = uriFlags;
}

AboutPage.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
getURIFlags: function(aURI) { // eslint-disable-line no-unused-vars
return this.uriFlags;
},

newChannel: function(aURI, aLoadInfo) {
let newURI = Services.io.newURI(this.chromeURL, null, null);
let channel = Services.io.newChannelFromURIWithLoadInfo(newURI,
aLoadInfo);
channel.originalURI = aURI;

if (this.uriFlags & Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT) {
let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(aURI);
channel.owner = principal;
}
return channel;
},

createInstance: function(outer, iid) {
if (outer != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return this.QueryInterface(iid);
},

register: function() {
Cm.QueryInterface(Ci.nsIComponentRegistrar).registerFactory(
this.classID, this.description,
"@mozilla.org/network/protocol/about;1?what=" + this.aboutHost, this);
},

unregister: function() {
Cm.QueryInterface(Ci.nsIComponentRegistrar).unregisterFactory(
this.classID, this);
}
};

/* exported AboutLoop */
var AboutLoop = {};

// Note that about:loopconversation and about:looppanel are used in some
// checks in mozilla-central (eg getUserMedia-related), so if we want to
// make changes to the URL names themselves, we'll need to change them
// there too...
XPCOMUtils.defineLazyGetter(AboutLoop, "conversation", () => {
return new AboutPage("chrome://loop/content/panels/sidebar.html",
"loopconversation",
"E79DB45D-2D6D-48BE-B179-6A16C95E97BA",
"About Loop Conversation",
Ci.nsIAboutModule.ALLOW_SCRIPT |
Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT |
Ci.nsIAboutModule.MAKE_UNLINKABLE |
Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT |
Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD);
});

XPCOMUtils.defineLazyGetter(AboutLoop, "panel", () => {
return new AboutPage("chrome://loop/content/panels/panel.html",
"looppanel",
"A5DE152B-DE58-42BC-A68C-33E00B17EC2C",
"About Loop Panel",
Ci.nsIAboutModule.ALLOW_SCRIPT |
Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT |
Ci.nsIAboutModule.MAKE_UNLINKABLE |
Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT);
});

XPCOMUtils.defineLazyGetter(AboutLoop, "toc", () => {
return new AboutPage("chrome://loop/content/panels/toc.html",
"looptoc",
"A1220CE0-E5D1-45B6-BEBA-3706166A2AA4",
"About Loop ToC",
Ci.nsIAboutModule.ALLOW_SCRIPT |
Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT |
Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT |
Ci.nsIAboutModule.MAKE_UNLINKABLE); // XXX akita-sidebar load in child?
});

this.EXPORTED_SYMBOLS = ["AboutLoop"];
8 changes: 8 additions & 0 deletions add-on/chrome/modules/MozLoopAPI.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ const kMessageHandlers = {
reply();
},

LoadSidebar: function(message, reply) {
let win = Services.wm.getMostRecentWindow("navigator:browser");
let [roomToken] = message.data;
win.LoopUI.loadSidebar(roomToken);
reply();
},

/**
* Creates a layout for the remote cursor on the browser chrome,
* and positions it on the received coordinates.
Expand Down Expand Up @@ -1171,6 +1178,7 @@ const LoopAPIInternal = {

gPageListeners = [new RemotePages("about:looppanel"),
new RemotePages("about:loopconversation"),
new RemotePages("about:looptoc"),
// Slideshow added here to expose the loop api to make L10n work.
// XXX Can remove once slideshow is made remote.
new RemotePages("chrome://loop/content/panels/slideshow.html")];
Expand Down
Loading