Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/browser/extensions/extension_app_api.h

Issue 7187023: Adding an experimental app notification API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: avoid rebuilding NTP apps section when notifications arrive Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 // Returns the most recently added notification for |extension_id| if there
44 // are any, or NULL otherwise.
45 const AppNotification* GetLast(const std::string& extension_id);
46
47 // Clears all notifications for |extension_id|.
48 void ClearAll(const std::string& extension_id);
49
50 // Implementing NotificationObserver interface.
51 void Observe(NotificationType type,
52 const NotificationSource& source,
53 const NotificationDetails& details) OVERRIDE;
54
55 private:
56 // Maps extension id to a list of notifications for that extension.
57 typedef std::map<std::string, AppNotificationList> NotificationMap;
58
59 NotificationRegistrar registrar_;
60 NotificationMap notifications_;
61
62 DISALLOW_COPY_AND_ASSIGN(AppNotificationManager);
63 };
64
65 class AppNotifyFunction : public SyncExtensionFunction {
66 ~AppNotifyFunction() {}
67 virtual bool RunImpl();
68 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.notify");
69 };
70
71 class AppClearAllNotificationsFunction : public SyncExtensionFunction {
72 ~AppClearAllNotificationsFunction() {}
73 virtual bool RunImpl();
74 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.clearAllNotifications");
75 };
76
77 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698