Skip to content

Commit

Permalink
Merge actual fx-team (previous merge push was a mislabeled inbound me…
Browse files Browse the repository at this point in the history
…rge) to m-c a=merge
  • Loading branch information
KWierso committed Nov 20, 2014
2 parents a999777 + 4067b23 commit c86c586
Show file tree
Hide file tree
Showing 85 changed files with 1,381 additions and 568 deletions.
13 changes: 12 additions & 1 deletion browser/components/loop/LoopRooms.jsm
Expand Up @@ -6,6 +6,7 @@
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const {MozLoopService, LOOP_SESSION_TYPE} = Cu.import("resource:///modules/loop/MozLoopService.jsm", {});
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
Expand All @@ -15,6 +16,9 @@ XPCOMUtils.defineLazyGetter(this, "eventEmitter", function() {
const {EventEmitter} = Cu.import("resource://gre/modules/devtools/event-emitter.js", {});
return new EventEmitter();
});
XPCOMUtils.defineLazyGetter(this, "gLoopBundle", function() {
return Services.strings.createBundle('chrome://browser/locale/loop/loop.properties');
});

this.EXPORTED_SYMBOLS = ["LoopRooms", "roomsPushNotification"];

Expand Down Expand Up @@ -327,9 +331,16 @@ let LoopRoomsInternal = {
* `Error` object or `null`.
*/
join: function(roomToken, callback) {
let displayName;
if (MozLoopService.userProfile && MozLoopService.userProfile.email) {
displayName = MozLoopService.userProfile.email;
} else {
displayName = gLoopBundle.GetStringFromName("display_name_guest");
}

this._postToRoom(roomToken, {
action: "join",
displayName: MozLoopService.userProfile.email,
displayName: displayName,
clientMaxSize: CLIENT_MAX_SIZE
}, callback);
},
Expand Down
68 changes: 17 additions & 51 deletions browser/components/loop/MozLoopAPI.jsm
Expand Up @@ -414,78 +414,41 @@ function injectLoopAPI(targetWindow) {
},

/**
* Set any character preference under "loop."
* Set any preference under "loop."
*
* @param {String} prefName The name of the pref without the preceding "loop."
* @param {String} stringValue The value to set.
* @param {*} value The value to set.
* @param {Enum} prefType Type of preference, defined at Ci.nsIPrefBranch. Optional.
*
* Any errors thrown by the Mozilla pref API are logged to the console
* and cause false to be returned.
*/
setLoopCharPref: {
setLoopPref: {
enumerable: true,
writable: true,
value: function(prefName, value) {
MozLoopService.setLoopCharPref(prefName, value);
value: function(prefName, value, prefType) {
MozLoopService.setLoopPref(prefName, value, prefType);
}
},

/**
* Return any preference under "loop." that's coercible to a character
* preference.
* Return any preference under "loop.".
*
* @param {String} prefName The name of the pref without the preceding
* "loop."
* @param {Enum} prefType Type of preference, defined at Ci.nsIPrefBranch. Optional.
*
* Any errors thrown by the Mozilla pref API are logged to the console
* and cause null to be returned. This includes the case of the preference
* not being found.
*
* @return {String} on success, null on error
* @return {*} on success, null on error
*/
getLoopCharPref: {
getLoopPref: {
enumerable: true,
writable: true,
value: function(prefName) {
return MozLoopService.getLoopCharPref(prefName);
}
},

/**
* Set any boolean preference under "loop."
*
* @param {String} prefName The name of the pref without the preceding "loop."
* @param {bool} value The value to set.
*
* Any errors thrown by the Mozilla pref API are logged to the console
* and cause false to be returned.
*/
setLoopBoolPref: {
enumerable: true,
writable: true,
value: function(prefName, value) {
MozLoopService.setLoopBoolPref(prefName, value);
}
},

/**
* Return any preference under "loop." that's coercible to a boolean
* preference.
*
* @param {String} prefName The name of the pref without the preceding
* "loop."
*
* Any errors thrown by the Mozilla pref API are logged to the console
* and cause null to be returned. This includes the case of the preference
* not being found.
*
* @return {String} on success, null on error
*/
getLoopBoolPref: {
enumerable: true,
writable: true,
value: function(prefName) {
return MozLoopService.getLoopBoolPref(prefName);
value: function(prefName, prefType) {
return MozLoopService.getLoopPref(prefName);
}
},

Expand Down Expand Up @@ -615,12 +578,15 @@ function injectLoopAPI(targetWindow) {

/**
* Opens the Getting Started tour in the browser.
*
* @param {String} aSrc
* - The UI element that the user used to begin the tour, optional.
*/
openGettingStartedTour: {
enumerable: true,
writable: true,
value: function() {
return MozLoopService.openGettingStartedTour();
value: function(aSrc) {
return MozLoopService.openGettingStartedTour(aSrc);
},
},

Expand Down
111 changes: 56 additions & 55 deletions browser/components/loop/MozLoopService.jsm
Expand Up @@ -1220,80 +1220,75 @@ this.MozLoopService = {
},

/**
* Set any character preference under "loop.".
* Set any preference under "loop.".
*
* @param {String} prefName The name of the pref without the preceding "loop."
* @param {String} value The value to set.
* @param {String} prefSuffix The name of the pref without the preceding "loop."
* @param {*} value The value to set.
* @param {Enum} prefType Type of preference, defined at Ci.nsIPrefBranch. Optional.
*
* Any errors thrown by the Mozilla pref API are logged to the console.
*/
setLoopCharPref: function(prefName, value) {
setLoopPref: function(prefSuffix, value, prefType) {
let prefName = "loop." + prefSuffix;
try {
Services.prefs.setCharPref("loop." + prefName, value);
} catch (ex) {
log.error("setLoopCharPref had trouble setting " + prefName +
"; exception: " + ex);
}
},

/**
* Return any preference under "loop." that's coercible to a character
* preference.
*
* @param {String} prefName The name of the pref without the preceding
* "loop."
*
* Any errors thrown by the Mozilla pref API are logged to the console
* and cause null to be returned. This includes the case of the preference
* not being found.
*
* @return {String} on success, null on error
*/
getLoopCharPref: function(prefName) {
try {
return Services.prefs.getCharPref("loop." + prefName);
} catch (ex) {
log.error("getLoopCharPref had trouble getting " + prefName +
"; exception: " + ex);
return null;
}
},

/**
* Set any boolean preference under "loop.".
*
* @param {String} prefName The name of the pref without the preceding "loop."
* @param {boolean} value The value to set.
*
* Any errors thrown by the Mozilla pref API are logged to the console.
*/
setLoopBoolPref: function(prefName, value) {
try {
Services.prefs.setBoolPref("loop." + prefName, value);
if (!prefType) {
prefType = Services.prefs.getPrefType(prefName);
}
switch (prefType) {
case Ci.nsIPrefBranch.PREF_STRING:
Services.prefs.setCharPref(prefName, value);
break;
case Ci.nsIPrefBranch.PREF_INT:
Services.prefs.setIntPref(prefName, value);
break;
case Ci.nsIPrefBranch.PREF_BOOL:
Services.prefs.setBoolPref(prefName, value);
break;
default:
log.error("invalid preference type setting " + prefName);
break;
}
} catch (ex) {
log.error("setLoopCharPref had trouble setting " + prefName +
log.error("setLoopPref had trouble setting " + prefName +
"; exception: " + ex);
}
},

/**
* Return any preference under "loop." that's coercible to a character
* preference.
* Return any preference under "loop.".
*
* @param {String} prefName The name of the pref without the preceding
* "loop."
* @param {Enum} prefType Type of preference, defined at Ci.nsIPrefBranch. Optional.
*
* Any errors thrown by the Mozilla pref API are logged to the console
* and cause null to be returned. This includes the case of the preference
* not being found.
*
* @return {String} on success, null on error
* @return {*} on success, null on error
*/
getLoopBoolPref: function(prefName) {
getLoopPref: function(prefSuffix, prefType) {
let prefName = "loop." + prefSuffix;
try {
return Services.prefs.getBoolPref("loop." + prefName);
if (!prefType) {
prefType = Services.prefs.getPrefType(prefName);
} else if (prefType != Services.prefs.getPrefType(prefName)) {
log.error("invalid type specified for preference");
return null;
}
switch (prefType) {
case Ci.nsIPrefBranch.PREF_STRING:
return Services.prefs.getCharPref(prefName);
case Ci.nsIPrefBranch.PREF_INT:
return Services.prefs.getIntPref(prefName);
case Ci.nsIPrefBranch.PREF_BOOL:
return Services.prefs.getBoolPref(prefName);
default:
log.error("invalid preference type getting " + prefName);
return null;
}
} catch (ex) {
log.error("getLoopBoolPref had trouble getting " + prefName +
log.error("getLoopPref had trouble getting " + prefName +
"; exception: " + ex);
return null;
}
Expand Down Expand Up @@ -1406,12 +1401,18 @@ this.MozLoopService = {

/**
* Opens the Getting Started tour in the browser.
*
* @param {String} aSrc
* - The UI element that the user used to begin the tour, optional.
*/
openGettingStartedTour: Task.async(function() {
openGettingStartedTour: Task.async(function(aSrc = null) {
try {
let url = Services.prefs.getCharPref("loop.gettingStarted.url");
let url = new URL(Services.prefs.getCharPref("loop.gettingStarted.url"));
if (aSrc) {
url.searchParams.set("source", aSrc);
}
let win = Services.wm.getMostRecentWindow("navigator:browser");
win.switchToTabHavingURI(url, true);
win.switchToTabHavingURI(url, true, {replaceQueryString: true});
} catch (ex) {
log.error("Error opening Getting Started tour", ex);
}
Expand Down
3 changes: 2 additions & 1 deletion browser/components/loop/content/conversation.html
Expand Up @@ -34,8 +34,9 @@
<script type="text/javascript" src="loop/shared/js/validate.js"></script>
<script type="text/javascript" src="loop/shared/js/dispatcher.js"></script>
<script type="text/javascript" src="loop/shared/js/otSdkDriver.js"></script>
<script type="text/javascript" src="loop/shared/js/conversationStore.js"></script>
<script type="text/javascript" src="loop/shared/js/store.js"></script>
<script type="text/javascript" src="loop/shared/js/roomStore.js"></script>
<script type="text/javascript" src="loop/shared/js/conversationStore.js"></script>
<script type="text/javascript" src="loop/shared/js/activeRoomStore.js"></script>
<script type="text/javascript" src="loop/js/conversationViews.js"></script>
<script type="text/javascript" src="loop/shared/js/websocket.js"></script>
Expand Down
14 changes: 6 additions & 8 deletions browser/components/loop/content/js/conversation.js
Expand Up @@ -298,13 +298,13 @@ loop.conversation = (function(mozL10n) {

document.title = mozL10n.get("conversation_has_ended");

var feebackAPIBaseUrl = navigator.mozLoop.getLoopCharPref(
var feebackAPIBaseUrl = navigator.mozLoop.getLoopPref(
"feedback.baseUrl");

var appVersionInfo = navigator.mozLoop.appVersionInfo;

var feedbackClient = new loop.FeedbackAPIClient(feebackAPIBaseUrl, {
product: navigator.mozLoop.getLoopCharPref("feedback.product"),
product: navigator.mozLoop.getLoopPref("feedback.product"),
platform: appVersionInfo.OS,
channel: appVersionInfo.channel,
version: appVersionInfo.version
Expand Down Expand Up @@ -616,10 +616,10 @@ loop.conversation = (function(mozL10n) {
// don't work in the conversation window
window.OT.overrideGuidStorage({
get: function(callback) {
callback(null, navigator.mozLoop.getLoopCharPref("ot.guid"));
callback(null, navigator.mozLoop.getLoopPref("ot.guid"));
},
set: function(guid, callback) {
navigator.mozLoop.setLoopCharPref("ot.guid", guid);
navigator.mozLoop.setLoopPref("ot.guid", guid);
callback(null);
}
});
Expand All @@ -641,13 +641,11 @@ loop.conversation = (function(mozL10n) {
dispatcher: dispatcher,
sdkDriver: sdkDriver
});
var activeRoomStore = new loop.store.ActiveRoomStore({
dispatcher: dispatcher,
var activeRoomStore = new loop.store.ActiveRoomStore(dispatcher, {
mozLoop: navigator.mozLoop,
sdkDriver: sdkDriver
});
var roomStore = new loop.store.RoomStore({
dispatcher: dispatcher,
var roomStore = new loop.store.RoomStore(dispatcher, {
mozLoop: navigator.mozLoop,
activeRoomStore: activeRoomStore
});
Expand Down
14 changes: 6 additions & 8 deletions browser/components/loop/content/js/conversation.jsx
Expand Up @@ -298,13 +298,13 @@ loop.conversation = (function(mozL10n) {

document.title = mozL10n.get("conversation_has_ended");

var feebackAPIBaseUrl = navigator.mozLoop.getLoopCharPref(
var feebackAPIBaseUrl = navigator.mozLoop.getLoopPref(
"feedback.baseUrl");

var appVersionInfo = navigator.mozLoop.appVersionInfo;

var feedbackClient = new loop.FeedbackAPIClient(feebackAPIBaseUrl, {
product: navigator.mozLoop.getLoopCharPref("feedback.product"),
product: navigator.mozLoop.getLoopPref("feedback.product"),
platform: appVersionInfo.OS,
channel: appVersionInfo.channel,
version: appVersionInfo.version
Expand Down Expand Up @@ -616,10 +616,10 @@ loop.conversation = (function(mozL10n) {
// don't work in the conversation window
window.OT.overrideGuidStorage({
get: function(callback) {
callback(null, navigator.mozLoop.getLoopCharPref("ot.guid"));
callback(null, navigator.mozLoop.getLoopPref("ot.guid"));
},
set: function(guid, callback) {
navigator.mozLoop.setLoopCharPref("ot.guid", guid);
navigator.mozLoop.setLoopPref("ot.guid", guid);
callback(null);
}
});
Expand All @@ -641,13 +641,11 @@ loop.conversation = (function(mozL10n) {
dispatcher: dispatcher,
sdkDriver: sdkDriver
});
var activeRoomStore = new loop.store.ActiveRoomStore({
dispatcher: dispatcher,
var activeRoomStore = new loop.store.ActiveRoomStore(dispatcher, {
mozLoop: navigator.mozLoop,
sdkDriver: sdkDriver
});
var roomStore = new loop.store.RoomStore({
dispatcher: dispatcher,
var roomStore = new loop.store.RoomStore(dispatcher, {
mozLoop: navigator.mozLoop,
activeRoomStore: activeRoomStore
});
Expand Down

0 comments on commit c86c586

Please sign in to comment.