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

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

Issue 787193002: Move logic for displaying notifications to the ProfileNotificationServiceImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-total
Patch Set: tests Created 6 years 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 "base/gtest_prod_util.h"
8 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
9 #include "content/public/browser/platform_notification_service.h" 10 #include "content/public/browser/platform_notification_service.h"
10 11
12 class NotificationUIManager;
13 class Profile;
14
11 // The platform notification service is the profile-agnostic entry point through 15 // The platform notification service is the profile-agnostic entry point through
12 // which Web Notifications can be controlled. 16 // which Web Notifications can be controlled.
13 class PlatformNotificationServiceImpl 17 class PlatformNotificationServiceImpl
14 : public content::PlatformNotificationService { 18 : public content::PlatformNotificationService {
15 public: 19 public:
16 // Returns the active instance of the service in the browser process. Safe to 20 // Returns the active instance of the service in the browser process. Safe to
17 // be called from any thread. 21 // be called from any thread.
18 static PlatformNotificationServiceImpl* GetInstance(); 22 static PlatformNotificationServiceImpl* GetInstance();
19 23
24 // Returns the Notification UI Manager through which notifications can be
25 // displayed to the user. Can be overridden for testing.
26 NotificationUIManager* GetNotificationUIManager() const;
27
20 // content::PlatformNotificationService implementation. 28 // content::PlatformNotificationService implementation.
21 blink::WebNotificationPermission CheckPermission( 29 blink::WebNotificationPermission CheckPermission(
22 content::ResourceContext* resource_context, 30 content::ResourceContext* resource_context,
23 const GURL& origin, 31 const GURL& origin,
24 int render_process_id) override;; 32 int render_process_id) override;;
25 void DisplayNotification( 33 void DisplayNotification(
26 content::BrowserContext* browser_context, 34 content::BrowserContext* browser_context,
27 const content::ShowDesktopNotificationHostMsgParams& params, 35 const content::ShowDesktopNotificationHostMsgParams& params,
28 scoped_ptr<content::DesktopNotificationDelegate> delegate, 36 scoped_ptr<content::DesktopNotificationDelegate> delegate,
29 int render_process_id, 37 int render_process_id,
30 base::Closure* cancel_callback) override; 38 base::Closure* cancel_callback) override;
31 void DisplayPersistentNotification( 39 void DisplayPersistentNotification(
32 content::BrowserContext* browser_context, 40 content::BrowserContext* browser_context,
33 int64 service_worker_registration_id, 41 int64 service_worker_registration_id,
34 const content::ShowDesktopNotificationHostMsgParams& params, 42 const content::ShowDesktopNotificationHostMsgParams& params,
35 int render_process_id) override; 43 int render_process_id) override;
36 void ClosePersistentNotification( 44 void ClosePersistentNotification(
37 content::BrowserContext* browser_context, 45 content::BrowserContext* browser_context,
38 const std::string& persistent_notification_id) override; 46 const std::string& persistent_notification_id) override;
39 47
40 private: 48 private:
41 friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>; 49 friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>;
50 friend class PlatformNotificationServiceTest;
51 FRIEND_TEST_ALL_PREFIXES(
52 PlatformNotificationServiceTest, DisplayNameForOrigin);
42 53
43 PlatformNotificationServiceImpl(); 54 PlatformNotificationServiceImpl();
44 ~PlatformNotificationServiceImpl() override; 55 ~PlatformNotificationServiceImpl() override;
56
57 // Overrides the Notification UI Manager to use to |manager|. Only to be
58 // used by tests. Tests are responsible for cleaning up after themselves.
59 void SetNotificationUIManagerForTesting(NotificationUIManager* manager);
60
61 // Returns a display name for an origin in the process id, to be used in
62 // permission infobar or on the frame of the notification toast. Different
63 // from the origin itself when dealing with extensions.
64 base::string16 DisplayNameForOriginInProcessId(Profile* profile,
65 const GURL& origin,
66 int process_id);
67
68 // Weak reference. Ownership maintains with the test.
69 NotificationUIManager* notification_ui_manager_for_tests_;
70
71 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl);
45 }; 72 };
46 73
47 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ 74 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698