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 "chrome/browser/profiles/profile.h" | |
9 #include "chrome/browser/ui/browser.h" | |
10 #include "chrome/browser/ui/browser_list.h" | |
11 #include "chrome/browser/ui/browser_window.h" | |
12 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" | |
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
14 #include "content/public/browser/web_contents.h" | |
Peter Beverloo
2016/09/27 17:17:36
nit: these includes probably aren't needed for thi
bmalcolm
2016/09/27 20:34:36
Earlier design. Removed.
| |
15 | |
16 using content::WebContents; | |
Peter Beverloo
2016/09/27 17:17:36
unused
bmalcolm
2016/09/27 20:34:36
Removed.
| |
8 | 17 |
9 PersistentNotificationDelegate::PersistentNotificationDelegate( | 18 PersistentNotificationDelegate::PersistentNotificationDelegate( |
10 content::BrowserContext* browser_context, | 19 content::BrowserContext* browser_context, |
11 const std::string& notification_id, | 20 const std::string& notification_id, |
12 const GURL& origin, | 21 const GURL& origin, |
13 int notification_settings_index) | 22 int notification_settings_index) |
14 : browser_context_(browser_context), | 23 : WebNotificationDelegate(browser_context, notification_id, origin), |
15 notification_id_(notification_id), | |
16 origin_(origin), | |
17 notification_settings_index_(notification_settings_index) {} | 24 notification_settings_index_(notification_settings_index) {} |
18 | 25 |
19 PersistentNotificationDelegate::~PersistentNotificationDelegate() {} | 26 PersistentNotificationDelegate::~PersistentNotificationDelegate() {} |
20 | 27 |
21 void PersistentNotificationDelegate::Display() {} | 28 void PersistentNotificationDelegate::Display() {} |
22 | 29 |
23 void PersistentNotificationDelegate::Close(bool by_user) { | 30 void PersistentNotificationDelegate::Close(bool by_user) { |
24 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose( | 31 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose( |
25 browser_context_, notification_id_, origin_, by_user); | 32 browser_context(), id(), origin(), by_user); |
26 } | 33 } |
27 | 34 |
28 void PersistentNotificationDelegate::Click() { | 35 void PersistentNotificationDelegate::Click() { |
29 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( | 36 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( |
30 browser_context_, notification_id_, origin_, -1 /* action_index */); | 37 browser_context(), id(), origin(), -1 /* action_index */); |
31 } | 38 } |
32 | 39 |
33 void PersistentNotificationDelegate::ButtonClick(int button_index) { | 40 void PersistentNotificationDelegate::ButtonClick(int button_index) { |
34 DCHECK_GE(button_index, 0); | 41 DCHECK_GE(button_index, 0); |
35 if (button_index == notification_settings_index_) { | 42 if (button_index == notification_settings_index_) { |
36 NotificationCommon::OpenNotificationSettings(browser_context_); | 43 NotificationCommon::OpenNotificationSettings(browser_context()); |
37 return; | 44 return; |
38 } | 45 } |
39 | 46 |
40 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( | 47 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( |
41 browser_context_, notification_id_, origin_, button_index); | 48 browser_context(), id(), origin(), button_index); |
42 } | 49 } |
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 |