Chromium Code Reviews| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 blink::WebNotificationPermission CheckPermission( | 45 blink::WebNotificationPermission CheckPermission( |
| 46 content::ResourceContext* resource_context, | 46 content::ResourceContext* resource_context, |
| 47 const GURL& origin, | 47 const GURL& origin, |
| 48 int render_process_id) override; | 48 int render_process_id) override; |
| 49 void DisplayNotification( | 49 void DisplayNotification( |
| 50 content::BrowserContext* browser_context, | 50 content::BrowserContext* browser_context, |
| 51 const GURL& origin, | 51 const GURL& origin, |
| 52 const SkBitmap& icon, | 52 const SkBitmap& icon, |
| 53 const content::PlatformNotificationData& notification_data, | 53 const content::PlatformNotificationData& notification_data, |
| 54 scoped_ptr<content::DesktopNotificationDelegate> delegate, | 54 scoped_ptr<content::DesktopNotificationDelegate> delegate, |
| 55 int render_process_id, | |
| 56 base::Closure* cancel_callback) override; | 55 base::Closure* cancel_callback) override; |
| 57 void DisplayPersistentNotification( | 56 void DisplayPersistentNotification( |
| 58 content::BrowserContext* browser_context, | 57 content::BrowserContext* browser_context, |
| 59 int64 service_worker_registration_id, | 58 int64 service_worker_registration_id, |
| 60 const GURL& origin, | 59 const GURL& origin, |
| 61 const SkBitmap& icon, | 60 const SkBitmap& icon, |
| 62 const content::PlatformNotificationData& notification_data, | 61 const content::PlatformNotificationData& notification_data) override; |
| 63 int render_process_id) override; | |
| 64 void ClosePersistentNotification( | 62 void ClosePersistentNotification( |
| 65 content::BrowserContext* browser_context, | 63 content::BrowserContext* browser_context, |
| 66 const std::string& persistent_notification_id) override; | 64 const std::string& persistent_notification_id) override; |
| 67 | 65 |
| 68 private: | 66 private: |
| 69 friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>; | 67 friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>; |
| 70 friend class PlatformNotificationServiceBrowserTest; | 68 friend class PlatformNotificationServiceBrowserTest; |
| 71 friend class PlatformNotificationServiceTest; | 69 friend class PlatformNotificationServiceTest; |
| 72 FRIEND_TEST_ALL_PREFIXES( | 70 FRIEND_TEST_ALL_PREFIXES( |
| 73 PlatformNotificationServiceTest, DisplayNameForOrigin); | 71 PlatformNotificationServiceTest, DisplayNameForOrigin); |
| 72 FRIEND_TEST_ALL_PREFIXES(PlatformNotificationServiceTest, | |
| 73 TestWebOriginDisplayName); | |
| 74 | 74 |
| 75 PlatformNotificationServiceImpl(); | 75 PlatformNotificationServiceImpl(); |
| 76 ~PlatformNotificationServiceImpl() override; | 76 ~PlatformNotificationServiceImpl() override; |
| 77 | 77 |
| 78 // Creates a new Web Notification-based Notification object. | 78 // Creates a new Web Notification-based Notification object. |
| 79 // TODO(peter): |delegate| can be a scoped_refptr, but properly passing this | 79 // TODO(peter): |delegate| can be a scoped_refptr, but properly passing this |
| 80 // through requires changing a whole lot of Notification constructor calls. | 80 // through requires changing a whole lot of Notification constructor calls. |
| 81 Notification CreateNotificationFromData( | 81 Notification CreateNotificationFromData( |
| 82 Profile* profile, | 82 Profile* profile, |
| 83 const GURL& origin, | 83 const GURL& origin, |
| 84 const SkBitmap& icon, | 84 const SkBitmap& icon, |
| 85 const content::PlatformNotificationData& notification_data, | 85 const content::PlatformNotificationData& notification_data, |
| 86 NotificationDelegate* delegate, | 86 NotificationDelegate* delegate) const; |
| 87 int render_process_id) const; | |
| 88 | 87 |
| 89 // Overrides the Notification UI Manager to use to |manager|. Only to be | 88 // Overrides the Notification UI Manager to use to |manager|. Only to be |
| 90 // used by tests. Tests are responsible for cleaning up after themselves. | 89 // used by tests. Tests are responsible for cleaning up after themselves. |
| 91 void SetNotificationUIManagerForTesting(NotificationUIManager* manager); | 90 void SetNotificationUIManagerForTesting(NotificationUIManager* manager); |
| 92 | 91 |
| 93 // Returns a display name for an origin in the process id, to be used in | 92 // Returns a display name for an origin, to be used in permission infobar or |
| 94 // permission infobar or on the frame of the notification toast. Different | 93 // on the frame of the notification toast. Different from the origin itself |
| 95 // from the origin itself when dealing with extensions. | 94 // when dealing with extensions. |
| 96 base::string16 DisplayNameForOriginInProcessId(Profile* profile, | 95 base::string16 DisplayNameForOrigin(Profile* profile, |
| 97 const GURL& origin, | 96 const GURL& origin) const; |
| 98 int process_id) const; | 97 |
| 98 // Translates a URL into a slightly more readable version that may omit | |
| 99 // the port and scheme for common cases. | |
| 100 static base::string16 WebOriginDisplayName(const GURL& origin, | |
|
Peter Beverloo
2015/01/14 19:18:14
nit: TODO for future consolidation?
dewittj
2015/01/15 22:31:35
Done.
| |
| 101 const std::string& languages); | |
| 99 | 102 |
| 100 // Weak reference. Ownership maintains with the test. | 103 // Weak reference. Ownership maintains with the test. |
| 101 NotificationUIManager* notification_ui_manager_for_tests_; | 104 NotificationUIManager* notification_ui_manager_for_tests_; |
| 102 | 105 |
| 103 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); | 106 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); |
| 104 }; | 107 }; |
| 105 | 108 |
| 106 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ | 109 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ |
| OLD | NEW |