OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_API_NOTIFICATION_NOTIFICATION_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_NOTIFICATION_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_NOTIFICATION_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_NOTIFICATION_API_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "chrome/browser/extensions/api/api_function.h" | 9 #include "chrome/browser/extensions/api/api_function.h" |
10 #include "chrome/browser/extensions/extension_function.h" | 10 #include "chrome/browser/extensions/extension_function.h" |
11 #include "chrome/common/extensions/api/experimental_notification.h" | 11 #include "chrome/common/extensions/api/experimental_notification.h" |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 namespace extensions { | 15 namespace extensions { |
16 | 16 |
17 class NotificationApiFunction : public ApiFunction { | 17 class NotificationApiFunction : public ApiFunction { |
18 protected: | 18 protected: |
19 NotificationApiFunction(); | 19 NotificationApiFunction(); |
20 virtual ~NotificationApiFunction(); | 20 virtual ~NotificationApiFunction(); |
21 | 21 |
22 void CreateNotification( | 22 void CreateNotification( |
23 const std::string& id, | 23 const std::string& id, |
24 api::experimental_notification::NotificationOptions* options); | 24 api::experimental_notification::NotificationOptions* options); |
| 25 |
| 26 bool IsNotificationApiEnabled(); |
| 27 |
| 28 // Called inside of RunImpl. |
| 29 virtual bool RunNotificationApi() = 0; |
| 30 |
| 31 // UITHreadExtensionFunction: |
| 32 virtual bool RunImpl() OVERRIDE; |
25 }; | 33 }; |
26 | 34 |
27 class NotificationCreateFunction : public NotificationApiFunction { | 35 class NotificationCreateFunction : public NotificationApiFunction { |
28 public: | 36 public: |
29 NotificationCreateFunction(); | 37 NotificationCreateFunction(); |
30 | 38 |
31 // UIThreadExtensionFunction: | 39 // UIThreadExtensionFunction: |
32 virtual bool RunImpl() OVERRIDE; | 40 virtual bool RunNotificationApi() OVERRIDE; |
33 | 41 |
34 protected: | 42 protected: |
35 virtual ~NotificationCreateFunction(); | 43 virtual ~NotificationCreateFunction(); |
36 | 44 |
37 private: | 45 private: |
38 scoped_ptr<api::experimental_notification::Create::Params> params_; | 46 scoped_ptr<api::experimental_notification::Create::Params> params_; |
39 | 47 |
40 DECLARE_EXTENSION_FUNCTION("experimental.notification.create", | 48 DECLARE_EXTENSION_FUNCTION("experimental.notification.create", |
41 EXPERIMENTAL_NOTIFICATION_CREATE) | 49 EXPERIMENTAL_NOTIFICATION_CREATE) |
42 }; | 50 }; |
43 | 51 |
44 class NotificationUpdateFunction : public NotificationApiFunction { | 52 class NotificationUpdateFunction : public NotificationApiFunction { |
45 public: | 53 public: |
46 NotificationUpdateFunction(); | 54 NotificationUpdateFunction(); |
47 | 55 |
48 // UIThreadExtensionFunction: | 56 // UIThreadExtensionFunction: |
49 virtual bool RunImpl() OVERRIDE; | 57 virtual bool RunNotificationApi() OVERRIDE; |
50 | 58 |
51 protected: | 59 protected: |
52 virtual ~NotificationUpdateFunction(); | 60 virtual ~NotificationUpdateFunction(); |
53 | 61 |
54 private: | 62 private: |
55 scoped_ptr<api::experimental_notification::Update::Params> params_; | 63 scoped_ptr<api::experimental_notification::Update::Params> params_; |
56 | 64 |
57 DECLARE_EXTENSION_FUNCTION("experimental.notification.update", | 65 DECLARE_EXTENSION_FUNCTION("experimental.notification.update", |
58 EXPERIMENTAL_NOTIFICATION_UPDATE) | 66 EXPERIMENTAL_NOTIFICATION_UPDATE) |
59 }; | 67 }; |
60 | 68 |
61 class NotificationDeleteFunction : public NotificationApiFunction { | 69 class NotificationDeleteFunction : public NotificationApiFunction { |
62 public: | 70 public: |
63 NotificationDeleteFunction(); | 71 NotificationDeleteFunction(); |
64 | 72 |
65 // UIThreadExtensionFunction: | 73 // UIThreadExtensionFunction: |
66 virtual bool RunImpl() OVERRIDE; | 74 virtual bool RunNotificationApi() OVERRIDE; |
67 | 75 |
68 protected: | 76 protected: |
69 virtual ~NotificationDeleteFunction(); | 77 virtual ~NotificationDeleteFunction(); |
70 | 78 |
71 private: | 79 private: |
72 scoped_ptr<api::experimental_notification::Delete::Params> params_; | 80 scoped_ptr<api::experimental_notification::Delete::Params> params_; |
73 | 81 |
74 DECLARE_EXTENSION_FUNCTION("experimental.notification.delete", | 82 DECLARE_EXTENSION_FUNCTION("experimental.notification.delete", |
75 EXPERIMENTAL_NOTIFICATION_DELETE) | 83 EXPERIMENTAL_NOTIFICATION_DELETE) |
76 }; | 84 }; |
77 | 85 |
78 } // namespace extensions | 86 } // namespace extensions |
79 | 87 |
80 #endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_NOTIFICATION_API_H_ | 88 #endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_NOTIFICATION_API_H_ |
OLD | NEW |