OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ |
| 7 #pragma once |
| 8 |
| 9 #include "chrome/browser/extensions/extension_function.h" |
| 10 |
| 11 #include <map> |
| 12 #include <vector> |
| 13 |
| 14 #include "base/memory/linked_ptr.h" |
| 15 #include "content/common/notification_observer.h" |
| 16 #include "content/common/notification_registrar.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 |
| 19 |
| 20 struct AppNotification { |
| 21 std::string extension_id; |
| 22 std::string title; |
| 23 std::string body; |
| 24 GURL linkUrl; |
| 25 std::string linkText; |
| 26 SkBitmap icon; |
| 27 }; |
| 28 |
| 29 // A list of AppNotification's. |
| 30 typedef std::vector<linked_ptr<AppNotification> > AppNotificationList; |
| 31 |
| 32 // This class keeps track of notifications for installed apps. |
| 33 class AppNotificationManager : public NotificationObserver { |
| 34 public: |
| 35 AppNotificationManager(); |
| 36 virtual ~AppNotificationManager(); |
| 37 |
| 38 // Takes ownership of |notification|. |
| 39 void Add(AppNotification* item); |
| 40 |
| 41 const AppNotificationList* GetAll(const std::string& extension_id); |
| 42 |
| 43 // Clears all notifications for |extension_id|. |
| 44 void ClearAll(const std::string& extension_id); |
| 45 |
| 46 // Implementing NotificationObserver interface. |
| 47 void Observe(NotificationType type, |
| 48 const NotificationSource& source, |
| 49 const NotificationDetails& details) OVERRIDE; |
| 50 |
| 51 private: |
| 52 // Maps extension id to a list of notifications for that extension. |
| 53 typedef std::map<std::string, AppNotificationList> NotificationMap; |
| 54 |
| 55 NotificationRegistrar registrar_; |
| 56 NotificationMap notifications_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(AppNotificationManager); |
| 59 }; |
| 60 |
| 61 class AppNotifyFunction : public SyncExtensionFunction { |
| 62 ~AppNotifyFunction() {} |
| 63 virtual bool RunImpl(); |
| 64 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.notify"); |
| 65 }; |
| 66 |
| 67 class AppClearAllNotificationsFunction : public SyncExtensionFunction { |
| 68 ~AppClearAllNotificationsFunction() {} |
| 69 virtual bool RunImpl(); |
| 70 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.clearAllNotifications"); |
| 71 }; |
| 72 |
| 73 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ |
OLD | NEW |