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 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_ 7 8 #include <string> 9 10 #include "chrome/browser/notifications/notification_delegate.h" 11 12 // A NotificationObjectProxy stands in for the JavaScript Notification object 13 // which corresponds to a notification toast on the desktop. It can be signaled 14 // when various events occur regarding the desktop notification, and the 15 // attached JS listeners will be invoked in the renderer or worker process. 16 class NotificationObjectProxy 17 : public NotificationDelegate { 18 public: 19 // Creates a Proxy object with the necessary callback information. 20 NotificationObjectProxy(int process_id, int route_id, 21 int notification_id, bool worker); 22 23 // NotificationDelegate implementation. 24 virtual void Display() OVERRIDE; 25 virtual void Error() OVERRIDE; 26 virtual void Close(bool by_user) OVERRIDE; 27 virtual void Click() OVERRIDE; 28 virtual std::string id() const OVERRIDE; 29 virtual int process_id() const OVERRIDE; 30 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE; 31 32 protected: 33 friend class base::RefCountedThreadSafe<NotificationObjectProxy>; 34 35 virtual ~NotificationObjectProxy() {} 36 37 private: 38 // Callback information to find the JS Notification object where it lives. 39 int process_id_; 40 int route_id_; 41 int notification_id_; 42 bool worker_; 43 bool displayed_; 44 }; 45 46 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ 47