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 #ifndef CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 blink::WebNotificationPermission CheckPermissionOnIOThread( | 53 blink::WebNotificationPermission CheckPermissionOnIOThread( |
54 content::ResourceContext* resource_context, | 54 content::ResourceContext* resource_context, |
55 const GURL& origin, | 55 const GURL& origin, |
56 int render_process_id) override; | 56 int render_process_id) override; |
57 void DisplayNotification( | 57 void DisplayNotification( |
58 content::BrowserContext* browser_context, | 58 content::BrowserContext* browser_context, |
59 const GURL& origin, | 59 const GURL& origin, |
60 const SkBitmap& icon, | 60 const SkBitmap& icon, |
61 const content::PlatformNotificationData& notification_data, | 61 const content::PlatformNotificationData& notification_data, |
62 scoped_ptr<content::DesktopNotificationDelegate> delegate, | 62 scoped_ptr<content::DesktopNotificationDelegate> delegate, |
63 int render_process_id, | |
64 base::Closure* cancel_callback) override; | 63 base::Closure* cancel_callback) override; |
65 void DisplayPersistentNotification( | 64 void DisplayPersistentNotification( |
66 content::BrowserContext* browser_context, | 65 content::BrowserContext* browser_context, |
67 int64 service_worker_registration_id, | 66 int64 service_worker_registration_id, |
68 const GURL& origin, | 67 const GURL& origin, |
69 const SkBitmap& icon, | 68 const SkBitmap& icon, |
70 const content::PlatformNotificationData& notification_data, | 69 const content::PlatformNotificationData& notification_data) override; |
71 int render_process_id) override; | |
72 void ClosePersistentNotification( | 70 void ClosePersistentNotification( |
73 content::BrowserContext* browser_context, | 71 content::BrowserContext* browser_context, |
74 const std::string& persistent_notification_id) override; | 72 const std::string& persistent_notification_id) override; |
75 | 73 |
76 private: | 74 private: |
77 friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>; | 75 friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>; |
78 friend class PlatformNotificationServiceBrowserTest; | 76 friend class PlatformNotificationServiceBrowserTest; |
79 friend class PlatformNotificationServiceTest; | 77 friend class PlatformNotificationServiceTest; |
80 friend class gcm::PushMessagingBrowserTest; | 78 friend class gcm::PushMessagingBrowserTest; |
81 FRIEND_TEST_ALL_PREFIXES( | 79 FRIEND_TEST_ALL_PREFIXES( |
82 PlatformNotificationServiceTest, DisplayNameForOrigin); | 80 PlatformNotificationServiceTest, DisplayNameForOrigin); |
| 81 FRIEND_TEST_ALL_PREFIXES(PlatformNotificationServiceTest, |
| 82 TestWebOriginDisplayName); |
83 | 83 |
84 PlatformNotificationServiceImpl(); | 84 PlatformNotificationServiceImpl(); |
85 ~PlatformNotificationServiceImpl() override; | 85 ~PlatformNotificationServiceImpl() override; |
86 | 86 |
87 // Creates a new Web Notification-based Notification object. | 87 // Creates a new Web Notification-based Notification object. |
88 // TODO(peter): |delegate| can be a scoped_refptr, but properly passing this | 88 // TODO(peter): |delegate| can be a scoped_refptr, but properly passing this |
89 // through requires changing a whole lot of Notification constructor calls. | 89 // through requires changing a whole lot of Notification constructor calls. |
90 Notification CreateNotificationFromData( | 90 Notification CreateNotificationFromData( |
91 Profile* profile, | 91 Profile* profile, |
92 const GURL& origin, | 92 const GURL& origin, |
93 const SkBitmap& icon, | 93 const SkBitmap& icon, |
94 const content::PlatformNotificationData& notification_data, | 94 const content::PlatformNotificationData& notification_data, |
95 NotificationDelegate* delegate, | 95 NotificationDelegate* delegate) const; |
96 int render_process_id) const; | |
97 | 96 |
98 // Overrides the Notification UI Manager to use to |manager|. Only to be | 97 // Overrides the Notification UI Manager to use to |manager|. Only to be |
99 // used by tests. Tests are responsible for cleaning up after themselves. | 98 // used by tests. Tests are responsible for cleaning up after themselves. |
100 void SetNotificationUIManagerForTesting(NotificationUIManager* manager); | 99 void SetNotificationUIManagerForTesting(NotificationUIManager* manager); |
101 | 100 |
102 // Returns a display name for an origin in the process id, to be used in | 101 // Returns a display name for an origin, to be used in permission infobar or |
103 // permission infobar or on the frame of the notification toast. Different | 102 // on the frame of the notification toast. Different from the origin itself |
104 // from the origin itself when dealing with extensions. | 103 // when dealing with extensions. |
105 base::string16 DisplayNameForOriginInProcessId(Profile* profile, | 104 base::string16 DisplayNameForOrigin(Profile* profile, |
106 const GURL& origin, | 105 const GURL& origin) const; |
107 int process_id) const; | 106 |
| 107 // Translates a URL into a slightly more readable version that may omit |
| 108 // the port and scheme for common cases. |
| 109 // TODO(dewittj): Remove this when the proper function is implemented in a |
| 110 // chrome/browser/ui library function. See crbug.com/402698. |
| 111 static base::string16 WebOriginDisplayName(const GURL& origin, |
| 112 const std::string& languages); |
108 | 113 |
109 // Weak reference. Ownership maintains with the test. | 114 // Weak reference. Ownership maintains with the test. |
110 NotificationUIManager* notification_ui_manager_for_tests_; | 115 NotificationUIManager* notification_ui_manager_for_tests_; |
111 | 116 |
112 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); | 117 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); |
113 }; | 118 }; |
114 | 119 |
115 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ | 120 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ |
OLD | NEW |