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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 if (!base::StartsWith(app_id, kPushMessagingAppIdentifierPrefix, | 79 if (!base::StartsWith(app_id, kPushMessagingAppIdentifierPrefix, |
80 base::CompareCase::INSENSITIVE_ASCII)) { | 80 base::CompareCase::INSENSITIVE_ASCII)) { |
81 return PushMessagingAppIdentifier(); | 81 return PushMessagingAppIdentifier(); |
82 } | 82 } |
83 | 83 |
84 // Since we now know this is a Push Messaging app_id, check the case hasn't | 84 // Since we now know this is a Push Messaging app_id, check the case hasn't |
85 // been mangled (crbug.com/461867). | 85 // been mangled (crbug.com/461867). |
86 DCHECK_EQ(kPushMessagingAppIdentifierPrefix, app_id.substr(0, kPrefixLength)); | 86 DCHECK_EQ(kPushMessagingAppIdentifierPrefix, app_id.substr(0, kPrefixLength)); |
87 DCHECK_GE(app_id.size(), kPrefixLength + kGuidLength); | 87 DCHECK_GE(app_id.size(), kPrefixLength + kGuidLength); |
88 DCHECK_EQ(app_id.substr(app_id.size() - kGuidLength), | 88 DCHECK_EQ(app_id.substr(app_id.size() - kGuidLength), |
89 base::StringToUpperASCII( | 89 base::ToUpperASCII(app_id.substr(app_id.size() - kGuidLength))); |
90 app_id.substr(app_id.size() - kGuidLength))); | |
91 | 90 |
92 const base::DictionaryValue* map = | 91 const base::DictionaryValue* map = |
93 profile->GetPrefs()->GetDictionary(prefs::kPushMessagingAppIdentifierMap); | 92 profile->GetPrefs()->GetDictionary(prefs::kPushMessagingAppIdentifierMap); |
94 | 93 |
95 std::string map_value; | 94 std::string map_value; |
96 if (!map->GetStringWithoutPathExpansion(app_id, &map_value)) | 95 if (!map->GetStringWithoutPathExpansion(app_id, &map_value)) |
97 return PushMessagingAppIdentifier(); | 96 return PushMessagingAppIdentifier(); |
98 | 97 |
99 GURL origin; | 98 GURL origin; |
100 int64_t service_worker_registration_id; | 99 int64_t service_worker_registration_id; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 const size_t suffix_length = 1 /* kSeparator */ + kGuidLength; | 200 const size_t suffix_length = 1 /* kSeparator */ + kGuidLength; |
202 DCHECK(app_id_.size() > kPrefixLength + suffix_length); | 201 DCHECK(app_id_.size() > kPrefixLength + suffix_length); |
203 DCHECK_EQ(origin_, GURL(app_id_.substr( | 202 DCHECK_EQ(origin_, GURL(app_id_.substr( |
204 kPrefixLength, app_id_.size() - kPrefixLength - suffix_length))); | 203 kPrefixLength, app_id_.size() - kPrefixLength - suffix_length))); |
205 DCHECK_EQ(std::string(1, kSeparator), | 204 DCHECK_EQ(std::string(1, kSeparator), |
206 app_id_.substr(app_id_.size() - suffix_length, 1)); | 205 app_id_.substr(app_id_.size() - suffix_length, 1)); |
207 } | 206 } |
208 // GUID | 207 // GUID |
209 DCHECK(base::IsValidGUID(app_id_.substr(app_id_.size() - kGuidLength))); | 208 DCHECK(base::IsValidGUID(app_id_.substr(app_id_.size() - kGuidLength))); |
210 } | 209 } |
OLD | NEW |