Chromium Code Reviews| 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_NOTIFICATIONS_NOTIFICATIONS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_NOTIFICATIONS_NOTIFICATIONS_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_NOTIFICATIONS_NOTIFICATIONS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_NOTIFICATIONS_NOTIFICATIONS_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "chrome/browser/extensions/chrome_extension_function.h" | 12 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 13 #include "chrome/common/extensions/api/notifications.h" | 13 #include "chrome/common/extensions/api/notifications.h" |
| 14 #include "extensions/browser/extension_function.h" | 14 #include "extensions/browser/extension_function.h" |
| 15 #include "ui/message_center/notification_types.h" | 15 #include "ui/message_center/notification_types.h" |
| 16 | 16 |
| 17 class Notification; | 17 class Notification; |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 | 20 |
| 21 extern const base::Feature kAllowFullscreenAppNotificationsFeature; | 21 extern const base::Feature kAllowFullscreenAppNotificationsFeature; |
| 22 | 22 |
| 23 class ExtensionNotificationDisplayHelper; | |
| 24 | |
| 23 class NotificationsApiFunction : public ChromeAsyncExtensionFunction { | 25 class NotificationsApiFunction : public ChromeAsyncExtensionFunction { |
|
Miguel Garcia
2017/02/21 10:56:43
Can you describe briefly (perhaps offline) the own
Peter Beverloo
2017/02/21 17:23:50
The functions will be created on demand by the Ext
| |
| 24 public: | 26 public: |
| 25 // Whether the current extension and channel allow the API. Public for | 27 // Whether the current extension and channel allow the API. Public for |
| 26 // testing. | 28 // testing. |
| 27 bool IsNotificationsApiAvailable(); | 29 bool IsNotificationsApiAvailable(); |
| 28 | 30 |
| 29 protected: | 31 protected: |
| 30 NotificationsApiFunction(); | 32 NotificationsApiFunction(); |
| 31 ~NotificationsApiFunction() override; | 33 ~NotificationsApiFunction() override; |
| 32 | 34 |
| 33 bool CreateNotification(const std::string& id, | 35 bool CreateNotification(const std::string& id, |
| 34 api::notifications::NotificationOptions* options); | 36 api::notifications::NotificationOptions* options); |
| 35 bool UpdateNotification(const std::string& id, | 37 bool UpdateNotification(const std::string& id, |
| 36 api::notifications::NotificationOptions* options, | 38 api::notifications::NotificationOptions* options, |
| 37 Notification* notification); | 39 Notification* notification); |
| 38 | 40 |
| 39 bool IsNotificationsApiEnabled() const; | 41 bool IsNotificationsApiEnabled() const; |
| 40 | 42 |
| 41 bool AreExtensionNotificationsAllowed() const; | 43 bool AreExtensionNotificationsAllowed() const; |
| 42 | 44 |
| 45 // Returns the display helper that should be used for interacting with the | |
| 46 // common notification system. | |
| 47 ExtensionNotificationDisplayHelper* GetDisplayHelper() const; | |
| 48 | |
| 43 // Returns true if the API function is still allowed to run even when the | 49 // Returns true if the API function is still allowed to run even when the |
| 44 // notifications for a notifier have been disabled. | 50 // notifications for a notifier have been disabled. |
| 45 virtual bool CanRunWhileDisabled() const; | 51 virtual bool CanRunWhileDisabled() const; |
| 46 | 52 |
| 47 // Called inside of RunAsync. | 53 // Called inside of RunAsync. |
| 48 virtual bool RunNotificationsApi() = 0; | 54 virtual bool RunNotificationsApi() = 0; |
| 49 | 55 |
| 50 // UITHreadExtensionFunction: | 56 // UITHreadExtensionFunction: |
| 51 bool RunAsync() override; | 57 bool RunAsync() override; |
| 52 | 58 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 ~NotificationsGetPermissionLevelFunction() override; | 135 ~NotificationsGetPermissionLevelFunction() override; |
| 130 | 136 |
| 131 private: | 137 private: |
| 132 DECLARE_EXTENSION_FUNCTION("notifications.getPermissionLevel", | 138 DECLARE_EXTENSION_FUNCTION("notifications.getPermissionLevel", |
| 133 NOTIFICATIONS_GET_ALL) | 139 NOTIFICATIONS_GET_ALL) |
| 134 }; | 140 }; |
| 135 | 141 |
| 136 } // namespace extensions | 142 } // namespace extensions |
| 137 | 143 |
| 138 #endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATIONS_NOTIFICATIONS_API_H_ | 144 #endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATIONS_NOTIFICATIONS_API_H_ |
| OLD | NEW |