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

Side by Side Diff: components/password_manager/core/browser/password_reuse_detector.cc

Issue 2913323004: Implementation of sync password hash clearing. (Closed)
Patch Set: addressed reviewer's comments Created 3 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/password_manager/core/browser/password_reuse_detector.h" 5 #include "components/password_manager/core/browser/password_reuse_detector.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "components/autofill/core/common/password_form.h" 9 #include "components/autofill/core/common/password_form.h"
10 #include "components/password_manager/core/browser/password_manager_util.h" 10 #include "components/password_manager/core/browser/password_manager_util.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 const base::string16& password) { 130 const base::string16& password) {
131 sync_password_hash_ = 131 sync_password_hash_ =
132 password_manager_util::Calculate37BitsOfSHA256Hash(password); 132 password_manager_util::Calculate37BitsOfSHA256Hash(password);
133 if (prefs_) { 133 if (prefs_) {
134 // TODO(crbug.com/657041) Implement encrypting and saving of 134 // TODO(crbug.com/657041) Implement encrypting and saving of
135 // |sync_password_hash_| into preference kSyncPasswordHash. 135 // |sync_password_hash_| into preference kSyncPasswordHash.
136 prefs_->SetString(prefs::kSyncPasswordHash, std::string()); 136 prefs_->SetString(prefs::kSyncPasswordHash, std::string());
137 } 137 }
138 } 138 }
139 139
140 void PasswordReuseDetector::ClearSyncPasswordHash() {
141 sync_password_hash_.reset();
142 if (prefs_)
143 prefs_->ClearPref(prefs::kSyncPasswordHash);
144 }
145
140 void PasswordReuseDetector::AddPassword(const autofill::PasswordForm& form) { 146 void PasswordReuseDetector::AddPassword(const autofill::PasswordForm& form) {
141 if (form.password_value.size() < kMinPasswordLengthToCheck) 147 if (form.password_value.size() < kMinPasswordLengthToCheck)
142 return; 148 return;
143 GURL signon_realm(form.signon_realm); 149 GURL signon_realm(form.signon_realm);
144 const std::string domain = GetRegistryControlledDomain(signon_realm); 150 const std::string domain = GetRegistryControlledDomain(signon_realm);
145 std::set<std::string>& domains = passwords_[form.password_value]; 151 std::set<std::string>& domains = passwords_[form.password_value];
146 if (domains.find(domain) == domains.end()) { 152 if (domains.find(domain) == domains.end()) {
147 ++saved_passwords_; 153 ++saved_passwords_;
148 domains.insert(domain); 154 domains.insert(domain);
149 } 155 }
(...skipping 18 matching lines...) Expand all
168 174
169 // Otherwise the previous key is a candidate for password reuse. 175 // Otherwise the previous key is a candidate for password reuse.
170 if (it == passwords_.begin()) 176 if (it == passwords_.begin())
171 return passwords_.end(); 177 return passwords_.end();
172 178
173 --it; 179 --it;
174 return IsSuffix(input, it->first) ? it : passwords_.end(); 180 return IsSuffix(input, it->first) ? it : passwords_.end();
175 } 181 }
176 182
177 } // namespace password_manager 183 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698