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

Side by Side Diff: components/webdata/encryptor/encryptor_win.cc

Issue 112433004: Update uses of UTF conversions in chrome_frame/, chromeos/, components/ to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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
« no previous file with comments | « components/webdata/encryptor/encryptor_unittest.cc ('k') | components/wifi/wifi_service_win.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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/webdata/encryptor/encryptor.h" 5 #include "components/webdata/encryptor/encryptor.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <wincrypt.h> 8 #include <wincrypt.h>
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 10
11 #pragma comment(lib, "crypt32.lib") 11 #pragma comment(lib, "crypt32.lib")
12 12
13 bool Encryptor::EncryptString16(const base::string16& plaintext, 13 bool Encryptor::EncryptString16(const base::string16& plaintext,
14 std::string* ciphertext) { 14 std::string* ciphertext) {
15 return EncryptString(UTF16ToUTF8(plaintext), ciphertext); 15 return EncryptString(base::UTF16ToUTF8(plaintext), ciphertext);
16 } 16 }
17 17
18 bool Encryptor::DecryptString16(const std::string& ciphertext, 18 bool Encryptor::DecryptString16(const std::string& ciphertext,
19 base::string16* plaintext) { 19 base::string16* plaintext) {
20 std::string utf8; 20 std::string utf8;
21 if (!DecryptString(ciphertext, &utf8)) 21 if (!DecryptString(ciphertext, &utf8))
22 return false; 22 return false;
23 23
24 *plaintext = UTF8ToUTF16(utf8); 24 *plaintext = base::UTF8ToUTF16(utf8);
25 return true; 25 return true;
26 } 26 }
27 27
28 bool Encryptor::EncryptString(const std::string& plaintext, 28 bool Encryptor::EncryptString(const std::string& plaintext,
29 std::string* ciphertext) { 29 std::string* ciphertext) {
30 DATA_BLOB input; 30 DATA_BLOB input;
31 input.pbData = const_cast<BYTE*>( 31 input.pbData = const_cast<BYTE*>(
32 reinterpret_cast<const BYTE*>(plaintext.data())); 32 reinterpret_cast<const BYTE*>(plaintext.data()));
33 input.cbData = static_cast<DWORD>(plaintext.length()); 33 input.cbData = static_cast<DWORD>(plaintext.length());
34 34
(...skipping 21 matching lines...) Expand all
56 DATA_BLOB output; 56 DATA_BLOB output;
57 BOOL result = CryptUnprotectData(&input, NULL, NULL, NULL, NULL, 57 BOOL result = CryptUnprotectData(&input, NULL, NULL, NULL, NULL,
58 0, &output); 58 0, &output);
59 if (!result) 59 if (!result)
60 return false; 60 return false;
61 61
62 plaintext->assign(reinterpret_cast<char*>(output.pbData), output.cbData); 62 plaintext->assign(reinterpret_cast<char*>(output.pbData), output.cbData);
63 LocalFree(output.pbData); 63 LocalFree(output.pbData);
64 return true; 64 return true;
65 } 65 }
OLDNEW
« no previous file with comments | « components/webdata/encryptor/encryptor_unittest.cc ('k') | components/wifi/wifi_service_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698