Backed out changeset a0b233afc099 (bug 1011084) for causing bug 1019827. a=me

This commit is contained in:
Ryan VanderMeulen 2014-06-03 15:17:04 -04:00
parent 3871fc8369
commit 2477e7e6d7
4 changed files with 96 additions and 124 deletions

View File

@ -1,6 +1,7 @@
# nsDOMIdentity.js
component {210853d9-2c97-4669-9761-b1ab9cbf57ef} nsDOMIdentity.js
contract @mozilla.org/identity/manager;1 {210853d9-2c97-4669-9761-b1ab9cbf57ef}
contract @mozilla.org/dom/identity;1 {210853d9-2c97-4669-9761-b1ab9cbf57ef}
category JavaScript-navigator-property mozId @mozilla.org/dom/identity;1
# nsIDService.js (initialization on startup)
component {4e0a0e98-b1d3-4745-a1eb-f815199dd06b} nsIDService.js

View File

@ -48,10 +48,29 @@ const ERRORS = {
"The request() method may only be invoked when handling user input",
};
function nsDOMIdentity() {
function nsDOMIdentity(aIdentityInternal) {
this._identityInternal = aIdentityInternal;
}
nsDOMIdentity.prototype = {
__exposedProps__: {
// Relying Party (RP)
watch: 'r',
request: 'r',
logout: 'r',
get: 'r',
getVerifiedEmail: 'r',
// Provisioning
beginProvisioning: 'r',
genKeyPair: 'r',
registerCertificate: 'r',
raiseProvisioningFailure: 'r',
// Authentication
beginAuthentication: 'r',
completeAuthentication: 'r',
raiseAuthenticationFailure: 'r'
},
// require native events unless syntheticEventsOk is set
get nativeEventsRequired() {
@ -130,7 +149,7 @@ nsDOMIdentity.prototype = {
// broken client to be able to call watch() any more. It's broken.
return;
}
this._mm.sendAsyncMessage("Identity:RP:Watch", message);
this._identityInternal._mm.sendAsyncMessage("Identity:RP:Watch", message);
},
request: function nsDOMIdentity_request(aOptions = {}) {
@ -200,7 +219,7 @@ nsDOMIdentity.prototype = {
}
this._rpCalls++;
this._mm.sendAsyncMessage("Identity:RP:Request", message);
this._identityInternal._mm.sendAsyncMessage("Identity:RP:Request", message);
},
logout: function nsDOMIdentity_logout() {
@ -220,7 +239,7 @@ nsDOMIdentity.prototype = {
return;
}
this._mm.sendAsyncMessage("Identity:RP:Logout", message);
this._identityInternal._mm.sendAsyncMessage("Identity:RP:Logout", message);
},
/*
@ -303,7 +322,7 @@ nsDOMIdentity.prototype = {
}
this._beginProvisioningCallback = aCallback;
this._mm.sendAsyncMessage("Identity:IDP:BeginProvisioning",
this._identityInternal._mm.sendAsyncMessage("Identity:IDP:BeginProvisioning",
this.DOMIdentityMessage());
},
@ -320,7 +339,7 @@ nsDOMIdentity.prototype = {
}
this._genKeyPairCallback = aCallback;
this._mm.sendAsyncMessage("Identity:IDP:GenKeyPair",
this._identityInternal._mm.sendAsyncMessage("Identity:IDP:GenKeyPair",
this.DOMIdentityMessage());
},
@ -336,7 +355,7 @@ nsDOMIdentity.prototype = {
let message = this.DOMIdentityMessage();
message.cert = aCertificate;
this._mm.sendAsyncMessage("Identity:IDP:RegisterCertificate", message);
this._identityInternal._mm.sendAsyncMessage("Identity:IDP:RegisterCertificate", message);
},
raiseProvisioningFailure: function nsDOMIdentity_raiseProvisioningFailure(aReason) {
@ -351,7 +370,7 @@ nsDOMIdentity.prototype = {
let message = this.DOMIdentityMessage();
message.reason = aReason;
this._mm.sendAsyncMessage("Identity:IDP:ProvisioningFailure", message);
this._identityInternal._mm.sendAsyncMessage("Identity:IDP:ProvisioningFailure", message);
},
/**
@ -371,7 +390,7 @@ nsDOMIdentity.prototype = {
}
this._beginAuthenticationCallback = aCallback;
this._mm.sendAsyncMessage("Identity:IDP:BeginAuthentication",
this._identityInternal._mm.sendAsyncMessage("Identity:IDP:BeginAuthentication",
this.DOMIdentityMessage());
},
@ -384,7 +403,7 @@ nsDOMIdentity.prototype = {
}
this._authenticationEnded = true;
this._mm.sendAsyncMessage("Identity:IDP:CompleteAuthentication",
this._identityInternal._mm.sendAsyncMessage("Identity:IDP:CompleteAuthentication",
this.DOMIdentityMessage());
},
@ -398,7 +417,27 @@ nsDOMIdentity.prototype = {
let message = this.DOMIdentityMessage();
message.reason = aReason;
this._mm.sendAsyncMessage("Identity:IDP:AuthenticationFailure", message);
this._identityInternal._mm.sendAsyncMessage("Identity:IDP:AuthenticationFailure", message);
},
// Private.
_init: function nsDOMIdentity__init(aWindow) {
this._initializeState();
// Store window and origin URI.
this._window = aWindow;
this._origin = aWindow.document.nodePrincipal.origin;
this._appStatus = aWindow.document.nodePrincipal.appStatus;
this._appId = aWindow.document.nodePrincipal.appId;
// Setup identifiers for current window.
let util = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
// We need to inherit the id from the internalIdentity service.
// See comments below in that service's init.
this._id = this._identityInternal._id;
},
/**
@ -418,18 +457,12 @@ nsDOMIdentity.prototype = {
this._beginAuthenticationCallback = null;
},
// nsIMessageListener
receiveMessage: function nsDOMIdentity_receiveMessage(aMessage) {
_receiveMessage: function nsDOMIdentity_receiveMessage(aMessage) {
let msg = aMessage.json;
// Is this message intended for this window?
if (msg.id != this._id) {
return;
}
switch (aMessage.name) {
case "Identity:ResetState":
if (!this._debug) {
if (!this._identityInternal._debug) {
return;
}
this._initializeState();
@ -505,6 +538,10 @@ nsDOMIdentity.prototype = {
}
},
_log: function nsDOMIdentity__log(msg) {
this._identityInternal._log(msg);
},
_callGenKeyPairCallback: function nsDOMIdentity__callGenKeyPairCallback(message) {
// create a pubkey object that works
let chrome_pubkey = JSON.parse(message.publicKey);
@ -605,10 +642,32 @@ nsDOMIdentity.prototype = {
return message;
},
/*
* Internal methods that are not exposed to content.
* See dom/webidl/Identity.webidl for the public interface.
*/
uninit: function DOMIdentity_uninit() {
this._log("nsDOMIdentity uninit() " + this._id);
this._identityInternal._mm.sendAsyncMessage(
"Identity:RP:Unwatch",
{ id: this._id }
);
}
};
/**
* Internal functions that shouldn't be exposed to content.
*/
function nsDOMIdentityInternal() {
}
nsDOMIdentityInternal.prototype = {
// nsIMessageListener
receiveMessage: function nsDOMIdentityInternal_receiveMessage(aMessage) {
let msg = aMessage.json;
// Is this message intended for this window?
if (msg.id != this._id) {
return;
}
this._identity._receiveMessage(aMessage);
},
// nsIObserver
observe: function nsDOMIdentityInternal_observe(aSubject, aTopic, aData) {
@ -617,10 +676,11 @@ nsDOMIdentity.prototype = {
return;
}
this.uninit();
this._identity.uninit();
Services.obs.removeObserver(this, "inner-window-destroyed");
this._initializeState();
this._identity._initializeState();
this._identity = null;
// TODO: Also send message to DOMIdentity notifiying window is no longer valid
// ie. in the case that the user closes the auth. window and we need to know.
@ -636,8 +696,7 @@ nsDOMIdentity.prototype = {
this._mm = null;
},
// Because we implement nsIDOMGlobalPropertyInitializer, our init() method
// is invoked with content window as its single argument.
// nsIDOMGlobalPropertyInitializer
init: function nsDOMIdentityInternal_init(aWindow) {
if (Services.prefs.getPrefType(PREF_ENABLED) != Ci.nsIPrefBranch.PREF_BOOL
|| !Services.prefs.getBoolPref(PREF_ENABLED)) {
@ -661,17 +720,8 @@ nsDOMIdentity.prototype = {
// nsDOMIdentity needs to know our _id, so this goes after
// its creation.
this._initializeState();
// Store window and origin URI.
this._window = aWindow;
this._origin = aWindow.document.nodePrincipal.origin;
this._appStatus = aWindow.document.nodePrincipal.appStatus;
this._appId = aWindow.document.nodePrincipal.appId;
// Setup identifiers for current window.
let util = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
this._identity = new nsDOMIdentity(this);
this._identity._init(aWindow);
this._log("init was called from " + aWindow.document.location);
@ -695,14 +745,8 @@ nsDOMIdentity.prototype = {
// Setup observers so we can remove message listeners.
Services.obs.addObserver(this, "inner-window-destroyed", false);
},
uninit: function DOMIdentity_uninit() {
this._log("nsDOMIdentity uninit() " + this._id);
this._mm.sendAsyncMessage(
"Identity:RP:Unwatch",
{ id: this._id }
);
return this._identity;
},
// Private.
@ -716,11 +760,9 @@ nsDOMIdentity.prototype = {
// Component setup.
classID: Components.ID("{210853d9-2c97-4669-9761-b1ab9cbf57ef}"),
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIMessageListener,
Ci.nsIObserver,
Ci.nsIDOMGlobalPropertyInitializer
]),
QueryInterface: XPCOMUtils.generateQI(
[Ci.nsIDOMGlobalPropertyInitializer, Ci.nsIMessageListener]
),
classInfo: XPCOMUtils.generateCI({
classID: Components.ID("{210853d9-2c97-4669-9761-b1ab9cbf57ef}"),
@ -762,4 +804,4 @@ function assertCorrectCallbacks(aOptions) {
}
}
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([nsDOMIdentity]);
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([nsDOMIdentityInternal]);

View File

@ -1,70 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*/
callback IdentityOnReadyCallback = void();
callback IdentityOnLoginCallback = void(DOMString identityAssertion);
callback IdentityOnLogoutCallback = void();
callback IdentityOnCancelCallback = void(DOMString? error);
callback IdentityOnErrorCallback = void(DOMString error);
dictionary IdentityWatchOptions {
// Required callback
IdentityOnLoginCallback onlogin;
// Optional parameters
DOMString wantIssuer;
DOMString loggedInUser;
// Optional callbacks
IdentityOnReadyCallback onready;
IdentityOnLogoutCallback onlogout;
IdentityOnErrorCallback onerror;
// Certified apps can specify this
DOMString audience;
};
dictionary IdentityRequestOptions {
// Optional parameters
long refreshAuthentication;
DOMString termsOfService;
DOMString privacyPolicy;
DOMString backgroundColor;
DOMString siteLogo;
DOMString siteName;
DOMString returnTo;
IdentityOnCancelCallback oncancel;
// Certified apps can specify this
DOMString origin;
};
dictionary IdentityGetOptions {
DOMString privacyPolicy;
DOMString termsOfService;
DOMString privacyURL;
DOMString tosURL;
DOMString siteName;
DOMString siteLogo;
};
[JSImplementation="@mozilla.org/identity/manager;1",
NoInterfaceObject,
NavigatorProperty="mozId",
Pref="dom.identity.enabled"]
interface IdentityManager {
void watch(optional IdentityWatchOptions options);
void request(optional IdentityRequestOptions options);
void logout();
[Pref="dom.identity.exposeLegacyGetAPI"]
void get(IdentityOnLoginCallback callback, optional IdentityGetOptions options);
[Pref="dom.identity.exposeLegacyGetVerifiedEmailAPI"]
void getVerifiedEmail(IdentityOnLoginCallback callback);
};

View File

@ -212,7 +212,6 @@ WEBIDL_FILES = [
'IDBRequest.webidl',
'IDBTransaction.webidl',
'IDBVersionChangeEvent.webidl',
'Identity.webidl',
'ImageData.webidl',
'ImageDocument.webidl',
'InputEvent.webidl',