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

Side by Side Diff: components/crx_file/id_util.cc

Issue 1279123004: Replace ToLower calls to the new format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « components/crx_file/crx_file.cc ('k') | components/device_event_log/device_event_log_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/crx_file/id_util.h" 5 #include "components/crx_file/id_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.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 22 matching lines...) Expand all
33 namespace crx_file { 33 namespace crx_file {
34 namespace id_util { 34 namespace id_util {
35 35
36 // First 16 bytes of SHA256 hashed public key. 36 // First 16 bytes of SHA256 hashed public key.
37 const size_t kIdSize = 16; 37 const size_t kIdSize = 16;
38 38
39 std::string GenerateId(const std::string& input) { 39 std::string GenerateId(const std::string& input) {
40 uint8 hash[kIdSize]; 40 uint8 hash[kIdSize];
41 crypto::SHA256HashString(input, hash, sizeof(hash)); 41 crypto::SHA256HashString(input, hash, sizeof(hash));
42 std::string output = 42 std::string output =
43 base::StringToLowerASCII(base::HexEncode(hash, sizeof(hash))); 43 base::ToLowerASCII(base::HexEncode(hash, sizeof(hash)));
44 ConvertHexadecimalToIDAlphabet(&output); 44 ConvertHexadecimalToIDAlphabet(&output);
45 45
46 return output; 46 return output;
47 } 47 }
48 48
49 std::string GenerateIdForPath(const base::FilePath& path) { 49 std::string GenerateIdForPath(const base::FilePath& path) {
50 base::FilePath new_path = MaybeNormalizePath(path); 50 base::FilePath new_path = MaybeNormalizePath(path);
51 std::string path_bytes = 51 std::string path_bytes =
52 std::string(reinterpret_cast<const char*>(new_path.value().data()), 52 std::string(reinterpret_cast<const char*>(new_path.value().data()),
53 new_path.value().size() * sizeof(base::FilePath::CharType)); 53 new_path.value().size() * sizeof(base::FilePath::CharType));
(...skipping 22 matching lines...) Expand all
76 #endif 76 #endif
77 } 77 }
78 78
79 bool IdIsValid(const std::string& id) { 79 bool IdIsValid(const std::string& id) {
80 // Verify that the id is legal. 80 // Verify that the id is legal.
81 if (id.size() != (crx_file::id_util::kIdSize * 2)) 81 if (id.size() != (crx_file::id_util::kIdSize * 2))
82 return false; 82 return false;
83 83
84 // We only support lowercase IDs, because IDs can be used as URL components 84 // We only support lowercase IDs, because IDs can be used as URL components
85 // (where GURL will lowercase it). 85 // (where GURL will lowercase it).
86 std::string temp = base::StringToLowerASCII(id); 86 std::string temp = base::ToLowerASCII(id);
87 for (size_t i = 0; i < temp.size(); i++) 87 for (size_t i = 0; i < temp.size(); i++)
88 if (temp[i] < 'a' || temp[i] > 'p') 88 if (temp[i] < 'a' || temp[i] > 'p')
89 return false; 89 return false;
90 90
91 return true; 91 return true;
92 } 92 }
93 93
94 } // namespace id_util 94 } // namespace id_util
95 } // namespace crx_file 95 } // namespace crx_file
OLDNEW
« no previous file with comments | « components/crx_file/crx_file.cc ('k') | components/device_event_log/device_event_log_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698