| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "chrome/browser/notifications/notification_object_proxy.h" | |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "chrome/browser/notifications/platform_notification_service_impl.h" | |
| 11 #include "content/public/browser/desktop_notification_delegate.h" | |
| 12 #include "url/gurl.h" | |
| 13 | |
| 14 NotificationObjectProxy::NotificationObjectProxy( | |
| 15 content::BrowserContext* browser_context, | |
| 16 const std::string& notification_id, | |
| 17 const GURL& origin, | |
| 18 std::unique_ptr<content::DesktopNotificationDelegate> delegate) | |
| 19 : WebNotificationDelegate(browser_context, notification_id, origin), | |
| 20 delegate_(std::move(delegate)), | |
| 21 displayed_(false) {} | |
| 22 | |
| 23 NotificationObjectProxy::~NotificationObjectProxy() {} | |
| 24 | |
| 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. | |
| 28 if (displayed_) | |
| 29 return; | |
| 30 | |
| 31 displayed_ = true; | |
| 32 | |
| 33 delegate_->NotificationDisplayed(); | |
| 34 } | |
| 35 | |
| 36 void NotificationObjectProxy::Close(bool by_user) { | |
| 37 delegate_->NotificationClosed(); | |
| 38 } | |
| 39 | |
| 40 void NotificationObjectProxy::Click() { | |
| 41 delegate_->NotificationClick(); | |
| 42 } | |
| 43 | |
| 44 void NotificationObjectProxy::ButtonClick(int button_index) { | |
| 45 // Notification buttons not are supported for non persistent notifications. | |
| 46 DCHECK_EQ(button_index, 0); | |
| 47 | |
| 48 NotificationCommon::OpenNotificationSettings(browser_context()); | |
| 49 } | |
| OLD | NEW |