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 <stdint.h> | 8 #include <stdint.h> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 int64_t persistent_notification_id) override; | 83 int64_t persistent_notification_id) override; |
84 bool GetDisplayedPersistentNotifications( | 84 bool GetDisplayedPersistentNotifications( |
85 content::BrowserContext* browser_context, | 85 content::BrowserContext* browser_context, |
86 std::set<std::string>* displayed_notifications) override; | 86 std::set<std::string>* displayed_notifications) override; |
87 | 87 |
88 private: | 88 private: |
89 friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>; | 89 friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>; |
90 friend class PlatformNotificationServiceBrowserTest; | 90 friend class PlatformNotificationServiceBrowserTest; |
91 friend class PlatformNotificationServiceTest; | 91 friend class PlatformNotificationServiceTest; |
92 friend class PushMessagingBrowserTest; | 92 friend class PushMessagingBrowserTest; |
93 FRIEND_TEST_ALL_PREFIXES( | |
94 PlatformNotificationServiceTest, DisplayNameForOrigin); | |
95 FRIEND_TEST_ALL_PREFIXES(PlatformNotificationServiceTest, | 93 FRIEND_TEST_ALL_PREFIXES(PlatformNotificationServiceTest, |
96 TestWebOriginDisplayName); | 94 CreateNotificationFromData); |
| 95 FRIEND_TEST_ALL_PREFIXES(PlatformNotificationServiceTest, |
| 96 DisplayNameForContextMessage); |
97 | 97 |
98 PlatformNotificationServiceImpl(); | 98 PlatformNotificationServiceImpl(); |
99 ~PlatformNotificationServiceImpl() override; | 99 ~PlatformNotificationServiceImpl() override; |
100 | 100 |
101 // Creates a new Web Notification-based Notification object. | 101 // Creates a new Web Notification-based Notification object. |
102 // TODO(peter): |delegate| can be a scoped_refptr, but properly passing this | 102 // TODO(peter): |delegate| can be a scoped_refptr, but properly passing this |
103 // through requires changing a whole lot of Notification constructor calls. | 103 // through requires changing a whole lot of Notification constructor calls. |
104 Notification CreateNotificationFromData( | 104 Notification CreateNotificationFromData( |
105 Profile* profile, | 105 Profile* profile, |
106 const GURL& origin, | 106 const GURL& origin, |
107 const SkBitmap& icon, | 107 const SkBitmap& icon, |
108 const content::PlatformNotificationData& notification_data, | 108 const content::PlatformNotificationData& notification_data, |
109 NotificationDelegate* delegate) const; | 109 NotificationDelegate* delegate) const; |
110 | 110 |
111 // Overrides the Notification UI Manager to use to |manager|. Only to be | 111 // Overrides the Notification UI Manager to use to |manager|. Only to be |
112 // used by tests. Tests are responsible for cleaning up after themselves. | 112 // used by tests. Tests are responsible for cleaning up after themselves. |
113 void SetNotificationUIManagerForTesting(NotificationUIManager* manager); | 113 void SetNotificationUIManagerForTesting(NotificationUIManager* manager); |
114 | 114 |
115 // Returns a display name for an origin, to be used in permission infobar or | 115 // Returns a display name for an origin, to be used in the context message |
116 // on the frame of the notification toast. Different from the origin itself | 116 base::string16 DisplayNameForContextMessage(Profile* profile, |
117 // when dealing with extensions. | 117 const GURL& origin) const; |
118 base::string16 DisplayNameForOrigin(Profile* profile, | |
119 const GURL& origin) const; | |
120 | |
121 // Translates a URL into a slightly more readable version that may omit | |
122 // the port and scheme for common cases. | |
123 // TODO(dewittj): Remove this when the proper function is implemented in a | |
124 // chrome/browser/ui library function. See crbug.com/402698. | |
125 static base::string16 WebOriginDisplayName(const GURL& origin, | |
126 const std::string& languages); | |
127 | 118 |
128 // Weak reference. Ownership maintains with the test. | 119 // Weak reference. Ownership maintains with the test. |
129 NotificationUIManager* notification_ui_manager_for_tests_; | 120 NotificationUIManager* notification_ui_manager_for_tests_; |
130 | 121 |
131 // Mapping between a persistent notification id and the id of the associated | 122 // Mapping between a persistent notification id and the id of the associated |
132 // message_center::Notification object. Must only be used on the UI thread. | 123 // message_center::Notification object. Must only be used on the UI thread. |
133 std::map<int64_t, std::string> persistent_notifications_; | 124 std::map<int64_t, std::string> persistent_notifications_; |
134 | 125 |
135 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); | 126 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); |
136 }; | 127 }; |
137 | 128 |
138 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ | 129 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ |
OLD | NEW |