| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/notifications/notification_object_proxy.h" | 5 #include "chrome/browser/notifications/notification_object_proxy.h" |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/strings/stringprintf.h" | |
| 9 #include "content/public/browser/desktop_notification_delegate.h" | 8 #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" | |
| 13 | 9 |
| 14 NotificationObjectProxy::NotificationObjectProxy( | 10 NotificationObjectProxy::NotificationObjectProxy( |
| 15 content::RenderFrameHost* render_frame_host, | |
| 16 scoped_ptr<content::DesktopNotificationDelegate> delegate) | 11 scoped_ptr<content::DesktopNotificationDelegate> delegate) |
| 17 : render_process_id_(render_frame_host->GetProcess()->GetID()), | 12 : delegate_(delegate.Pass()), |
| 18 render_frame_id_(render_frame_host->GetRoutingID()), | |
| 19 delegate_(delegate.Pass()), | |
| 20 displayed_(false), | 13 displayed_(false), |
| 21 id_(base::GenerateGUID()) { | 14 id_(base::GenerateGUID()) {} |
| 22 } | |
| 23 | 15 |
| 24 NotificationObjectProxy::~NotificationObjectProxy() {} | 16 NotificationObjectProxy::~NotificationObjectProxy() {} |
| 25 | 17 |
| 26 void NotificationObjectProxy::Display() { | 18 void NotificationObjectProxy::Display() { |
| 27 // This method is called each time the notification is shown to the user | 19 // 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. | 20 // but we only want to fire the event the first time. |
| 29 if (displayed_) | 21 if (displayed_) |
| 30 return; | 22 return; |
| 31 displayed_ = true; | 23 displayed_ = true; |
| 32 | 24 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 43 | 35 |
| 44 void NotificationObjectProxy::Click() { | 36 void NotificationObjectProxy::Click() { |
| 45 delegate_->NotificationClick(); | 37 delegate_->NotificationClick(); |
| 46 } | 38 } |
| 47 | 39 |
| 48 std::string NotificationObjectProxy::id() const { | 40 std::string NotificationObjectProxy::id() const { |
| 49 return id_; | 41 return id_; |
| 50 } | 42 } |
| 51 | 43 |
| 52 content::WebContents* NotificationObjectProxy::GetWebContents() const { | 44 content::WebContents* NotificationObjectProxy::GetWebContents() const { |
| 53 return content::WebContents::FromRenderFrameHost( | 45 return NULL; |
| 54 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_)); | |
| 55 } | 46 } |
| OLD | NEW |