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 "google_apis/gcm/engine/gservices_settings.h" | 5 #include "google_apis/gcm/engine/gservices_settings.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 ++iter) { | 189 ++iter) { |
190 data += iter->first; | 190 data += iter->first; |
191 data += '\0'; | 191 data += '\0'; |
192 data += iter->second; | 192 data += iter->second; |
193 data += '\0'; | 193 data += '\0'; |
194 } | 194 } |
195 base::SHA1HashBytes( | 195 base::SHA1HashBytes( |
196 reinterpret_cast<const unsigned char*>(&data[0]), data.size(), hash); | 196 reinterpret_cast<const unsigned char*>(&data[0]), data.size(), hash); |
197 std::string digest = | 197 std::string digest = |
198 kDigestVersionPrefix + base::HexEncode(hash, base::kSHA1Length); | 198 kDigestVersionPrefix + base::HexEncode(hash, base::kSHA1Length); |
199 digest = StringToLowerASCII(digest); | 199 digest = base::StringToLowerASCII(digest); |
200 return digest; | 200 return digest; |
201 } | 201 } |
202 | 202 |
203 GServicesSettings::GServicesSettings() : weak_ptr_factory_(this) { | 203 GServicesSettings::GServicesSettings() : weak_ptr_factory_(this) { |
204 digest_ = CalculateDigest(settings_); | 204 digest_ = CalculateDigest(settings_); |
205 } | 205 } |
206 | 206 |
207 GServicesSettings::~GServicesSettings() { | 207 GServicesSettings::~GServicesSettings() { |
208 } | 208 } |
209 | 209 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 } | 333 } |
334 | 334 |
335 GURL GServicesSettings::GetRegistrationURL() const { | 335 GURL GServicesSettings::GetRegistrationURL() const { |
336 SettingsMap::const_iterator iter = settings_.find(kRegistrationURLKey); | 336 SettingsMap::const_iterator iter = settings_.find(kRegistrationURLKey); |
337 if (iter == settings_.end() || iter->second.empty()) | 337 if (iter == settings_.end() || iter->second.empty()) |
338 return GURL(kDefaultRegistrationURL); | 338 return GURL(kDefaultRegistrationURL); |
339 return GURL(iter->second); | 339 return GURL(iter->second); |
340 } | 340 } |
341 | 341 |
342 } // namespace gcm | 342 } // namespace gcm |
OLD | NEW |