Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/Notification.cpp

Issue 5068192028295168: Issue 1919 - add Notifications::GetLinks() (Closed)
Patch Set: get rid of c++11 Created Feb. 2, 2015, 2:51 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/AdblockPlus/Notification.h ('k') | test/Notification.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 const std::string& Notification::GetTitle() const 70 const std::string& Notification::GetTitle() const
71 { 71 {
72 return title; 72 return title;
73 } 73 }
74 74
75 const std::string& Notification::GetMessageString() const 75 const std::string& Notification::GetMessageString() const
76 { 76 {
77 return message; 77 return message;
78 } 78 }
79 79
80 std::vector<std::string> Notification::GetLinks() const
81 {
82 std::vector<std::string> retValue;
83 JsValuePtr jsLinks = GetProperty("links");
84 if (!jsLinks->IsArray())
85 {
86 return retValue;
87 }
88 JsValueList urlLinksList = jsLinks->AsList();
89 for (JsValueList::const_iterator linkIterator = urlLinksList.begin();
90 linkIterator != urlLinksList.end(); ++linkIterator)
91 {
92 retValue.push_back((*linkIterator)->AsString());
93 }
94 return retValue;
95 }
96
80 void Notification::MarkAsShown() 97 void Notification::MarkAsShown()
81 { 98 {
82 JsValueList params; 99 JsValueList params;
83 params.push_back(GetProperty("id")); 100 params.push_back(GetProperty("id"));
84 jsEngine->Evaluate("API.markNotificationAsShown")->Call(params); 101 jsEngine->Evaluate("API.markNotificationAsShown")->Call(params);
85 } 102 }
86 103
87 NotificationPtr Notification::JsValueToNotification(const JsValuePtr& jsValue) 104 NotificationPtr Notification::JsValueToNotification(const JsValuePtr& jsValue)
88 { 105 {
89 if (!jsValue || !jsValue->IsObject()) 106 if (!jsValue || !jsValue->IsObject())
(...skipping 14 matching lines...) Expand all
104 { 121 {
105 notification->title = jsTitle->AsString(); 122 notification->title = jsTitle->AsString();
106 } 123 }
107 JsValuePtr jsMessage = jsTexts->GetProperty("message"); 124 JsValuePtr jsMessage = jsTexts->GetProperty("message");
108 if (jsMessage->IsString()) 125 if (jsMessage->IsString())
109 { 126 {
110 notification->message = jsMessage->AsString(); 127 notification->message = jsMessage->AsString();
111 } 128 }
112 return notification; 129 return notification;
113 } 130 }
OLDNEW
« no previous file with comments | « include/AdblockPlus/Notification.h ('k') | test/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld