blob: 70aa1935a231b8a1e28df5ab4d6e2873a1f09ed6 [file] [log] [blame]
[email protected]4bb336302009-10-12 05:44:261// Copyright (c) 2009 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_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_
6#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]4bb336302009-10-12 05:44:268
[email protected]3b845752010-03-17 01:19:069#include <string>
10
11#include "chrome/browser/notifications/notification_delegate.h"
[email protected]4bb336302009-10-12 05:44:2612
13class MessageLoop;
14namespace IPC {
15class Message;
16}
17
18// A NotificationObjectProxy stands in for the JavaScript Notification object
19// which corresponds to a notification toast on the desktop. It can be signaled
20// when various events occur regarding the desktop notification, and the
21// attached JS listeners will be invoked in the renderer or worker process.
[email protected]11f4857282009-11-13 19:56:1722class NotificationObjectProxy
[email protected]3b845752010-03-17 01:19:0623 : public NotificationDelegate {
[email protected]4bb336302009-10-12 05:44:2624 public:
25 // Creates a Proxy object with the necessary callback information.
26 NotificationObjectProxy(int process_id, int route_id,
27 int notification_id, bool worker);
28
[email protected]3b845752010-03-17 01:19:0629 // NotificationDelegate implementation.
[email protected]8b7135d6aa2009-11-11 17:40:3130 virtual void Display();
[email protected]8b7135d6aa2009-11-11 17:40:3131 virtual void Error();
[email protected]8b7135d6aa2009-11-11 17:40:3132 virtual void Close(bool by_user);
[email protected]3b845752010-03-17 01:19:0633 virtual std::string id() const;
[email protected]b52448bb2009-11-04 21:29:1134
[email protected]8b7135d6aa2009-11-11 17:40:3135 protected:
[email protected]7991a232009-11-06 01:55:4836 friend class base::RefCountedThreadSafe<NotificationObjectProxy>;
37
[email protected]8b7135d6aa2009-11-11 17:40:3138 virtual ~NotificationObjectProxy() {}
[email protected]7991a232009-11-06 01:55:4839
[email protected]8b7135d6aa2009-11-11 17:40:3140 private:
[email protected]4bb336302009-10-12 05:44:2641 // Called on UI thread to schedule a message for sending.
42 void DeliverMessage(IPC::Message* message);
43
44 // Called via Task on IO thread to actually send a message to a notification.
45 void Send(IPC::Message* message);
46
47 // Callback information to find the JS Notification object where it lives.
48 int process_id_;
49 int route_id_;
50 int notification_id_;
51 bool worker_;
52};
53
54#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_