diff options
author | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-28 02:07:30 +0000 |
---|---|---|
committer | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-28 02:07:30 +0000 |
commit | c1d05aaf3fa0d974facfd52e02f27b6a7a2d265d (patch) | |
tree | 7860ec49ad86186ee5689cc1357b43f31a532a6d /chrome/browser/extensions/extension_app_api.h | |
parent | 03536444cded4963dd7edc5d5b77605a16140e25 (diff) | |
download | chromium_src-c1d05aaf3fa0d974facfd52e02f27b6a7a2d265d.zip chromium_src-c1d05aaf3fa0d974facfd52e02f27b6a7a2d265d.tar.gz chromium_src-c1d05aaf3fa0d974facfd52e02f27b6a7a2d265d.tar.bz2 |
Adding an experimental app notification API.
BUG=86958
TEST=none for now
Review URL: http://codereview.chromium.org/7187023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90705 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_app_api.h')
-rw-r--r-- | chrome/browser/extensions/extension_app_api.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_app_api.h b/chrome/browser/extensions/extension_app_api.h new file mode 100644 index 0000000..3e6b22c --- /dev/null +++ b/chrome/browser/extensions/extension_app_api.h @@ -0,0 +1,79 @@ +// Copyright (c) 2011 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_EXTENSION_APP_API_H__ +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ +#pragma once + +#include "chrome/browser/extensions/extension_function.h" + +#include <map> +#include <vector> + +#include "base/memory/linked_ptr.h" +#include "content/common/notification_observer.h" +#include "content/common/notification_registrar.h" +#include "third_party/skia/include/core/SkBitmap.h" + +struct AppNotification { + AppNotification(); + ~AppNotification(); + + std::string extension_id; + std::string title; + std::string body; + GURL linkUrl; + std::string linkText; + SkBitmap icon; +}; + +// A list of AppNotification's. +typedef std::vector<linked_ptr<AppNotification> > AppNotificationList; + +// This class keeps track of notifications for installed apps. +class AppNotificationManager : public NotificationObserver { + public: + AppNotificationManager(); + virtual ~AppNotificationManager(); + + // Takes ownership of |notification|. + void Add(AppNotification* item); + + const AppNotificationList* GetAll(const std::string& extension_id); + + // Returns the most recently added notification for |extension_id| if there + // are any, or NULL otherwise. + const AppNotification* GetLast(const std::string& extension_id); + + // Clears all notifications for |extension_id|. + void ClearAll(const std::string& extension_id); + + // Implementing NotificationObserver interface. + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) OVERRIDE; + + private: + // Maps extension id to a list of notifications for that extension. + typedef std::map<std::string, AppNotificationList> NotificationMap; + + NotificationRegistrar registrar_; + NotificationMap notifications_; + + DISALLOW_COPY_AND_ASSIGN(AppNotificationManager); +}; + +class AppNotifyFunction : public SyncExtensionFunction { + virtual ~AppNotifyFunction() {} + virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.notify"); +}; + +class AppClearAllNotificationsFunction : public SyncExtensionFunction { + virtual ~AppClearAllNotificationsFunction() {} + virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.clearAllNotifications"); +}; + +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_API_H__ |