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

Side by Side Diff: components/signin/core/webdata/token_service_table.cc

Issue 183953005: Rename components's Encryptor to OSEncrypt. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: similarity Created 6 years, 9 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 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/signin/core/webdata/token_service_table.h" 5 #include "components/signin/core/webdata/token_service_table.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "components/encryptor/encryptor.h" 11 #include "components/encryptor/os_crypt.h"
12 #include "components/webdata/common/web_database.h" 12 #include "components/webdata/common/web_database.h"
13 #include "sql/statement.h" 13 #include "sql/statement.h"
14 14
15 namespace { 15 namespace {
16 16
17 WebDatabaseTable::TypeKey GetKey() { 17 WebDatabaseTable::TypeKey GetKey() {
18 // We just need a unique constant. Use the address of a static that 18 // We just need a unique constant. Use the address of a static that
19 // COMDAT folding won't touch in an optimizing linker. 19 // COMDAT folding won't touch in an optimizing linker.
20 static int table_key = 0; 20 static int table_key = 0;
21 return reinterpret_cast<void*>(&table_key); 21 return reinterpret_cast<void*>(&table_key);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 sql::Statement s(db_->GetUniqueStatement( 65 sql::Statement s(db_->GetUniqueStatement(
66 "DELETE FROM token_service WHERE service = ?")); 66 "DELETE FROM token_service WHERE service = ?"));
67 s.BindString(0, service); 67 s.BindString(0, service);
68 68
69 return s.Run(); 69 return s.Run();
70 } 70 }
71 71
72 bool TokenServiceTable::SetTokenForService(const std::string& service, 72 bool TokenServiceTable::SetTokenForService(const std::string& service,
73 const std::string& token) { 73 const std::string& token) {
74 std::string encrypted_token; 74 std::string encrypted_token;
75 bool encrypted = Encryptor::EncryptString(token, &encrypted_token); 75 bool encrypted = OSCrypt::EncryptString(token, &encrypted_token);
76 if (!encrypted) { 76 if (!encrypted) {
77 return false; 77 return false;
78 } 78 }
79 79
80 // Don't bother with a cached statement since this will be a relatively 80 // Don't bother with a cached statement since this will be a relatively
81 // infrequent operation. 81 // infrequent operation.
82 sql::Statement s(db_->GetUniqueStatement( 82 sql::Statement s(db_->GetUniqueStatement(
83 "INSERT OR REPLACE INTO token_service " 83 "INSERT OR REPLACE INTO token_service "
84 "(service, encrypted_token) VALUES (?, ?)")); 84 "(service, encrypted_token) VALUES (?, ?)"));
85 s.BindString(0, service); 85 s.BindString(0, service);
(...skipping 12 matching lines...) Expand all
98 return false; 98 return false;
99 99
100 while (s.Step()) { 100 while (s.Step()) {
101 std::string encrypted_token; 101 std::string encrypted_token;
102 std::string decrypted_token; 102 std::string decrypted_token;
103 std::string service; 103 std::string service;
104 service = s.ColumnString(0); 104 service = s.ColumnString(0);
105 bool entry_ok = !service.empty() && 105 bool entry_ok = !service.empty() &&
106 s.ColumnBlobAsString(1, &encrypted_token); 106 s.ColumnBlobAsString(1, &encrypted_token);
107 if (entry_ok) { 107 if (entry_ok) {
108 Encryptor::DecryptString(encrypted_token, &decrypted_token); 108 OSCrypt::DecryptString(encrypted_token, &decrypted_token);
109 (*tokens)[service] = decrypted_token; 109 (*tokens)[service] = decrypted_token;
110 } else { 110 } else {
111 NOTREACHED(); 111 NOTREACHED();
112 return false; 112 return false;
113 } 113 }
114 } 114 }
115 return true; 115 return true;
116 } 116 }
OLDNEW
« no previous file with comments | « components/password_manager/core/browser/login_database_win.cc ('k') | components/sync_driver/system_encryptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698