Update notification PR as per feedback

This commit is contained in:
Samuel Attard 2017-06-28 17:00:19 +10:00
parent 7eb14243eb
commit 3774482859
4 changed files with 9 additions and 9 deletions

View file

@ -126,7 +126,7 @@ void Notification::SetHasReply(bool new_has_reply) {
}
void Notification::SetActions(
const std::vector<brightray::NotificationAction> actions) {
const std::vector<brightray::NotificationAction>& actions) {
actions_ = actions;
}

View file

@ -60,7 +60,7 @@ class Notification : public mate::TrackableObject<Notification>,
void SetSilent(bool new_silent);
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
void SetHasReply(bool new_has_reply);
void SetActions(const std::vector<brightray::NotificationAction> actions);
void SetActions(const std::vector<brightray::NotificationAction>& actions);
private:
base::string16 title_;

View file

@ -33,7 +33,7 @@ class CocoaNotification : public Notification {
private:
base::scoped_nsobject<NSUserNotification> notification_;
int actionIndex_;
int action_index_;
DISALLOW_COPY_AND_ASSIGN(CocoaNotification);
};

View file

@ -44,14 +44,14 @@ void CocoaNotification::Show(const NotificationOptions& options) {
[notification_ setHasActionButton:false];
for (size_t i = 0; i < options.actions.size(); i++) {
NotificationAction action = options.actions[i];
if (action.type == base::UTF8ToUTF16("button")) {
int i = 0;
for (const auto& action : options.actions) {
if (action.type == base::ASCIIToUTF16("button")) {
[notification_ setHasActionButton:true];
[notification_ setActionButtonTitle:base::SysUTF16ToNSString(action.text)];
actionIndex_ = i;
action_index_ = i;
}
i++;
}
if (options.has_reply) {
@ -82,7 +82,7 @@ void CocoaNotification::NotificationReplied(const std::string& reply) {
void CocoaNotification::NotificationButtonClicked() {
if (delegate())
delegate()->NotificationAction(actionIndex_);
delegate()->NotificationAction(action_index_);
}
} // namespace brightray