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