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/platform_notification_service_impl.h" | 5 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 10 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
40 #include "base/strings/string_number_conversions.h" | 40 #include "base/strings/string_number_conversions.h" |
41 #endif | 41 #endif |
42 | 42 |
43 using content::BrowserThread; | 43 using content::BrowserThread; |
44 using message_center::NotifierId; | 44 using message_center::NotifierId; |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
| 48 // Persistent notifications fired through the delegate do not care about the |
| 49 // lifetime of the Service Worker responsible for executing the event. |
| 50 void OnEventDispatchComplete(content::PersistentNotificationStatus status) { |
| 51 // TODO(peter): Record UMA statistics about the result status of running |
| 52 // events for persistent Web Notifications. |
| 53 } |
| 54 |
48 void CancelNotification(const std::string& id, ProfileID profile_id) { | 55 void CancelNotification(const std::string& id, ProfileID profile_id) { |
49 PlatformNotificationServiceImpl::GetInstance() | 56 PlatformNotificationServiceImpl::GetInstance() |
50 ->GetNotificationUIManager()->CancelById(id, profile_id); | 57 ->GetNotificationUIManager()->CancelById(id, profile_id); |
51 } | 58 } |
52 | 59 |
53 } // namespace | 60 } // namespace |
54 | 61 |
55 // static | 62 // static |
56 PlatformNotificationServiceImpl* | 63 PlatformNotificationServiceImpl* |
57 PlatformNotificationServiceImpl::GetInstance() { | 64 PlatformNotificationServiceImpl::GetInstance() { |
58 return Singleton<PlatformNotificationServiceImpl>::get(); | 65 return Singleton<PlatformNotificationServiceImpl>::get(); |
59 } | 66 } |
60 | 67 |
61 PlatformNotificationServiceImpl::PlatformNotificationServiceImpl() | 68 PlatformNotificationServiceImpl::PlatformNotificationServiceImpl() |
62 : notification_ui_manager_for_tests_(nullptr) {} | 69 : notification_ui_manager_for_tests_(nullptr) {} |
63 | 70 |
64 PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {} | 71 PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {} |
65 | 72 |
66 void PlatformNotificationServiceImpl::OnPersistentNotificationClick( | 73 void PlatformNotificationServiceImpl::OnPersistentNotificationClick( |
67 content::BrowserContext* browser_context, | 74 content::BrowserContext* browser_context, |
68 int64_t persistent_notification_id, | 75 int64_t persistent_notification_id, |
69 const GURL& origin, | 76 const GURL& origin) const { |
70 const base::Callback<void(content::PersistentNotificationStatus)>& | |
71 callback) const { | |
72 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 77 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
73 content::NotificationEventDispatcher::GetInstance() | 78 content::NotificationEventDispatcher::GetInstance() |
74 ->DispatchNotificationClickEvent( | 79 ->DispatchNotificationClickEvent( |
75 browser_context, | 80 browser_context, |
76 persistent_notification_id, | 81 persistent_notification_id, |
77 origin, | 82 origin, |
78 callback); | 83 base::Bind(&OnEventDispatchComplete)); |
79 } | 84 } |
80 | 85 |
81 blink::WebNotificationPermission | 86 blink::WebNotificationPermission |
82 PlatformNotificationServiceImpl::CheckPermissionOnUIThread( | 87 PlatformNotificationServiceImpl::CheckPermissionOnUIThread( |
83 content::BrowserContext* browser_context, | 88 content::BrowserContext* browser_context, |
84 const GURL& origin, | 89 const GURL& origin, |
85 int render_process_id) { | 90 int render_process_id) { |
86 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 91 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
87 | 92 |
88 Profile* profile = Profile::FromBrowserContext(browser_context); | 93 Profile* profile = Profile::FromBrowserContext(browser_context); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 formatted_origin.push_back(':'); | 354 formatted_origin.push_back(':'); |
350 formatted_origin.append(base::UTF8ToUTF16(origin.port())); | 355 formatted_origin.append(base::UTF8ToUTF16(origin.port())); |
351 } | 356 } |
352 return formatted_origin; | 357 return formatted_origin; |
353 } | 358 } |
354 | 359 |
355 // TODO(dewittj): Once file:// URLs are passed in to the origin | 360 // TODO(dewittj): Once file:// URLs are passed in to the origin |
356 // GURL here, begin returning the path as the display name. | 361 // GURL here, begin returning the path as the display name. |
357 return net::FormatUrl(origin, languages); | 362 return net::FormatUrl(origin, languages); |
358 } | 363 } |
OLD | NEW |