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" |
11 #include "base/prefs/pref_service.h" | |
12 #include "base/prefs/scoped_user_pref_update.h" | |
13 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
15 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
16 #include "base/values.h" | 14 #include "base/values.h" |
17 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
19 #include "components/pref_registry/pref_registry_syncable.h" | 17 #include "components/pref_registry/pref_registry_syncable.h" |
| 18 #include "components/prefs/pref_service.h" |
| 19 #include "components/prefs/scoped_user_pref_update.h" |
20 | 20 |
21 const char kPushMessagingAppIdentifierPrefix[] = "wp:"; | 21 const char kPushMessagingAppIdentifierPrefix[] = "wp:"; |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // sizeof is strlen + 1 since it's null-terminated. | 25 // sizeof is strlen + 1 since it's null-terminated. |
26 const size_t kPrefixLength = sizeof(kPushMessagingAppIdentifierPrefix) - 1; | 26 const size_t kPrefixLength = sizeof(kPushMessagingAppIdentifierPrefix) - 1; |
27 | 27 |
28 const char kSeparator = '#'; // Ok as only the origin of the url is used. | 28 const char kSeparator = '#'; // Ok as only the origin of the url is used. |
29 const size_t kGuidLength = 36; // "%08X-%04X-%04X-%04X-%012llX" | 29 const size_t kGuidLength = 36; // "%08X-%04X-%04X-%04X-%012llX" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 DCHECK(app_id_.size() > kPrefixLength + suffix_length); | 208 DCHECK(app_id_.size() > kPrefixLength + suffix_length); |
209 DCHECK_EQ(origin_, GURL(app_id_.substr( | 209 DCHECK_EQ(origin_, GURL(app_id_.substr( |
210 kPrefixLength, | 210 kPrefixLength, |
211 app_id_.size() - kPrefixLength - suffix_length))); | 211 app_id_.size() - kPrefixLength - suffix_length))); |
212 DCHECK_EQ(std::string(1, kSeparator), | 212 DCHECK_EQ(std::string(1, kSeparator), |
213 app_id_.substr(app_id_.size() - suffix_length, 1)); | 213 app_id_.substr(app_id_.size() - suffix_length, 1)); |
214 } | 214 } |
215 // GUID | 215 // GUID |
216 DCHECK(base::IsValidGUID(app_id_.substr(app_id_.size() - kGuidLength))); | 216 DCHECK(base::IsValidGUID(app_id_.substr(app_id_.size() - kGuidLength))); |
217 } | 217 } |
OLD | NEW |