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 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" | 5 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 service_worker_registration_id); | 124 service_worker_registration_id); |
125 app_identifier.DCheckValid(); | 125 app_identifier.DCheckValid(); |
126 return app_identifier; | 126 return app_identifier; |
127 } | 127 } |
128 | 128 |
129 // static | 129 // static |
130 PushMessagingAppIdentifier PushMessagingAppIdentifier::FindByServiceWorker( | 130 PushMessagingAppIdentifier PushMessagingAppIdentifier::FindByServiceWorker( |
131 Profile* profile, | 131 Profile* profile, |
132 const GURL& origin, | 132 const GURL& origin, |
133 int64_t service_worker_registration_id) { | 133 int64_t service_worker_registration_id) { |
134 const base::StringValue pref_value = | 134 const base::Value pref_value = |
135 base::StringValue(MakePrefValue(origin, service_worker_registration_id)); | 135 base::Value(MakePrefValue(origin, service_worker_registration_id)); |
136 | 136 |
137 const base::DictionaryValue* map = | 137 const base::DictionaryValue* map = |
138 profile->GetPrefs()->GetDictionary(prefs::kPushMessagingAppIdentifierMap); | 138 profile->GetPrefs()->GetDictionary(prefs::kPushMessagingAppIdentifierMap); |
139 for (auto it = base::DictionaryValue::Iterator(*map); !it.IsAtEnd(); | 139 for (auto it = base::DictionaryValue::Iterator(*map); !it.IsAtEnd(); |
140 it.Advance()) { | 140 it.Advance()) { |
141 if (it.value().Equals(&pref_value)) | 141 if (it.value().Equals(&pref_value)) |
142 return FindByAppId(profile, it.key()); | 142 return FindByAppId(profile, it.key()); |
143 } | 143 } |
144 return PushMessagingAppIdentifier(); | 144 return PushMessagingAppIdentifier(); |
145 } | 145 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 if (UseInstanceID(app_id_)) { | 243 if (UseInstanceID(app_id_)) { |
244 DCHECK(!base::IsValidGUID(guid)); | 244 DCHECK(!base::IsValidGUID(guid)); |
245 | 245 |
246 // Replace suffix with valid hex so we can validate the rest of the string. | 246 // Replace suffix with valid hex so we can validate the rest of the string. |
247 guid = guid.replace(guid.size() - kGuidSuffixLength, kGuidSuffixLength, | 247 guid = guid.replace(guid.size() - kGuidSuffixLength, kGuidSuffixLength, |
248 kGuidSuffixLength, 'C'); | 248 kGuidSuffixLength, 'C'); |
249 } | 249 } |
250 DCHECK(base::IsValidGUID(guid)); | 250 DCHECK(base::IsValidGUID(guid)); |
251 #endif // DCHECK_IS_ON() | 251 #endif // DCHECK_IS_ON() |
252 } | 252 } |
OLD | NEW |