Bug 1022193 - Add a "forceIdSelection" to navigator.getMobileIdAssertion. Part 2: DOM. r=sicking

This commit is contained in:
Fernando Jiménez 2014-06-27 01:18:21 +02:00
parent a6dcf570c5
commit bbb3d1581c
4 changed files with 27 additions and 8 deletions

View File

@ -1591,7 +1591,8 @@ Navigator::GetMozTelephony(ErrorResult& aRv)
#ifdef MOZ_B2G
already_AddRefed<Promise>
Navigator::GetMobileIdAssertion(ErrorResult& aRv)
Navigator::GetMobileIdAssertion(const MobileIdOptions& aOptions,
ErrorResult& aRv)
{
if (!mWindow || !mWindow->GetDocShell()) {
aRv.Throw(NS_ERROR_UNEXPECTED);
@ -1605,8 +1606,22 @@ Navigator::GetMobileIdAssertion(ErrorResult& aRv)
return nullptr;
}
JSContext *cx = nsContentUtils::GetCurrentJSContext();
if (!cx) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
JS::Rooted<JS::Value> optionsValue(cx);
if (!ToJSValue(cx, aOptions, &optionsValue)) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsCOMPtr<nsISupports> promise;
aRv = service->GetMobileIdAssertion(mWindow, getter_AddRefs(promise));
aRv = service->GetMobileIdAssertion(mWindow,
optionsValue,
getter_AddRefs(promise));
nsRefPtr<Promise> p = static_cast<Promise*>(promise.get());
return p.forget();

View File

@ -35,6 +35,7 @@ class systemMessageCallback;
struct MediaStreamConstraints;
class WakeLock;
class ArrayBufferViewOrBlobOrStringOrFormData;
struct MobileIdOptions;
}
}
@ -214,14 +215,15 @@ public:
ErrorResult& aRv);
bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv);
#ifdef MOZ_B2G
already_AddRefed<Promise> GetMobileIdAssertion(ErrorResult& aRv);
already_AddRefed<Promise> GetMobileIdAssertion(const MobileIdOptions& options,
ErrorResult& aRv);
#endif
#ifdef MOZ_B2G_RIL
MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv);
CellBroadcast* GetMozCellBroadcast(ErrorResult& aRv);
Voicemail* GetMozVoicemail(ErrorResult& aRv);
IccManager* GetMozIccManager(ErrorResult& aRv);
#endif // MOZ_B2G_RILi
#endif // MOZ_B2G_RIL
#ifdef MOZ_GAMEPAD
void GetGamepads(nsTArray<nsRefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
#endif // MOZ_GAMEPAD

View File

@ -6,8 +6,9 @@
interface nsIDOMWindow;
[scriptable, uuid(376d3a43-a7f2-4ac0-b196-d83acb3a68cc)]
[scriptable, uuid(2dff5d37-d39d-4a7b-9bad-c108712c8a91)]
interface nsIMobileIdentityService : nsISupports
{
nsISupports getMobileIdAssertion(in nsIDOMWindow window);
nsISupports getMobileIdAssertion(in nsIDOMWindow window,
in jsval options);
};

View File

@ -31,7 +31,7 @@ MobileIdentityService.prototype = {
// TODO: this should be handled by DOMRequestIpcHelper. Bug 1020582
_windows: {},
getMobileIdAssertion: function(aWindow) {
getMobileIdAssertion: function(aWindow, aOptions) {
log.debug("getMobileIdAssertion");
if (!this.init) {
@ -49,7 +49,8 @@ MobileIdentityService.prototype = {
this._windows[promiseId] = aWindow;
cpmm.sendAsyncMessage("MobileId:GetAssertion", {
promiseId: promiseId
promiseId: promiseId,
options: aOptions
}, null, aWindow.document.nodePrincipal);
}
);