Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / push_messaging / push_messaging_notification_manager.h
blob79f230878bd98c43a0e9c9e99c05763b749b5945
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_NOTIFICATION_MANAGER_H_
6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_NOTIFICATION_MANAGER_H_
8 #include <stdint.h>
9 #include <vector>
11 #include "base/callback_forward.h"
12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
15 class GURL;
16 class Profile;
18 namespace content {
19 struct NotificationDatabaseData;
20 struct PlatformNotificationData;
23 // Developers may be required to display a Web Notification in response to an
24 // incoming push message in order to clarify to the user that something has
25 // happened in the background. When they forget to do so, a default notification
26 // has to be displayed on their behalf.
28 // This class implements the heuristics for determining whether the default
29 // notification is necessary, as well as the functionality of displaying the
30 // default notification when it is.
32 // See the following document and bug for more context:
33 // https://docs.google.com/document/d/13VxFdLJbMwxHrvnpDm8RXnU41W2ZlcP0mdWWe9zXQT8/edit
34 // https://crbug.com/437277
35 class PushMessagingNotificationManager {
36 public:
37 explicit PushMessagingNotificationManager(Profile* profile);
38 ~PushMessagingNotificationManager();
40 // Enforces the requirements implied for push subscriptions which must display
41 // a Web Notification in response to an incoming message.
42 void EnforceUserVisibleOnlyRequirements(
43 const GURL& requesting_origin,
44 int64_t service_worker_registration_id,
45 const base::Closure& message_handled_closure);
47 private:
48 static void DidGetNotificationsFromDatabaseIOProxy(
49 const base::WeakPtr<PushMessagingNotificationManager>& ui_weak_ptr,
50 const GURL& requesting_origin,
51 int64_t service_worker_registration_id,
52 const base::Closure& message_handled_closure,
53 bool success,
54 const std::vector<content::NotificationDatabaseData>& data);
56 void DidGetNotificationsFromDatabase(
57 const GURL& requesting_origin,
58 int64_t service_worker_registration_id,
59 const base::Closure& message_handled_closure,
60 bool success,
61 const std::vector<content::NotificationDatabaseData>& data);
63 void DidGetNotificationsShownAndNeeded(
64 const GURL& requesting_origin,
65 int64_t service_worker_registration_id,
66 bool notification_shown,
67 bool notification_needed,
68 const base::Closure& message_handled_closure,
69 const std::string& data,
70 bool success,
71 bool not_found);
73 static void DidWriteNotificationDataIOProxy(
74 const base::WeakPtr<PushMessagingNotificationManager>& ui_weak_ptr,
75 const GURL& requesting_origin,
76 const content::PlatformNotificationData& notification_data,
77 const base::Closure& message_handled_closure,
78 bool success,
79 int64_t persistent_notification_id);
81 void DidWriteNotificationData(
82 const GURL& requesting_origin,
83 const content::PlatformNotificationData& notification_data,
84 const base::Closure& message_handled_closure,
85 bool success,
86 int64_t persistent_notification_id);
88 // Weak. This manager is owned by a keyed service on this profile.
89 Profile* profile_;
91 base::WeakPtrFactory<PushMessagingNotificationManager> weak_factory_;
93 DISALLOW_COPY_AND_ASSIGN(PushMessagingNotificationManager);
96 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_NOTIFICATION_MANAGER_H_