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

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: 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 typedef std::vector<linked_ptr<AppNotification> > AppNotificationList;
30
31 // This class keeps track of notifications for installed apps.
32 class AppNotificationManager : public NotificationObserver {
33 public:
34 AppNotificationManager();
35 virtual ~AppNotificationManager();
36
37 // Takes ownership of |notification|.
38 void Add(AppNotification* item);
39
40 const AppNotificationList* GetAll(const std::string& extension_id);
41
42 // Clears all notifications for |extension_id|.
43 void ClearAll(const std::string& extension_id);
44
45 // Implementing NotificationObserver interface.
46 void Observe(NotificationType type,
47 const NotificationSource& source,
48 const NotificationDetails& details) OVERRIDE;
49
50 private:
51 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.
52
53 // Maps extension id to a list of notifications for that extension.
54 typedef std::map<std::string, AppNotificationList> NotificationMap;
55 NotificationMap items_;
56 };
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.
57
58 class AppNotifyFunction : public SyncExtensionFunction {
59 ~AppNotifyFunction() {}
60 virtual bool RunImpl();
61 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.notify");
62 };
63
64 class AppClearAllNotificationsFunction : public SyncExtensionFunction {
65 ~AppClearAllNotificationsFunction() {}
66 virtual bool RunImpl();
67 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.clearAllNotifications");
68 };
69
70 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698