Bug 915002: Convert optional notification arguments to webidl dictionary, add directional/lang arguments; r=bz r=fabrice

This commit is contained in:
Kyle Machulis 2013-10-10 15:02:45 -07:00
Родитель 93db88daa6
Коммит f0e643f07e
10 изменённых файлов: 67 добавлений и 30 удалений

Просмотреть файл

@ -18,4 +18,4 @@
# Modifying this file will now automatically clobber the buildbot machines \o/
#
Bug 899574 needed a clobber, at least on Windows.
Bug 915002 - Clobber needed for webidl updates for AppNotificationServiceOptions

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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',