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_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ | 5 #ifndef CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ |
6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ | 6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <string> | 10 #include <string> |
(...skipping 16 matching lines...) Expand all Loading... |
27 // perspective. These can be persisted to prefs, in a 1:1 mapping between | 27 // perspective. These can be persisted to prefs, in a 1:1 mapping between |
28 // app_id (which includes origin) and service_worker_registration_id. | 28 // app_id (which includes origin) and service_worker_registration_id. |
29 // Legacy mapped values saved by old versions of Chrome are also supported; | 29 // Legacy mapped values saved by old versions of Chrome are also supported; |
30 // these don't contain the origin in the app_id, so instead they map from | 30 // these don't contain the origin in the app_id, so instead they map from |
31 // app_id to pair<origin, service_worker_registration_id>. | 31 // app_id to pair<origin, service_worker_registration_id>. |
32 class PushMessagingAppIdentifier { | 32 class PushMessagingAppIdentifier { |
33 public: | 33 public: |
34 // Register profile-specific prefs. | 34 // Register profile-specific prefs. |
35 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 35 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
36 | 36 |
| 37 // Returns whether the modern InstanceID API should be used with this app_id |
| 38 // (rather than legacy GCM registration). |
| 39 static bool UseInstanceID(const std::string& app_id); |
| 40 |
37 // Generates a new app identifier, with partially random app_id. | 41 // Generates a new app identifier, with partially random app_id. |
38 static PushMessagingAppIdentifier Generate( | 42 static PushMessagingAppIdentifier Generate( |
39 const GURL& origin, | 43 const GURL& origin, |
40 int64_t service_worker_registration_id); | 44 int64_t service_worker_registration_id); |
41 | 45 |
42 // Looks up an app identifier by app_id. If not found, is_null() will be true. | 46 // Looks up an app identifier by app_id. If not found, is_null() will be true. |
43 static PushMessagingAppIdentifier FindByAppId(Profile* profile, | 47 static PushMessagingAppIdentifier FindByAppId(Profile* profile, |
44 const std::string& app_id); | 48 const std::string& app_id); |
45 | 49 |
46 // Looks up an app identifier by origin & service worker registration id. | 50 // Looks up an app identifier by origin & service worker registration id. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 106 |
103 // Validates that all the fields contain valid values. | 107 // Validates that all the fields contain valid values. |
104 void DCheckValid() const; | 108 void DCheckValid() const; |
105 | 109 |
106 std::string app_id_; | 110 std::string app_id_; |
107 GURL origin_; | 111 GURL origin_; |
108 int64_t service_worker_registration_id_; | 112 int64_t service_worker_registration_id_; |
109 }; | 113 }; |
110 | 114 |
111 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ | 115 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ |
OLD | NEW |