Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: chrome/browser/notifications/platform_notification_service_impl.h

Issue 1292003004: Elide origins displayed on web notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(PlatformNotificationServiceTest,
94 CreateNotificationFromData);
93 FRIEND_TEST_ALL_PREFIXES( 95 FRIEND_TEST_ALL_PREFIXES(
94 PlatformNotificationServiceTest, DisplayNameForOrigin); 96 PlatformNotificationServiceTest, DisplayNameForOrigin);
95 FRIEND_TEST_ALL_PREFIXES(PlatformNotificationServiceTest, 97 FRIEND_TEST_ALL_PREFIXES(PlatformNotificationServiceTest,
96 TestWebOriginDisplayName); 98 TestWebOriginDisplayName);
97 99
98 PlatformNotificationServiceImpl(); 100 PlatformNotificationServiceImpl();
99 ~PlatformNotificationServiceImpl() override; 101 ~PlatformNotificationServiceImpl() override;
100 102
101 // Creates a new Web Notification-based Notification object. 103 // Creates a new Web Notification-based Notification object.
102 // TODO(peter): |delegate| can be a scoped_refptr, but properly passing this 104 // TODO(peter): |delegate| can be a scoped_refptr, but properly passing this
103 // through requires changing a whole lot of Notification constructor calls. 105 // through requires changing a whole lot of Notification constructor calls.
104 Notification CreateNotificationFromData( 106 Notification CreateNotificationFromData(
105 Profile* profile, 107 Profile* profile,
106 const GURL& origin, 108 const GURL& origin,
107 const SkBitmap& icon, 109 const SkBitmap& icon,
108 const content::PlatformNotificationData& notification_data, 110 const content::PlatformNotificationData& notification_data,
109 NotificationDelegate* delegate) const; 111 NotificationDelegate* delegate) const;
110 112
111 // Overrides the Notification UI Manager to use to |manager|. Only to be 113 // Overrides the Notification UI Manager to use to |manager|. Only to be
112 // used by tests. Tests are responsible for cleaning up after themselves. 114 // used by tests. Tests are responsible for cleaning up after themselves.
113 void SetNotificationUIManagerForTesting(NotificationUIManager* manager); 115 void SetNotificationUIManagerForTesting(NotificationUIManager* manager);
114 116
115 // Returns a display name for an origin, to be used in permission infobar or 117 // Returns a display name for an origin, to be used in permission infobar or
116 // on the frame of the notification toast. Different from the origin itself 118 // on the frame of the notification toast. Different from the origin itself
117 // when dealing with extensions. 119 // when dealing with extensions.
118 base::string16 DisplayNameForOrigin(Profile* profile, 120 std::string DisplayNameForOrigin(Profile* profile, const GURL& origin) const;
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 121
128 // Weak reference. Ownership maintains with the test. 122 // Weak reference. Ownership maintains with the test.
129 NotificationUIManager* notification_ui_manager_for_tests_; 123 NotificationUIManager* notification_ui_manager_for_tests_;
130 124
131 // Mapping between a persistent notification id and the id of the associated 125 // 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. 126 // message_center::Notification object. Must only be used on the UI thread.
133 std::map<int64_t, std::string> persistent_notifications_; 127 std::map<int64_t, std::string> persistent_notifications_;
134 128
135 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); 129 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl);
136 }; 130 };
137 131
138 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ 132 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698