Update notification PR as per feedback
This commit is contained in:
parent
7eb14243eb
commit
3774482859
4 changed files with 9 additions and 9 deletions
|
@ -126,7 +126,7 @@ void Notification::SetHasReply(bool new_has_reply) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notification::SetActions(
|
void Notification::SetActions(
|
||||||
const std::vector<brightray::NotificationAction> actions) {
|
const std::vector<brightray::NotificationAction>& actions) {
|
||||||
actions_ = actions;
|
actions_ = actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
||||||
void SetSilent(bool new_silent);
|
void SetSilent(bool new_silent);
|
||||||
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
|
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
|
||||||
void SetHasReply(bool new_has_reply);
|
void SetHasReply(bool new_has_reply);
|
||||||
void SetActions(const std::vector<brightray::NotificationAction> actions);
|
void SetActions(const std::vector<brightray::NotificationAction>& actions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
base::string16 title_;
|
base::string16 title_;
|
||||||
|
|
|
@ -33,7 +33,7 @@ class CocoaNotification : public Notification {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
base::scoped_nsobject<NSUserNotification> notification_;
|
base::scoped_nsobject<NSUserNotification> notification_;
|
||||||
int actionIndex_;
|
int action_index_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CocoaNotification);
|
DISALLOW_COPY_AND_ASSIGN(CocoaNotification);
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,14 +44,14 @@ void CocoaNotification::Show(const NotificationOptions& options) {
|
||||||
|
|
||||||
[notification_ setHasActionButton:false];
|
[notification_ setHasActionButton:false];
|
||||||
|
|
||||||
for (size_t i = 0; i < options.actions.size(); i++) {
|
int i = 0;
|
||||||
NotificationAction action = options.actions[i];
|
for (const auto& action : options.actions) {
|
||||||
|
if (action.type == base::ASCIIToUTF16("button")) {
|
||||||
if (action.type == base::UTF8ToUTF16("button")) {
|
|
||||||
[notification_ setHasActionButton:true];
|
[notification_ setHasActionButton:true];
|
||||||
[notification_ setActionButtonTitle:base::SysUTF16ToNSString(action.text)];
|
[notification_ setActionButtonTitle:base::SysUTF16ToNSString(action.text)];
|
||||||
actionIndex_ = i;
|
action_index_ = i;
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.has_reply) {
|
if (options.has_reply) {
|
||||||
|
@ -82,7 +82,7 @@ void CocoaNotification::NotificationReplied(const std::string& reply) {
|
||||||
|
|
||||||
void CocoaNotification::NotificationButtonClicked() {
|
void CocoaNotification::NotificationButtonClicked() {
|
||||||
if (delegate())
|
if (delegate())
|
||||||
delegate()->NotificationAction(actionIndex_);
|
delegate()->NotificationAction(action_index_);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
Loading…
Add table
Reference in a new issue