mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1208295
- Show an additional action on OS X notifications to open notification settings. r=mstange
--HG-- extra : commitid : 1LMiMvjWhST extra : rebase_source : ae556b8e132e43b52eae947455eda288e53660a1
This commit is contained in:
parent
9736cd824c
commit
d3537d6383
@ -9,3 +9,4 @@ closeButton.title = Close
|
||||
# LOCALIZATION NOTE(actionButton.label): Used as the button label to provide more actions on OS X notifications. OS X will truncate this if it's too long.
|
||||
actionButton.label = …
|
||||
webActions.disable.label = Disable notifications from this site
|
||||
webActions.settings.label = Notification settings
|
||||
|
@ -139,7 +139,8 @@ enum {
|
||||
namespace mozilla {
|
||||
|
||||
enum {
|
||||
OSXNotificationActionDisable = 0
|
||||
OSXNotificationActionDisable = 0,
|
||||
OSXNotificationActionSettings = 1,
|
||||
};
|
||||
|
||||
class OSXNotificationInfo {
|
||||
@ -253,13 +254,15 @@ OSXNotificationCenter::ShowAlertNotification(const nsAString & aImageUrl, const
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
nsresult rv = sbs->CreateBundle("chrome://alerts/locale/alert.properties", getter_AddRefs(bundle));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsXPIDLString closeButtonTitle, actionButtonTitle, disableButtonTitle;
|
||||
nsXPIDLString closeButtonTitle, actionButtonTitle, disableButtonTitle, settingsButtonTitle;
|
||||
bundle->GetStringFromName(NS_LITERAL_STRING("closeButton.title").get(),
|
||||
getter_Copies(closeButtonTitle));
|
||||
bundle->GetStringFromName(NS_LITERAL_STRING("actionButton.label").get(),
|
||||
getter_Copies(actionButtonTitle));
|
||||
bundle->GetStringFromName(NS_LITERAL_STRING("webActions.disable.label").get(),
|
||||
getter_Copies(disableButtonTitle));
|
||||
bundle->GetStringFromName(NS_LITERAL_STRING("webActions.settings.label").get(),
|
||||
getter_Copies(settingsButtonTitle));
|
||||
|
||||
notification.hasActionButton = YES;
|
||||
notification.otherButtonTitle = nsCocoaUtils::ToNSString(closeButtonTitle);
|
||||
@ -267,7 +270,8 @@ OSXNotificationCenter::ShowAlertNotification(const nsAString & aImageUrl, const
|
||||
[(NSObject*)notification setValue:@(YES) forKey:@"_showsButtons"];
|
||||
[(NSObject*)notification setValue:@(YES) forKey:@"_alwaysShowAlternateActionMenu"];
|
||||
[(NSObject*)notification setValue:@[
|
||||
nsCocoaUtils::ToNSString(disableButtonTitle)
|
||||
nsCocoaUtils::ToNSString(disableButtonTitle),
|
||||
nsCocoaUtils::ToNSString(settingsButtonTitle)
|
||||
]
|
||||
forKey:@"_alternateActionButtonTitles"];
|
||||
}
|
||||
@ -394,6 +398,9 @@ OSXNotificationCenter::OnActivate(NSString *aAlertName,
|
||||
case OSXNotificationActionDisable:
|
||||
osxni->mObserver->Observe(nullptr, "alertdisablecallback", osxni->mCookie.get());
|
||||
break;
|
||||
case OSXNotificationActionSettings:
|
||||
osxni->mObserver->Observe(nullptr, "alertsettingscallback", osxni->mCookie.get());
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Unknown NSUserNotification additional action clicked");
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user