Index: chrome/browser/extensions/extension_app_api.h |
diff --git a/chrome/browser/extensions/extension_app_api.h b/chrome/browser/extensions/extension_app_api.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ec16927b0d79e5ca6ca3b635c1e56335a3d016ef |
--- /dev/null |
+++ b/chrome/browser/extensions/extension_app_api.h |
@@ -0,0 +1,70 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ |
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ |
+#pragma once |
+ |
+#include "chrome/browser/extensions/extension_function.h" |
+ |
+#include <map> |
+#include <vector> |
+ |
+#include "base/memory/linked_ptr.h" |
+#include "content/common/notification_observer.h" |
+#include "content/common/notification_registrar.h" |
+#include "third_party/skia/include/core/SkBitmap.h" |
+ |
+ |
+struct AppNotification { |
+ std::string extension_id; |
+ std::string title; |
+ std::string body; |
+ GURL linkUrl; |
+ std::string linkText; |
+ SkBitmap icon; |
+}; |
+ |
+typedef std::vector<linked_ptr<AppNotification> > AppNotificationList; |
+ |
+// This class keeps track of notifications for installed apps. |
+class AppNotificationManager : public NotificationObserver { |
+ public: |
+ AppNotificationManager(); |
+ virtual ~AppNotificationManager(); |
+ |
+ // Takes ownership of |notification|. |
+ void Add(AppNotification* item); |
+ |
+ const AppNotificationList* GetAll(const std::string& extension_id); |
+ |
+ // Clears all notifications for |extension_id|. |
+ void ClearAll(const std::string& extension_id); |
+ |
+ // Implementing NotificationObserver interface. |
+ void Observe(NotificationType type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details) OVERRIDE; |
+ |
+ private: |
+ NotificationRegistrar registrar_; |
Finnur
2011/06/20 12:21:46
Maybe have this member at the bottom, since techni
asargent_no_longer_on_chrome
2011/06/21 18:10:11
Done.
|
+ |
+ // Maps extension id to a list of notifications for that extension. |
+ typedef std::map<std::string, AppNotificationList> NotificationMap; |
+ NotificationMap items_; |
+}; |
Finnur
2011/06/20 12:21:46
No DISALLOW_DR_EVIL_CONSTRUCTORS(AppNotificationMa
asargent_no_longer_on_chrome
2011/06/21 18:10:11
Done.
|
+ |
+class AppNotifyFunction : public SyncExtensionFunction { |
+ ~AppNotifyFunction() {} |
+ virtual bool RunImpl(); |
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.notify"); |
+}; |
+ |
+class AppClearAllNotificationsFunction : public SyncExtensionFunction { |
+ ~AppClearAllNotificationsFunction() {} |
+ virtual bool RunImpl(); |
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.clearAllNotifications"); |
+}; |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ |