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.
5 #include "chrome/browser/notifications/notification_object_proxy.h"
7 #include "base/strings/stringprintf.h"
8 #include "content/public/browser/render_view_host.h"
10 using content::RenderViewHost;
12 NotificationObjectProxy::NotificationObjectProxy(int process_id, int route_id,
13 int notification_id, bool worker)
14 : process_id_(process_id),
16 notification_id_(notification_id),
20 // TODO(johnnyg): http://crbug.com/23065 Worker support coming soon.
25 void NotificationObjectProxy::Display() {
26 // This method is called each time the notification is shown to the user
27 // but we only want to fire the event the first time.
32 RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
34 host->DesktopNotificationPostDisplay(notification_id_);
37 void NotificationObjectProxy::Error() {
38 RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
40 host->DesktopNotificationPostError(notification_id_, string16());
43 void NotificationObjectProxy::Close(bool by_user) {
44 RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
46 host->DesktopNotificationPostClose(notification_id_, by_user);
49 void NotificationObjectProxy::Click() {
50 RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
52 host->DesktopNotificationPostClick(notification_id_);
55 std::string NotificationObjectProxy::id() const {
56 return base::StringPrintf("%d:%d:%d:%d", process_id_, route_id_,
57 notification_id_, worker_);
60 int NotificationObjectProxy::process_id() const {
64 RenderViewHost* NotificationObjectProxy::GetRenderViewHost() const {
65 return RenderViewHost::FromID(process_id_, route_id_);