| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/persistent_notification_delegate.h" | 5 #include "chrome/browser/notifications/persistent_notification_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 7 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 8 #include "url/gurl.h" |
| 8 | 9 |
| 9 PersistentNotificationDelegate::PersistentNotificationDelegate( | 10 PersistentNotificationDelegate::PersistentNotificationDelegate( |
| 10 content::BrowserContext* browser_context, | 11 content::BrowserContext* browser_context, |
| 11 const std::string& notification_id, | 12 const std::string& notification_id, |
| 12 const GURL& origin, | 13 const GURL& origin, |
| 13 int notification_settings_index) | 14 int notification_settings_index) |
| 14 : browser_context_(browser_context), | 15 : WebNotificationDelegate(browser_context, notification_id, origin), |
| 15 notification_id_(notification_id), | |
| 16 origin_(origin), | |
| 17 notification_settings_index_(notification_settings_index) {} | 16 notification_settings_index_(notification_settings_index) {} |
| 18 | 17 |
| 19 PersistentNotificationDelegate::~PersistentNotificationDelegate() {} | 18 PersistentNotificationDelegate::~PersistentNotificationDelegate() {} |
| 20 | 19 |
| 21 void PersistentNotificationDelegate::Display() {} | 20 void PersistentNotificationDelegate::Display() {} |
| 22 | 21 |
| 23 void PersistentNotificationDelegate::Close(bool by_user) { | 22 void PersistentNotificationDelegate::Close(bool by_user) { |
| 24 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose( | 23 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose( |
| 25 browser_context_, notification_id_, origin_, by_user); | 24 browser_context(), id(), origin(), by_user); |
| 26 } | 25 } |
| 27 | 26 |
| 28 void PersistentNotificationDelegate::Click() { | 27 void PersistentNotificationDelegate::Click() { |
| 29 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( | 28 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( |
| 30 browser_context_, notification_id_, origin_, -1 /* action_index */); | 29 browser_context(), id(), origin(), -1 /* action_index */); |
| 31 } | 30 } |
| 32 | 31 |
| 33 void PersistentNotificationDelegate::ButtonClick(int button_index) { | 32 void PersistentNotificationDelegate::ButtonClick(int button_index) { |
| 34 DCHECK_GE(button_index, 0); | 33 DCHECK_GE(button_index, 0); |
| 35 if (button_index == notification_settings_index_) { | 34 if (button_index == notification_settings_index_) { |
| 36 NotificationCommon::OpenNotificationSettings(browser_context_); | 35 NotificationCommon::OpenNotificationSettings(browser_context()); |
| 37 return; | 36 return; |
| 38 } | 37 } |
| 39 | 38 |
| 40 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( | 39 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( |
| 41 browser_context_, notification_id_, origin_, button_index); | 40 browser_context(), id(), origin(), button_index); |
| 42 } | 41 } |
| 43 | |
| 44 void PersistentNotificationDelegate::SettingsClick() { | |
| 45 NotificationCommon::OpenNotificationSettings(browser_context_); | |
| 46 } | |
| 47 | |
| 48 bool PersistentNotificationDelegate::ShouldDisplaySettingsButton() { | |
| 49 return true; | |
| 50 } | |
| 51 | |
| 52 std::string PersistentNotificationDelegate::id() const { | |
| 53 return notification_id_; | |
| 54 } | |
| OLD | NEW |