| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 const AppNotificationList* GetAll(const std::string& extension_id); | 43 const AppNotificationList* GetAll(const std::string& extension_id); |
| 44 | 44 |
| 45 // Returns the most recently added notification for |extension_id| if there | 45 // Returns the most recently added notification for |extension_id| if there |
| 46 // are any, or NULL otherwise. | 46 // are any, or NULL otherwise. |
| 47 const AppNotification* GetLast(const std::string& extension_id); | 47 const AppNotification* GetLast(const std::string& extension_id); |
| 48 | 48 |
| 49 // Clears all notifications for |extension_id|. | 49 // Clears all notifications for |extension_id|. |
| 50 void ClearAll(const std::string& extension_id); | 50 void ClearAll(const std::string& extension_id); |
| 51 | 51 |
| 52 // Implementing NotificationObserver interface. | 52 // Implementing NotificationObserver interface. |
| 53 virtual void Observe(NotificationType type, | 53 virtual void Observe(int type, |
| 54 const NotificationSource& source, | 54 const NotificationSource& source, |
| 55 const NotificationDetails& details) OVERRIDE; | 55 const NotificationDetails& details) OVERRIDE; |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 // Maps extension id to a list of notifications for that extension. | 58 // Maps extension id to a list of notifications for that extension. |
| 59 typedef std::map<std::string, AppNotificationList> NotificationMap; | 59 typedef std::map<std::string, AppNotificationList> NotificationMap; |
| 60 | 60 |
| 61 NotificationRegistrar registrar_; | 61 NotificationRegistrar registrar_; |
| 62 NotificationMap notifications_; | 62 NotificationMap notifications_; |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(AppNotificationManager); | 64 DISALLOW_COPY_AND_ASSIGN(AppNotificationManager); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 class AppNotifyFunction : public SyncExtensionFunction { | 67 class AppNotifyFunction : public SyncExtensionFunction { |
| 68 virtual ~AppNotifyFunction() {} | 68 virtual ~AppNotifyFunction() {} |
| 69 virtual bool RunImpl(); | 69 virtual bool RunImpl(); |
| 70 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.notify"); | 70 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.notify"); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 class AppClearAllNotificationsFunction : public SyncExtensionFunction { | 73 class AppClearAllNotificationsFunction : public SyncExtensionFunction { |
| 74 virtual ~AppClearAllNotificationsFunction() {} | 74 virtual ~AppClearAllNotificationsFunction() {} |
| 75 virtual bool RunImpl(); | 75 virtual bool RunImpl(); |
| 76 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.clearAllNotifications"); | 76 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.clearAllNotifications"); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ | 79 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ |
| OLD | NEW |