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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/platform_notification_service_impl.h
diff --git a/chrome/browser/notifications/platform_notification_service_impl.h b/chrome/browser/notifications/platform_notification_service_impl.h
index c2d08d4041d73865d1be0e6163661c224fda8000..9a801cfc952811771a0d33af0c87dc4645f7cdaf 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.h
+++ b/chrome/browser/notifications/platform_notification_service_impl.h
@@ -5,9 +5,13 @@
#ifndef CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_
#define CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_
+#include "base/gtest_prod_util.h"
#include "base/memory/singleton.h"
#include "content/public/browser/platform_notification_service.h"
+class NotificationUIManager;
+class Profile;
+
// The platform notification service is the profile-agnostic entry point through
// which Web Notifications can be controlled.
class PlatformNotificationServiceImpl
@@ -17,6 +21,10 @@ class PlatformNotificationServiceImpl
// be called from any thread.
static PlatformNotificationServiceImpl* GetInstance();
+ // Returns the Notification UI Manager through which notifications can be
+ // displayed to the user. Can be overridden for testing.
+ NotificationUIManager* GetNotificationUIManager() const;
+
// content::PlatformNotificationService implementation.
blink::WebNotificationPermission CheckPermission(
content::ResourceContext* resource_context,
@@ -39,9 +47,28 @@ class PlatformNotificationServiceImpl
private:
friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>;
+ friend class PlatformNotificationServiceTest;
+ FRIEND_TEST_ALL_PREFIXES(
+ PlatformNotificationServiceTest, DisplayNameForOrigin);
PlatformNotificationServiceImpl();
~PlatformNotificationServiceImpl() override;
+
+ // Overrides the Notification UI Manager to use to |manager|. Only to be
+ // used by tests. Tests are responsible for cleaning up after themselves.
+ void SetNotificationUIManagerForTesting(NotificationUIManager* manager);
+
+ // Returns a display name for an origin in the process id, to be used in
+ // permission infobar or on the frame of the notification toast. Different
+ // from the origin itself when dealing with extensions.
+ base::string16 DisplayNameForOriginInProcessId(Profile* profile,
+ const GURL& origin,
+ int process_id);
+
+ // Weak reference. Ownership maintains with the test.
+ NotificationUIManager* notification_ui_manager_for_tests_;
+
+ DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl);
};
#endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698