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_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ |
6 #define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "components/gcm_driver/gcm_app_handler.h" | 10 #include "components/gcm_driver/gcm_app_handler.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 const content::PushMessagingService::RegisterCallback& callback) override; | 66 const content::PushMessagingService::RegisterCallback& callback) override; |
67 // TODO(mvanouwerkerk): Delete once the Push API flows through platform. | 67 // TODO(mvanouwerkerk): Delete once the Push API flows through platform. |
68 // https://crbug.com/389194 | 68 // https://crbug.com/389194 |
69 blink::WebPushPermissionStatus GetPermissionStatus( | 69 blink::WebPushPermissionStatus GetPermissionStatus( |
70 const GURL& requesting_origin, | 70 const GURL& requesting_origin, |
71 int renderer_id, | 71 int renderer_id, |
72 int render_frame_id) override; | 72 int render_frame_id) override; |
73 blink::WebPushPermissionStatus GetPermissionStatus( | 73 blink::WebPushPermissionStatus GetPermissionStatus( |
74 const GURL& requesting_origin, | 74 const GURL& requesting_origin, |
75 const GURL& embedding_origin) override; | 75 const GURL& embedding_origin) override; |
76 void Unregister( | |
johnme
2014/12/15 12:07:16
Similarly here, please move this above the GetPerm
| |
77 const GURL& requesting_origin, | |
78 int64 service_worker_registration_id, | |
79 const content::PushMessagingService::UnregisterCallback&) override; | |
76 | 80 |
77 void SetProfileForTesting(Profile* profile); | 81 void SetProfileForTesting(Profile* profile); |
78 | 82 |
79 private: | 83 private: |
80 void IncreasePushRegistrationCount(int add); | 84 void IncreasePushRegistrationCount(int add); |
81 void DecreasePushRegistrationCount(int subtract); | 85 void DecreasePushRegistrationCount(int subtract); |
82 | 86 |
83 void DeliverMessageCallback(const PushMessagingApplicationId& application_id, | 87 void DeliverMessageCallback(const PushMessagingApplicationId& application_id, |
84 const GCMClient::IncomingMessage& message, | 88 const GCMClient::IncomingMessage& message, |
85 content::PushDeliveryStatus status); | 89 content::PushDeliveryStatus status); |
86 | 90 |
87 void RegisterEnd( | 91 void RegisterEnd( |
88 const content::PushMessagingService::RegisterCallback& callback, | 92 const content::PushMessagingService::RegisterCallback& callback, |
89 const std::string& registration_id, | 93 const std::string& registration_id, |
90 content::PushRegistrationStatus status); | 94 content::PushRegistrationStatus status); |
91 | 95 |
92 void DidRegister( | 96 void DidRegister( |
93 const content::PushMessagingService::RegisterCallback& callback, | 97 const content::PushMessagingService::RegisterCallback& callback, |
94 const std::string& registration_id, | 98 const std::string& registration_id, |
95 GCMClient::Result result); | 99 GCMClient::Result result); |
96 | 100 |
97 void DidRequestPermission( | 101 void DidRequestPermission( |
98 const PushMessagingApplicationId& application_id, | 102 const PushMessagingApplicationId& application_id, |
99 const std::string& sender_id, | 103 const std::string& sender_id, |
100 const content::PushMessagingService::RegisterCallback& callback, | 104 const content::PushMessagingService::RegisterCallback& callback, |
101 bool allow); | 105 bool allow); |
102 | 106 |
103 // TODO(mvanouwerkerk): this will need to be extended and move to the | 107 void Unregister(const PushMessagingApplicationId& application_id, |
104 // PushMessagingService interface later. | 108 const content::PushMessagingService::UnregisterCallback&); |
105 void Unregister(const PushMessagingApplicationId& application_id); | |
106 | 109 |
107 void DidUnregister(GCMClient::Result result); | 110 void DidUnregister(const content::PushMessagingService::UnregisterCallback&, |
111 GCMClient::Result result); | |
108 | 112 |
109 // Helper method that checks if a given origin is allowed to use Push. | 113 // Helper method that checks if a given origin is allowed to use Push. |
110 bool HasPermission(const GURL& origin); | 114 bool HasPermission(const GURL& origin); |
111 | 115 |
112 // Adds this service as an app handler to the GCMDriver if it has not been | 116 // Adds this service as an app handler to the GCMDriver if it has not been |
113 // added yet. | 117 // added yet. |
114 void AddAppHandlerIfNecessary(); | 118 void AddAppHandlerIfNecessary(); |
115 | 119 |
116 GCMProfileService* gcm_profile_service_; // It owns us. | 120 GCMProfileService* gcm_profile_service_; // It owns us. |
117 | 121 |
118 Profile* profile_; // It owns our owner. | 122 Profile* profile_; // It owns our owner. |
119 | 123 |
120 int push_registration_count_; | 124 int push_registration_count_; |
121 | 125 |
122 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; | 126 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; |
123 | 127 |
124 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); | 128 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); |
125 }; | 129 }; |
126 | 130 |
127 } // namespace gcm | 131 } // namespace gcm |
128 | 132 |
129 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ | 133 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ |
OLD | NEW |