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/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
),
19 // TODO(johnnyg): http://crbug.com/23065 Worker support coming soon.
24 void NotificationObjectProxy::Display() {
25 RenderViewHost
* host
= RenderViewHost::FromID(process_id_
, route_id_
);
27 host
->DesktopNotificationPostDisplay(notification_id_
);
30 void NotificationObjectProxy::Error() {
31 RenderViewHost
* host
= RenderViewHost::FromID(process_id_
, route_id_
);
33 host
->DesktopNotificationPostError(notification_id_
, string16());
36 void NotificationObjectProxy::Close(bool by_user
) {
37 RenderViewHost
* host
= RenderViewHost::FromID(process_id_
, route_id_
);
39 host
->DesktopNotificationPostClose(notification_id_
, by_user
);
42 void NotificationObjectProxy::Click() {
43 RenderViewHost
* host
= RenderViewHost::FromID(process_id_
, route_id_
);
45 host
->DesktopNotificationPostClick(notification_id_
);
48 std::string
NotificationObjectProxy::id() const {
49 return base::StringPrintf("%d:%d:%d:%d", process_id_
, route_id_
,
50 notification_id_
, worker_
);
53 RenderViewHost
* NotificationObjectProxy::GetRenderViewHost() const {
54 return RenderViewHost::FromID(process_id_
, route_id_
);