| Index: chrome/browser/extensions/api/custom_notification_center/custom_notification_center_api.h
|
| diff --git a/chrome/browser/extensions/api/custom_notification_center/custom_notification_center_api.h b/chrome/browser/extensions/api/custom_notification_center/custom_notification_center_api.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..238b86056fec8b0b69e5bf7f4d038596dd23eea4
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/api/custom_notification_center/custom_notification_center_api.h
|
| @@ -0,0 +1,146 @@
|
| +// Copyright (c) 2014 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_API_CUSTOM_NOTIFICATION_CENTER_CUSTOM_NOTIFICATION_CENTER_API_H_
|
| +#define CHROME_BROWSER_EXTENSIONS_API_CUSTOM_NOTIFICATION_CENTER_CUSTOM_NOTIFICATION_CENTER_API_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/memory/ref_counted.h"
|
| +#include "chrome/browser/extensions/chrome_extension_function.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/common/extensions/api/custom_notification_center.h"
|
| +#include "extensions/browser/extension_function.h"
|
| +#include "ui/message_center/notification_types.h"
|
| +
|
| +namespace extensions {
|
| +
|
| +// Send events to the client. This will send events onCreated, onUpdated and
|
| +// onCleared to extensions/apps using this API.
|
| +class CustomNotificationCenterEventRouter {
|
| + public:
|
| + explicit CustomNotificationCenterEventRouter(Profile* profile);
|
| + virtual ~CustomNotificationCenterEventRouter();
|
| +
|
| + void CreateNotification(
|
| + const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notification_id,
|
| + const extensions::api::custom_notification_center::NotificationContent&
|
| + content);
|
| + void UpdateNotification(
|
| + const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notificaiton_id,
|
| + const extensions::api::custom_notification_center::NotificationContent&
|
| + content);
|
| + void ClearNotification(const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notification_id);
|
| +
|
| + private:
|
| + void Create(
|
| + const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notification_id,
|
| + const extensions::api::custom_notification_center::NotificationContent&
|
| + content);
|
| + void Update(
|
| + const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notification_id,
|
| + const extensions::api::custom_notification_center::NotificationContent&
|
| + content);
|
| + void Clear(const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notification_id);
|
| +
|
| + Profile* profile_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CustomNotificationCenterEventRouter);
|
| +};
|
| +
|
| +// Implememtation of SendOnClear function of the API. It will notify the
|
| +// notification sender about the user action.
|
| +class CustomNotificationCenterSendOnClearFunction
|
| + : public ChromeAsyncExtensionFunction {
|
| + public:
|
| + CustomNotificationCenterSendOnClearFunction();
|
| +
|
| + virtual bool RunAsync() OVERRIDE;
|
| +
|
| + protected:
|
| + virtual ~CustomNotificationCenterSendOnClearFunction();
|
| +
|
| + private:
|
| + scoped_ptr<api::custom_notification_center::SendOnClear::Params> params_;
|
| +
|
| + DECLARE_EXTENSION_FUNCTION("customNotificationCenter.sendOnClear",
|
| + CUSTOMNOTIFICATIONCENTER_SENDONCLEAR)
|
| +};
|
| +
|
| +// Implememtation of SendOnClick function of the API. It will notify the
|
| +// notification sender about the user action.
|
| +class CustomNotificationCenterSendOnClickFunction
|
| + : public ChromeAsyncExtensionFunction {
|
| + public:
|
| + CustomNotificationCenterSendOnClickFunction();
|
| +
|
| + virtual bool RunAsync() OVERRIDE;
|
| +
|
| + protected:
|
| + virtual ~CustomNotificationCenterSendOnClickFunction();
|
| +
|
| + private:
|
| + scoped_ptr<api::custom_notification_center::SendOnClick::Params> params_;
|
| +
|
| + DECLARE_EXTENSION_FUNCTION("customNotificationCenter.sendOnClick",
|
| + CUSTOMNOTIFICATIONCENTER_SENDONCLICK)
|
| +};
|
| +
|
| +// Implememtation of SendOnButtonClick function of the API. It will notify the
|
| +// notification sender about the user action.
|
| +class CustomNotificationCenterSendOnButtonClickFunction
|
| + : public ChromeAsyncExtensionFunction {
|
| + public:
|
| + CustomNotificationCenterSendOnButtonClickFunction();
|
| +
|
| + virtual bool RunAsync() OVERRIDE;
|
| +
|
| + protected:
|
| + virtual ~CustomNotificationCenterSendOnButtonClickFunction();
|
| +
|
| + private:
|
| + scoped_ptr<api::custom_notification_center::SendOnButtonClick::Params>
|
| + params_;
|
| +
|
| + DECLARE_EXTENSION_FUNCTION("customNotificationCenter.sendOnButtonClick",
|
| + CUSTOMNOTIFICATIONCENTER_SENDONBUTTONCLICK)
|
| +};
|
| +
|
| +// Implememtation of NotifyPermissionLevelChanged function of the API.
|
| +// It will notify the notification sender about the user action.
|
| +class CustomNotificationCenterNotifyPermissionLevelChangedFunction
|
| + : public ChromeAsyncExtensionFunction {
|
| + public:
|
| + CustomNotificationCenterNotifyPermissionLevelChangedFunction();
|
| +
|
| + virtual bool RunAsync() OVERRIDE;
|
| +
|
| + protected:
|
| + virtual ~CustomNotificationCenterNotifyPermissionLevelChangedFunction();
|
| +
|
| + private:
|
| + scoped_ptr<
|
| + api::custom_notification_center::NotifyPermissionLevelChanged::Params>
|
| + params_;
|
| +
|
| + DECLARE_EXTENSION_FUNCTION(
|
| + "customNotificationCenter.notifyPermissionLevelChanged",
|
| + CUSTOMNOTIFICATIONCENTER_NOTIFYPERMISSIONLEVELCHANGED)
|
| +};
|
| +
|
| +} // namespace extensions
|
| +
|
| +#endif // CHROME_BROWSER_EXTENSIONS_API_CUSTOM_NOTIFICATION_CENTER_CUSTOM_NOTIFICATION_CENTER_API_H_
|
|
|