#include "chrome/browser/notifications/notification_object_proxy.h"
-#include "base/strings/stringprintf.h"
-#include "content/public/browser/render_view_host.h"
+#include "base/guid.h"
+#include "content/public/browser/desktop_notification_delegate.h"
-using content::RenderViewHost;
+NotificationObjectProxy::NotificationObjectProxy(
+ scoped_ptr<content::DesktopNotificationDelegate> delegate)
+ : delegate_(delegate.Pass()),
+ displayed_(false),
+ id_(base::GenerateGUID()) {}
-NotificationObjectProxy::NotificationObjectProxy(int process_id, int route_id,
- int notification_id, bool worker)
- : process_id_(process_id),
- route_id_(route_id),
- notification_id_(notification_id),
- worker_(worker),
- displayed_(false) {
- if (worker_) {
- // TODO(johnnyg): http://crbug.com/23065 Worker support coming soon.
- NOTREACHED();
- }
-}
+NotificationObjectProxy::~NotificationObjectProxy() {}
void NotificationObjectProxy::Display() {
// This method is called each time the notification is shown to the user
return;
displayed_ = true;
- RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
- if (host)
- host->DesktopNotificationPostDisplay(notification_id_);
-}
-
-void NotificationObjectProxy::Error() {
- RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
- if (host)
- host->DesktopNotificationPostError(notification_id_, string16());
+ delegate_->NotificationDisplayed();
}
void NotificationObjectProxy::Close(bool by_user) {
- RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
- if (host)
- host->DesktopNotificationPostClose(notification_id_, by_user);
+ delegate_->NotificationClosed(by_user);
}
void NotificationObjectProxy::Click() {
- RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
- if (host)
- host->DesktopNotificationPostClick(notification_id_);
+ delegate_->NotificationClick();
}
std::string NotificationObjectProxy::id() const {
- return base::StringPrintf("%d:%d:%d:%d", process_id_, route_id_,
- notification_id_, worker_);
-}
-
-int NotificationObjectProxy::process_id() const {
- return process_id_;
-}
-
-RenderViewHost* NotificationObjectProxy::GetRenderViewHost() const {
- return RenderViewHost::FromID(process_id_, route_id_);
+ return id_;
}