mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 915002: Convert optional notification arguments to webidl dictionary, add directional/lang arguments; r=bz r=fabrice
This commit is contained in:
parent
2e9374e556
commit
ecb0bdb67d
2
CLOBBER
2
CLOBBER
@ -18,4 +18,4 @@
|
|||||||
# Modifying this file will now automatically clobber the buildbot machines \o/
|
# Modifying this file will now automatically clobber the buildbot machines \o/
|
||||||
#
|
#
|
||||||
|
|
||||||
Bug 922461 needs a clobber to regenerate code and survive bug 925243's FAIL_ON_WARNINGS annotation.
|
Bug 915002 - Clobber needed for webidl updates for AppNotificationServiceOptions. One more time.
|
@ -887,18 +887,20 @@ var AlertsHelper = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let data = aMessage.data;
|
let data = aMessage.data;
|
||||||
|
let details = data.details;
|
||||||
let listener = {
|
let listener = {
|
||||||
mm: aMessage.target,
|
mm: aMessage.target,
|
||||||
title: data.title,
|
title: data.title,
|
||||||
text: data.text,
|
text: data.text,
|
||||||
manifestURL: data.manifestURL,
|
manifestURL: details.manifestURL,
|
||||||
imageURL: data.imageURL
|
imageURL: data.imageURL
|
||||||
}
|
};
|
||||||
this.registerAppListener(data.uid, listener);
|
this.registerAppListener(data.uid, listener);
|
||||||
|
|
||||||
this.showNotification(data.imageURL, data.title, data.text,
|
this.showNotification(data.imageURL, data.title, data.text,
|
||||||
data.textClickable, null,
|
details.textClickable, null,
|
||||||
data.uid, null, null, data.manifestURL);
|
data.uid, details.dir,
|
||||||
|
details.lang, details.manifestURL);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,17 +65,16 @@ AlertsService.prototype = {
|
|||||||
showAppNotification: function showAppNotification(aImageURL,
|
showAppNotification: function showAppNotification(aImageURL,
|
||||||
aTitle,
|
aTitle,
|
||||||
aText,
|
aText,
|
||||||
aTextClickable,
|
|
||||||
aManifestURL,
|
|
||||||
aAlertListener,
|
aAlertListener,
|
||||||
aId) {
|
aDetails) {
|
||||||
let uid = (aId == "") ? "app-notif-" + uuidGenerator.generateUUID() : aId;
|
let uid = (aDetails.id == "") ?
|
||||||
|
"app-notif-" + uuidGenerator.generateUUID() : aDetails.id;
|
||||||
|
|
||||||
this._listeners[uid] = {
|
this._listeners[uid] = {
|
||||||
observer: aAlertListener,
|
observer: aAlertListener,
|
||||||
title: aTitle,
|
title: aTitle,
|
||||||
text: aText,
|
text: aText,
|
||||||
manifestURL: aManifestURL,
|
manifestURL: aDetails.manifestURL,
|
||||||
imageURL: aImageURL
|
imageURL: aImageURL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -83,9 +82,8 @@ AlertsService.prototype = {
|
|||||||
imageURL: aImageURL,
|
imageURL: aImageURL,
|
||||||
title: aTitle,
|
title: aTitle,
|
||||||
text: aText,
|
text: aText,
|
||||||
textClickable: aTextClickable,
|
uid: uid,
|
||||||
manifestURL: aManifestURL,
|
details: aDetails
|
||||||
uid: uid
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
interface nsIObserver;
|
interface nsIObserver;
|
||||||
|
|
||||||
// Notification service that also provides the manifest URL
|
// 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
|
interface nsIAppNotificationService : nsISupports
|
||||||
{
|
{
|
||||||
void showAppNotification(in AString imageUrl,
|
void showAppNotification(in AString imageUrl,
|
||||||
in AString title,
|
in AString title,
|
||||||
in AString text,
|
in AString text,
|
||||||
[optional] in boolean textClickable,
|
in nsIObserver alertListener,
|
||||||
[optional] in AString manifestURL,
|
// details should be a WebIDL
|
||||||
[optional] in nsIObserver alertListener,
|
// AppNotificationServiceOptions Dictionary object
|
||||||
[optional] in AString id);
|
in jsval details);
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
#include "mozilla/dom/DesktopNotification.h"
|
#include "mozilla/dom/DesktopNotification.h"
|
||||||
#include "mozilla/dom/DesktopNotificationBinding.h"
|
#include "mozilla/dom/DesktopNotificationBinding.h"
|
||||||
|
#include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
|
||||||
#include "nsContentPermissionHelper.h"
|
#include "nsContentPermissionHelper.h"
|
||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
#include "mozilla/dom/PBrowserChild.h"
|
#include "mozilla/dom/PBrowserChild.h"
|
||||||
@ -91,11 +92,18 @@ DesktopNotification::PostDesktopNotification()
|
|||||||
nsCOMPtr<nsIAppsService> appsService = do_GetService("@mozilla.org/AppsService;1");
|
nsCOMPtr<nsIAppsService> appsService = do_GetService("@mozilla.org/AppsService;1");
|
||||||
nsString manifestUrl = EmptyString();
|
nsString manifestUrl = EmptyString();
|
||||||
appsService->GetManifestURLByLocalId(appId, manifestUrl);
|
appsService->GetManifestURLByLocalId(appId, manifestUrl);
|
||||||
|
mozilla::AutoSafeJSContext cx;
|
||||||
|
JS::RootedValue val(cx);
|
||||||
|
AppNotificationServiceOptions ops;
|
||||||
|
ops.mTextClickable = true;
|
||||||
|
ops.mManifestURL = manifestUrl;
|
||||||
|
|
||||||
|
if (!ops.ToObject(cx, JS::NullPtr(), &val)) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
return appNotifier->ShowAppNotification(mIconURL, mTitle, mDescription,
|
return appNotifier->ShowAppNotification(mIconURL, mTitle, mDescription,
|
||||||
true,
|
mObserver, val);
|
||||||
manifestUrl,
|
|
||||||
mObserver,
|
|
||||||
EmptyString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "PCOMContentPermissionRequestChild.h"
|
#include "PCOMContentPermissionRequestChild.h"
|
||||||
#include "mozilla/dom/Notification.h"
|
#include "mozilla/dom/Notification.h"
|
||||||
|
#include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
|
||||||
#include "mozilla/dom/OwningNonNull.h"
|
#include "mozilla/dom/OwningNonNull.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "TabChild.h"
|
#include "TabChild.h"
|
||||||
@ -375,11 +376,22 @@ Notification::ShowInternal()
|
|||||||
nsCOMPtr<nsIAppsService> appsService = do_GetService("@mozilla.org/AppsService;1");
|
nsCOMPtr<nsIAppsService> appsService = do_GetService("@mozilla.org/AppsService;1");
|
||||||
nsString manifestUrl = EmptyString();
|
nsString manifestUrl = EmptyString();
|
||||||
appsService->GetManifestURLByLocalId(appId, manifestUrl);
|
appsService->GetManifestURLByLocalId(appId, manifestUrl);
|
||||||
|
mozilla::AutoSafeJSContext cx;
|
||||||
|
JS::RootedValue val(cx);
|
||||||
|
AppNotificationServiceOptions 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,
|
return appNotifier->ShowAppNotification(mIconUrl, mTitle, mBody,
|
||||||
true,
|
observer, val);
|
||||||
manifestUrl,
|
|
||||||
observer,
|
|
||||||
alertName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,7 +9,7 @@ var registrar = SpecialPowers.wrap(SpecialPowers.Components).manager.
|
|||||||
|
|
||||||
var mockAlertsService = {
|
var mockAlertsService = {
|
||||||
showAlertNotification: function(imageUrl, title, text, textClickable,
|
showAlertNotification: function(imageUrl, title, text, textClickable,
|
||||||
cookie, alertListener, name) {
|
cookie, alertListener, name, bidi, lang) {
|
||||||
// probably should do this async....
|
// probably should do this async....
|
||||||
SpecialPowers.wrap(alertListener).observe(null, "alertshow", cookie);
|
SpecialPowers.wrap(alertListener).observe(null, "alertshow", cookie);
|
||||||
|
|
||||||
@ -20,9 +20,9 @@ var mockAlertsService = {
|
|||||||
SpecialPowers.wrap(alertListener).observe(null, "alertfinished", cookie);
|
SpecialPowers.wrap(alertListener).observe(null, "alertfinished", cookie);
|
||||||
},
|
},
|
||||||
|
|
||||||
showAppNotification: function(imageUrl, title, text, textClickable,
|
showAppNotification: function(imageUrl, title, text, alertListener, details) {
|
||||||
manifestURL, alertListener) {
|
this.showAlertNotification(imageUrl, title, text, details.textClickable, "",
|
||||||
this.showAlertNotification(imageUrl, title, text, textClickable, "", alertListener, "");
|
alertListener, details.name, details.dir, details.lang);
|
||||||
},
|
},
|
||||||
|
|
||||||
QueryInterface: function(aIID) {
|
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 DOMWindowResizeEventDetail(optional DOMWindowResizeEventDetail arg);
|
||||||
void WifiOptions(optional WifiCommandOptions arg1,
|
void WifiOptions(optional WifiCommandOptions arg1,
|
||||||
optional WifiResultOptions arg2);
|
optional WifiResultOptions arg2);
|
||||||
|
void AppNotificationServiceOptions(optional AppNotificationServiceOptions arg);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface DummyInterfaceWorkers {
|
interface DummyInterfaceWorkers {
|
||||||
|
@ -19,6 +19,7 @@ WEBIDL_FILES = [
|
|||||||
'AbstractWorker.webidl',
|
'AbstractWorker.webidl',
|
||||||
'AnalyserNode.webidl',
|
'AnalyserNode.webidl',
|
||||||
'AnimationEvent.webidl',
|
'AnimationEvent.webidl',
|
||||||
|
'AppNotificationServiceOptions.webidl',
|
||||||
'ArchiveReader.webidl',
|
'ArchiveReader.webidl',
|
||||||
'ArchiveRequest.webidl',
|
'ArchiveRequest.webidl',
|
||||||
'Attr.webidl',
|
'Attr.webidl',
|
||||||
|
Loading…
Reference in New Issue
Block a user