Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: chrome/browser/extensions/api/music_manager_private/device_id.cc

Issue 448853002: Move StringToLowerASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/extensions/api/music_manager_private/device_id.h" 5 #include "chrome/browser/extensions/api/music_manager_private/device_id.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "crypto/hmac.h" 11 #include "crypto/hmac.h"
12 12
13 namespace { 13 namespace {
14 14
15 using extensions::api::DeviceId; 15 using extensions::api::DeviceId;
16 16
17 // Compute HMAC-SHA256(|key|, |text|) as a string. 17 // Compute HMAC-SHA256(|key|, |text|) as a string.
18 bool ComputeHmacSha256(const std::string& key, 18 bool ComputeHmacSha256(const std::string& key,
19 const std::string& text, 19 const std::string& text,
20 std::string* signature_return) { 20 std::string* signature_return) {
21 crypto::HMAC hmac(crypto::HMAC::SHA256); 21 crypto::HMAC hmac(crypto::HMAC::SHA256);
22 const size_t digest_length = hmac.DigestLength(); 22 const size_t digest_length = hmac.DigestLength();
23 std::vector<uint8> digest(digest_length); 23 std::vector<uint8> digest(digest_length);
24 bool result = hmac.Init(key) && 24 bool result = hmac.Init(key) &&
25 hmac.Sign(text, &digest[0], digest.size()); 25 hmac.Sign(text, &digest[0], digest.size());
26 if (result) { 26 if (result) {
27 *signature_return = StringToLowerASCII(base::HexEncode(digest.data(), 27 *signature_return = base::StringToLowerASCII(
28 digest.size())); 28 base::HexEncode(digest.data(), digest.size()));
29 } 29 }
30 return result; 30 return result;
31 } 31 }
32 32
33 void GetRawDeviceIdCallback(const std::string& extension_id, 33 void GetRawDeviceIdCallback(const std::string& extension_id,
34 const DeviceId::IdCallback& callback, 34 const DeviceId::IdCallback& callback,
35 const std::string& raw_device_id) { 35 const std::string& raw_device_id) {
36 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 36 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
37 37
38 if (raw_device_id.empty()) { 38 if (raw_device_id.empty()) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 GetRawDeviceId(base::Bind(&GetRawDeviceIdCallback, extension_id, callback)); 187 GetRawDeviceId(base::Bind(&GetRawDeviceIdCallback, extension_id, callback));
188 } 188 }
189 189
190 // static 190 // static
191 bool DeviceId::IsValidMacAddress(const void* bytes, size_t size) { 191 bool DeviceId::IsValidMacAddress(const void* bytes, size_t size) {
192 return IsValidMacAddressImpl(bytes, size); 192 return IsValidMacAddressImpl(bytes, size);
193 } 193 }
194 194
195 } // namespace api 195 } // namespace api
196 } // namespace extensions 196 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/gcm/gcm_api.cc ('k') | chrome/browser/extensions/api/music_manager_private/device_id_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698