Chromium Code Reviews| 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 "base/strings/nullable_string16.h" | |
| 7 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 8 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 8 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 9 | 10 |
| 10 PersistentNotificationDelegate::PersistentNotificationDelegate( | 11 PersistentNotificationDelegate::PersistentNotificationDelegate( |
| 11 content::BrowserContext* browser_context, | 12 content::BrowserContext* browser_context, |
| 12 const std::string& notification_id, | 13 const std::string& notification_id, |
| 13 const GURL& origin, | 14 const GURL& origin, |
| 14 int notification_settings_index) | 15 int notification_settings_index) |
| 15 : WebNotificationDelegate(browser_context, notification_id, origin), | 16 : WebNotificationDelegate(browser_context, notification_id, origin), |
| 16 notification_settings_index_(notification_settings_index) {} | 17 notification_settings_index_(notification_settings_index) {} |
| 17 | 18 |
| 18 PersistentNotificationDelegate::~PersistentNotificationDelegate() {} | 19 PersistentNotificationDelegate::~PersistentNotificationDelegate() {} |
| 19 | 20 |
| 20 void PersistentNotificationDelegate::Display() {} | 21 void PersistentNotificationDelegate::Display() {} |
| 21 | 22 |
| 22 void PersistentNotificationDelegate::Close(bool by_user) { | 23 void PersistentNotificationDelegate::Close(bool by_user) { |
| 23 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose( | 24 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose( |
| 24 browser_context(), id(), origin(), by_user); | 25 browser_context(), id(), origin(), by_user); |
| 25 } | 26 } |
| 26 | 27 |
| 27 void PersistentNotificationDelegate::Click() { | 28 void PersistentNotificationDelegate::Click() { |
| 28 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( | 29 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( |
| 29 browser_context(), id(), origin(), -1 /* action_index */); | 30 browser_context(), id(), origin(), -1 /* action_index */, |
| 31 base::NullableString16() /* reply */); | |
| 30 } | 32 } |
| 31 | 33 |
| 32 void PersistentNotificationDelegate::ButtonClick(int button_index) { | 34 void PersistentNotificationDelegate::ButtonClick(int button_index) { |
| 33 DCHECK_GE(button_index, 0); | 35 DCHECK_GE(button_index, 0); |
| 34 if (button_index == notification_settings_index_) { | 36 if (button_index == notification_settings_index_) { |
| 35 NotificationCommon::OpenNotificationSettings(browser_context()); | 37 NotificationCommon::OpenNotificationSettings(browser_context()); |
| 36 return; | 38 return; |
| 37 } | 39 } |
| 38 | 40 |
| 39 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( | 41 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( |
| 40 browser_context(), id(), origin(), button_index); | 42 browser_context(), id(), origin(), button_index, |
| 43 base::NullableString16() /* reply */); | |
| 41 } | 44 } |
| 45 | |
| 46 void PersistentNotificationDelegate::ButtonClickWithReply( | |
| 47 int button_index, | |
| 48 const base::string16& reply) { | |
| 49 DCHECK_GE(button_index, 0); | |
|
Peter Beverloo
2016/10/12 13:58:31
DCHECK_NE(button_index, notification_settings_inde
| |
| 50 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( | |
| 51 browser_context(), id(), origin(), button_index, | |
| 52 base::NullableString16(reply, false /* is_null */)); | |
| 53 } | |
| OLD | NEW |