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

Unified Diff: include/AdblockPlus/Notification.h

Issue 5797488346791936: Issue 1107 - Support notifications (Closed)
Patch Set: move GetNotificationTexts into Notification class Created Jan. 21, 2015, 3:54 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | lib/api.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/AdblockPlus/Notification.h
diff --git a/include/AdblockPlus/Notification.h b/include/AdblockPlus/Notification.h
new file mode 100644
index 0000000000000000000000000000000000000000..0987521e98d0f74a8671314b620f43acbd23e660
--- /dev/null
+++ b/include/AdblockPlus/Notification.h
@@ -0,0 +1,70 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2015 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ADBLOCK_PLUS_NOTIFICATION_H
+#define ADBLOCK_PLUS_NOTIFICATION_H
+
+#include <string>
+#include <vector>
+#include <memory>
+
+namespace AdblockPlus
+{
+ class FilterEngine;
+ enum NotificationType
+ {
+ NOTIFICATION_TYPE_INFORMATION = 0,
+ NOTIFICATION_TYPE_QUESTION = 1,
+ NOTIFICATION_TYPE_CRITICAL = 2
+ };
+
+ struct NotificationTexts
+ {
+ std::string title;
+ std::string message;
+ };
+
+ class Notification : public JsValue, public std::tr1::enable_shared_from_this<Notification>
+ {
+ friend class FilterEngine;
+ protected:
+ struct PrivateCtrArg{};
+ static std::tr1::shared_ptr<Notification> JsValueToNotification(const JsValuePtr& jsValue);
+ /// @param jsText is javascript object returned by getLocalizedTexts.
+ static NotificationTexts JsTextsToNotificationTexts(const JsValue& jsText);
+ public:
+ Notification(NotificationType type, const std::string& id, const JsValuePtr& jsValue, PrivateCtrArg);
+ Notification(const JsValuePtr& value, PrivateCtrArg);
+ std::string GetId() const;
+ NotificationType GetType() const;
+ /**
+ * Localizes the texts of the supplied notification.
+ * @param locale The target locale (optional, defaults to the application
+ locale)
+ * @return the translated texts.
+ */
+ NotificationTexts GetTexts(const std::string& locale = std::string());
+ void SetTitle(const std::string& value, const std::string& locale = std::string());
+ void SetMessage(const std::string& value, const std::string& locale = std::string());
+ std::vector<std::string> GetUrlFilters() const;
+ void AddUrlFilter(const std::string& value);
+ private:
+ void SetMultilingualProperty(const std::string& propertyName, const std::string& value, const std::string& locale);
+ };
+}
+
+#endif
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | lib/api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld