mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 915002: Convert optional notification arguments to webidl dictionary, add directional/lang arguments; r=bz r=fabrice
--HG-- extra : rebase_source : 7052d11cbc5508efa7c3ae5cabe978ee62063933
This commit is contained in:
parent
fd889208b2
commit
2686b1b64b
@ -887,18 +887,20 @@ var AlertsHelper = {
|
||||
}
|
||||
|
||||
let data = aMessage.data;
|
||||
let details = data.details;
|
||||
let listener = {
|
||||
mm: aMessage.target,
|
||||
title: data.title,
|
||||
text: data.text,
|
||||
manifestURL: data.manifestURL,
|
||||
manifestURL: details.manifestURL,
|
||||
imageURL: data.imageURL
|
||||
}
|
||||
};
|
||||
this.registerAppListener(data.uid, listener);
|
||||
|
||||
this.showNotification(data.imageURL, data.title, data.text,
|
||||
data.textClickable, null,
|
||||
data.uid, null, null, data.manifestURL);
|
||||
details.textClickable, null,
|
||||
data.uid, details.dir,
|
||||
details.lang, details.manifestURL);
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -65,17 +65,16 @@ AlertsService.prototype = {
|
||||
showAppNotification: function showAppNotification(aImageURL,
|
||||
aTitle,
|
||||
aText,
|
||||
aTextClickable,
|
||||
aManifestURL,
|
||||
aAlertListener,
|
||||
aId) {
|
||||
let uid = (aId == "") ? "app-notif-" + uuidGenerator.generateUUID() : aId;
|
||||
aDetails) {
|
||||
let uid = (aDetails.id == "") ?
|
||||
"app-notif-" + uuidGenerator.generateUUID() : aDetails.id;
|
||||
|
||||
this._listeners[uid] = {
|
||||
observer: aAlertListener,
|
||||
title: aTitle,
|
||||
text: aText,
|
||||
manifestURL: aManifestURL,
|
||||
manifestURL: aDetails.manifestURL,
|
||||
imageURL: aImageURL
|
||||
};
|
||||
|
||||
@ -83,9 +82,8 @@ AlertsService.prototype = {
|
||||
imageURL: aImageURL,
|
||||
title: aTitle,
|
||||
text: aText,
|
||||
textClickable: aTextClickable,
|
||||
manifestURL: aManifestURL,
|
||||
uid: uid
|
||||
uid: uid,
|
||||
details: aDetails
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -7,14 +7,14 @@
|
||||
interface nsIObserver;
|
||||
|
||||
// Notification service that also provides the manifest URL
|
||||
[scriptable, uuid(61c4adf4-187d-4d18-937c-4df17bc01073)]
|
||||
[scriptable, uuid(50cb17d2-dc8a-4aa6-bcd3-94d76af14e20)]
|
||||
interface nsIAppNotificationService : nsISupports
|
||||
{
|
||||
void showAppNotification(in AString imageUrl,
|
||||
in AString title,
|
||||
in AString text,
|
||||
[optional] in boolean textClickable,
|
||||
[optional] in AString manifestURL,
|
||||
[optional] in nsIObserver alertListener,
|
||||
[optional] in AString id);
|
||||
in nsIObserver alertListener,
|
||||
// details should be a WebIDL
|
||||
// AppNotificationServiceOptions Dictionary object
|
||||
in jsval details);
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "mozilla/dom/DesktopNotification.h"
|
||||
#include "mozilla/dom/DesktopNotificationBinding.h"
|
||||
#include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/dom/PBrowserChild.h"
|
||||
@ -91,11 +92,18 @@ DesktopNotification::PostDesktopNotification()
|
||||
nsCOMPtr<nsIAppsService> appsService = do_GetService("@mozilla.org/AppsService;1");
|
||||
nsString manifestUrl = EmptyString();
|
||||
appsService->GetManifestURLByLocalId(appId, manifestUrl);
|
||||
mozilla::AutoSafeJSContext cx;
|
||||
JS::RootedValue val(cx);
|
||||
AppNotificationServiceOptionsInitializer ops;
|
||||
ops.mTextClickable = true;
|
||||
ops.mManifestURL = manifestUrl;
|
||||
|
||||
if (!ops.ToObject(cx, JS::NullPtr(), &val)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return appNotifier->ShowAppNotification(mIconURL, mTitle, mDescription,
|
||||
true,
|
||||
manifestUrl,
|
||||
mObserver,
|
||||
EmptyString());
|
||||
mObserver, val);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "PCOMContentPermissionRequestChild.h"
|
||||
#include "mozilla/dom/Notification.h"
|
||||
#include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
|
||||
#include "mozilla/dom/OwningNonNull.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "TabChild.h"
|
||||
@ -375,11 +376,22 @@ Notification::ShowInternal()
|
||||
nsCOMPtr<nsIAppsService> appsService = do_GetService("@mozilla.org/AppsService;1");
|
||||
nsString manifestUrl = EmptyString();
|
||||
appsService->GetManifestURLByLocalId(appId, manifestUrl);
|
||||
mozilla::AutoSafeJSContext cx;
|
||||
JS::RootedValue val(cx);
|
||||
AppNotificationServiceOptionsInitializer ops;
|
||||
ops.mTextClickable = true;
|
||||
ops.mManifestURL = manifestUrl;
|
||||
ops.mId = alertName;
|
||||
ops.mDir = DirectionToString(mDir);
|
||||
ops.mLang = mLang;
|
||||
|
||||
if (!ops.ToObject(cx, JS::NullPtr(), &val)) {
|
||||
NS_WARNING("Converting dict to object failed!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return appNotifier->ShowAppNotification(mIconUrl, mTitle, mBody,
|
||||
true,
|
||||
manifestUrl,
|
||||
observer,
|
||||
alertName);
|
||||
observer, val);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -9,7 +9,7 @@ var registrar = SpecialPowers.wrap(SpecialPowers.Components).manager.
|
||||
|
||||
var mockAlertsService = {
|
||||
showAlertNotification: function(imageUrl, title, text, textClickable,
|
||||
cookie, alertListener, name) {
|
||||
cookie, alertListener, name, bidi, lang) {
|
||||
// probably should do this async....
|
||||
SpecialPowers.wrap(alertListener).observe(null, "alertshow", cookie);
|
||||
|
||||
@ -20,9 +20,9 @@ var mockAlertsService = {
|
||||
SpecialPowers.wrap(alertListener).observe(null, "alertfinished", cookie);
|
||||
},
|
||||
|
||||
showAppNotification: function(imageUrl, title, text, textClickable,
|
||||
manifestURL, alertListener) {
|
||||
this.showAlertNotification(imageUrl, title, text, textClickable, "", alertListener, "");
|
||||
showAppNotification: function(imageUrl, title, text, alertListener, details) {
|
||||
this.showAlertNotification(imageUrl, title, text, details.textClickable, "",
|
||||
alertListener, details.name, details.dir, details.lang);
|
||||
},
|
||||
|
||||
QueryInterface: function(aIID) {
|
||||
|
15
dom/webidl/AppNotificationServiceOptions.webidl
Normal file
15
dom/webidl/AppNotificationServiceOptions.webidl
Normal file
@ -0,0 +1,15 @@
|
||||
/* -*- 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/.
|
||||
*/
|
||||
|
||||
interface MozObserver;
|
||||
|
||||
dictionary AppNotificationServiceOptions {
|
||||
boolean textClickable = false;
|
||||
DOMString manifestURL = "";
|
||||
DOMString id = "";
|
||||
DOMString dir = "";
|
||||
DOMString lang = "";
|
||||
};
|
@ -27,6 +27,7 @@ interface DummyInterface : EventTarget {
|
||||
void DOMWindowResizeEventDetail(optional DOMWindowResizeEventDetail arg);
|
||||
void WifiOptions(optional WifiCommandOptions arg1,
|
||||
optional WifiResultOptions arg2);
|
||||
void AppNotificationServiceOptions(optional AppNotificationServiceOptions arg);
|
||||
};
|
||||
|
||||
interface DummyInterfaceWorkers {
|
||||
|
@ -19,6 +19,7 @@ WEBIDL_FILES = [
|
||||
'AbstractWorker.webidl',
|
||||
'AnalyserNode.webidl',
|
||||
'AnimationEvent.webidl',
|
||||
'AppNotificationServiceOptions.webidl',
|
||||
'ArchiveReader.webidl',
|
||||
'ArchiveRequest.webidl',
|
||||
'Attr.webidl',
|
||||
|
Loading…
Reference in New Issue
Block a user