зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1224785, Part 2 - Show the site favicon in OS X notifications. r=mstange
MozReview-Commit-ID: L7d00xEY6Ka --HG-- extra : rebase_source : 04b35373c475fa8c212d76651f3380c316dc651c
This commit is contained in:
Родитель
f66e1ecefa
Коммит
91260d2668
|
@ -25,13 +25,15 @@ class OSXNotificationInfo;
|
|||
|
||||
class OSXNotificationCenter : public nsIAlertsService,
|
||||
public imgINotificationObserver,
|
||||
public nsITimerCallback
|
||||
public nsITimerCallback,
|
||||
public nsIAlertsIconData
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIALERTSSERVICE
|
||||
NS_DECL_IMGINOTIFICATIONOBSERVER
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
NS_DECL_NSIALERTSICONDATA
|
||||
|
||||
OSXNotificationCenter();
|
||||
|
||||
|
|
|
@ -218,7 +218,8 @@ OSXNotificationCenter::~OSXNotificationCenter()
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(OSXNotificationCenter, nsIAlertsService, imgINotificationObserver, nsITimerCallback)
|
||||
NS_IMPL_ISUPPORTS(OSXNotificationCenter, nsIAlertsService, nsITimerCallback,
|
||||
imgINotificationObserver, nsIAlertsIconData)
|
||||
|
||||
nsresult OSXNotificationCenter::Init()
|
||||
{
|
||||
|
@ -255,6 +256,15 @@ OSXNotificationCenter::ShowAlertNotification(const nsAString & aImageUrl, const
|
|||
NS_IMETHODIMP
|
||||
OSXNotificationCenter::ShowAlert(nsIAlertNotification* aAlert,
|
||||
nsIObserver* aAlertListener)
|
||||
{
|
||||
return ShowAlertWithIconData(aAlert, aAlertListener, 0, nullptr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
OSXNotificationCenter::ShowAlertWithIconData(nsIAlertNotification* aAlert,
|
||||
nsIObserver* aAlertListener,
|
||||
uint32_t aIconSize,
|
||||
const uint8_t* aIconData)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
|
@ -348,6 +358,18 @@ OSXNotificationCenter::ShowAlert(nsIAlertNotification* aAlert,
|
|||
|
||||
OSXNotificationInfo *osxni = new OSXNotificationInfo(alertName, aAlertListener, cookie);
|
||||
|
||||
// Show the favicon if supported on this version of OS X.
|
||||
if (aIconSize > 0 &&
|
||||
[notification respondsToSelector:@selector(set_identityImage:)] &&
|
||||
[notification respondsToSelector:@selector(set_identityImageHasBorder:)]) {
|
||||
|
||||
NSData *iconData = [NSData dataWithBytes:aIconData length:aIconSize];
|
||||
NSImage *icon = [[[NSImage alloc] initWithData:iconData] autorelease];
|
||||
|
||||
[(NSObject*)notification setValue:icon forKey:@"_identityImage"];
|
||||
[(NSObject*)notification setValue:@(NO) forKey:@"_identityImageHasBorder"];
|
||||
}
|
||||
|
||||
nsAutoString imageUrl;
|
||||
rv = aAlert->GetImageURL(imageUrl);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
Загрузка…
Ссылка в новой задаче