Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / notifications / notification_object_proxy.cc
blob1025c59791941ea7803bc4410a6460ce9e2c6db4
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/guid.h"
8 #include "base/strings/stringprintf.h"
9 #include "content/public/browser/desktop_notification_delegate.h"
10 #include "content/public/browser/render_frame_host.h"
11 #include "content/public/browser/render_process_host.h"
12 #include "content/public/browser/web_contents.h"
14 NotificationObjectProxy::NotificationObjectProxy(
15 content::RenderFrameHost* render_frame_host,
16 scoped_ptr<content::DesktopNotificationDelegate> delegate)
17 : render_process_id_(render_frame_host->GetProcess()->GetID()),
18 render_frame_id_(render_frame_host->GetRoutingID()),
19 delegate_(delegate.Pass()),
20 displayed_(false),
21 id_(base::GenerateGUID()) {
24 NotificationObjectProxy::~NotificationObjectProxy() {}
26 void NotificationObjectProxy::Display() {
27 // This method is called each time the notification is shown to the user
28 // but we only want to fire the event the first time.
29 if (displayed_)
30 return;
31 displayed_ = true;
33 delegate_->NotificationDisplayed();
36 void NotificationObjectProxy::Error() {
37 delegate_->NotificationError();
40 void NotificationObjectProxy::Close(bool by_user) {
41 delegate_->NotificationClosed(by_user);
44 void NotificationObjectProxy::Click() {
45 delegate_->NotificationClick();
48 std::string NotificationObjectProxy::id() const {
49 return id_;
52 int NotificationObjectProxy::process_id() const {
53 return render_process_id_;
56 content::WebContents* NotificationObjectProxy::GetWebContents() const {
57 return content::WebContents::FromRenderFrameHost(
58 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_));