| 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 "content/public/browser/platform_notification_service.h" | 11 #include "content/public/browser/platform_notification_service.h" |
| 11 | 12 |
| 12 class NotificationUIManager; | 13 class NotificationUIManager; |
| 13 class Profile; | 14 class Profile; |
| 14 | 15 |
| 15 // The platform notification service is the profile-agnostic entry point through | 16 // The platform notification service is the profile-agnostic entry point through |
| 16 // which Web Notifications can be controlled. | 17 // which Web Notifications can be controlled. |
| 17 class PlatformNotificationServiceImpl | 18 class PlatformNotificationServiceImpl |
| 18 : public content::PlatformNotificationService { | 19 : public content::PlatformNotificationService { |
| 19 public: | 20 public: |
| 20 // Returns the active instance of the service in the browser process. Safe to | 21 // Returns the active instance of the service in the browser process. Safe to |
| 21 // be called from any thread. | 22 // be called from any thread. |
| 22 static PlatformNotificationServiceImpl* GetInstance(); | 23 static PlatformNotificationServiceImpl* GetInstance(); |
| 23 | 24 |
| 24 // Returns the Notification UI Manager through which notifications can be | 25 // Returns the Notification UI Manager through which notifications can be |
| 25 // displayed to the user. Can be overridden for testing. | 26 // displayed to the user. Can be overridden for testing. |
| 26 NotificationUIManager* GetNotificationUIManager() const; | 27 NotificationUIManager* GetNotificationUIManager() const; |
| 27 | 28 |
| 28 // content::PlatformNotificationService implementation. | 29 // content::PlatformNotificationService implementation. |
| 29 blink::WebNotificationPermission CheckPermission( | 30 blink::WebNotificationPermission CheckPermission( |
| 30 content::ResourceContext* resource_context, | 31 content::ResourceContext* resource_context, |
| 31 const GURL& origin, | 32 const GURL& origin, |
| 32 int render_process_id) override;; | 33 int render_process_id) override; |
| 33 void DisplayNotification( | 34 void DisplayNotification( |
| 34 content::BrowserContext* browser_context, | 35 content::BrowserContext* browser_context, |
| 35 const content::ShowDesktopNotificationHostMsgParams& params, | 36 const GURL& origin, |
| 37 const SkBitmap& icon, |
| 38 const content::PlatformNotificationData& notification_data, |
| 36 scoped_ptr<content::DesktopNotificationDelegate> delegate, | 39 scoped_ptr<content::DesktopNotificationDelegate> delegate, |
| 37 int render_process_id, | 40 int render_process_id, |
| 38 base::Closure* cancel_callback) override; | 41 base::Closure* cancel_callback) override; |
| 39 void DisplayPersistentNotification( | 42 void DisplayPersistentNotification( |
| 40 content::BrowserContext* browser_context, | 43 content::BrowserContext* browser_context, |
| 41 int64 service_worker_registration_id, | 44 int64 service_worker_registration_id, |
| 42 const content::ShowDesktopNotificationHostMsgParams& params, | 45 const GURL& origin, |
| 46 const SkBitmap& icon, |
| 47 const content::PlatformNotificationData& notification_data, |
| 43 int render_process_id) override; | 48 int render_process_id) override; |
| 44 void ClosePersistentNotification( | 49 void ClosePersistentNotification( |
| 45 content::BrowserContext* browser_context, | 50 content::BrowserContext* browser_context, |
| 46 const std::string& persistent_notification_id) override; | 51 const std::string& persistent_notification_id) override; |
| 47 | 52 |
| 48 private: | 53 private: |
| 49 friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>; | 54 friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>; |
| 50 friend class PlatformNotificationServiceTest; | 55 friend class PlatformNotificationServiceTest; |
| 51 FRIEND_TEST_ALL_PREFIXES( | 56 FRIEND_TEST_ALL_PREFIXES( |
| 52 PlatformNotificationServiceTest, DisplayNameForOrigin); | 57 PlatformNotificationServiceTest, DisplayNameForOrigin); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 65 const GURL& origin, | 70 const GURL& origin, |
| 66 int process_id); | 71 int process_id); |
| 67 | 72 |
| 68 // Weak reference. Ownership maintains with the test. | 73 // Weak reference. Ownership maintains with the test. |
| 69 NotificationUIManager* notification_ui_manager_for_tests_; | 74 NotificationUIManager* notification_ui_manager_for_tests_; |
| 70 | 75 |
| 71 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); | 76 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); |
| 72 }; | 77 }; |
| 73 | 78 |
| 74 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ | 79 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ |
| OLD | NEW |