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

Side by Side Diff: chrome/browser/services/gcm/push_messaging_service_impl.h

Issue 930083002: Unregister with push service and SW database when permission is lost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add copy ctor Created 5 years, 10 months 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_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/content_settings/core/browser/content_settings_observer.h"
10 #include "components/gcm_driver/gcm_app_handler.h" 11 #include "components/gcm_driver/gcm_app_handler.h"
11 #include "components/gcm_driver/gcm_client.h" 12 #include "components/gcm_driver/gcm_client.h"
12 #include "content/public/browser/push_messaging_service.h" 13 #include "content/public/browser/push_messaging_service.h"
13 #include "content/public/common/push_messaging_status.h" 14 #include "content/public/common/push_messaging_status.h"
14 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi ssionStatus.h" 15 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi ssionStatus.h"
15 16
16 class Profile; 17 class Profile;
17 18
18 namespace user_prefs { 19 namespace user_prefs {
19 class PrefRegistrySyncable; 20 class PrefRegistrySyncable;
20 } 21 }
21 22
22 namespace gcm { 23 namespace gcm {
23 24
24 class GCMProfileService; 25 class GCMProfileService;
25 class PushMessagingApplicationId; 26 class PushMessagingApplicationId;
26 27
27 class PushMessagingServiceImpl : public content::PushMessagingService, 28 class PushMessagingServiceImpl : public content::PushMessagingService,
28 public GCMAppHandler { 29 public GCMAppHandler,
30 public content_settings::Observer {
29 public: 31 public:
30 // Register profile-specific prefs for GCM. 32 // Register profile-specific prefs for GCM.
31 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 33 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
32 34
33 // If any Service Workers are using push, starts GCM and adds an app handler. 35 // If any Service Workers are using push, starts GCM and adds an app handler.
34 static void InitializeForProfile(Profile* profile); 36 static void InitializeForProfile(Profile* profile);
35 37
36 PushMessagingServiceImpl(GCMProfileService* gcm_profile_service, 38 PushMessagingServiceImpl(GCMProfileService* gcm_profile_service,
37 Profile* profile); 39 Profile* profile);
38 ~PushMessagingServiceImpl() override; 40 ~PushMessagingServiceImpl() override;
(...skipping 27 matching lines...) Expand all
66 const content::PushMessagingService::RegisterCallback& callback) override; 68 const content::PushMessagingService::RegisterCallback& callback) override;
67 void Unregister( 69 void Unregister(
68 const GURL& requesting_origin, 70 const GURL& requesting_origin,
69 int64 service_worker_registration_id, 71 int64 service_worker_registration_id,
70 bool retry_on_failure, 72 bool retry_on_failure,
71 const content::PushMessagingService::UnregisterCallback&) override; 73 const content::PushMessagingService::UnregisterCallback&) override;
72 blink::WebPushPermissionStatus GetPermissionStatus( 74 blink::WebPushPermissionStatus GetPermissionStatus(
73 const GURL& requesting_origin, 75 const GURL& requesting_origin,
74 const GURL& embedding_origin) override; 76 const GURL& embedding_origin) override;
75 77
78 // content_settings::Observer implementation.
79 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
80 const ContentSettingsPattern& secondary_pattern,
81 ContentSettingsType content_type,
82 std::string resource_identifier) override;
83
76 void SetProfileForTesting(Profile* profile); 84 void SetProfileForTesting(Profile* profile);
77 85
78 private: 86 private:
79 // A registration is pending until it has succeeded or failed. 87 // A registration is pending until it has succeeded or failed.
80 void IncreasePushRegistrationCount(int add, bool is_pending); 88 void IncreasePushRegistrationCount(int add, bool is_pending);
81 void DecreasePushRegistrationCount(int subtract, bool was_pending); 89 void DecreasePushRegistrationCount(int subtract, bool was_pending);
82 90
83 void DeliverMessageCallback(const std::string& app_id_guid, 91 void DeliverMessageCallback(const std::string& app_id_guid,
84 const GURL& requesting_origin, 92 const GURL& requesting_origin,
85 int64 service_worker_registration_id, 93 int64 service_worker_registration_id,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 int pending_push_registration_count_; 146 int pending_push_registration_count_;
139 147
140 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; 148 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_;
141 149
142 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); 150 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl);
143 }; 151 };
144 152
145 } // namespace gcm 153 } // namespace gcm
146 154
147 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ 155 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698