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

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

Issue 2912383004: Fill is_chrome_signin_password field in the password entry pings. (Closed)
Patch Set: Fix deps 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"
11 #include "components/password_manager/core/browser/password_reuse_detector_consu mer.h" 11 #include "components/password_manager/core/browser/password_reuse_detector_consu mer.h"
12 #include "components/password_manager/core/browser/psl_matching_helper.h" 12 #include "components/password_manager/core/browser/psl_matching_helper.h"
13 #include "components/password_manager/core/common/password_manager_pref_names.h" 13 #include "components/password_manager/core/common/password_manager_pref_names.h"
14 #include "components/prefs/pref_service.h" 14 #include "components/prefs/pref_service.h"
15 #include "components/safe_browsing/common/safebrowsing_constants.h"
15 #include "google_apis/gaia/gaia_auth_util.h" 16 #include "google_apis/gaia/gaia_auth_util.h"
16 #include "google_apis/gaia/gaia_urls.h" 17 #include "google_apis/gaia/gaia_urls.h"
17 #include "url/origin.h" 18 #include "url/origin.h"
18 19
19 using url::Origin; 20 using url::Origin;
20 21
21 namespace password_manager { 22 namespace password_manager {
22 23
23 namespace { 24 namespace {
24 // Minimum number of characters in a password for finding it as password reuse. 25 // Minimum number of characters in a password for finding it as password reuse.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 88
88 const Origin gaia_origin(GaiaUrls::GetInstance()->gaia_url().GetOrigin()); 89 const Origin gaia_origin(GaiaUrls::GetInstance()->gaia_url().GetOrigin());
89 if (Origin(GURL(domain)).IsSameOriginWith(gaia_origin)) 90 if (Origin(GURL(domain)).IsSameOriginWith(gaia_origin))
90 return false; 91 return false;
91 92
92 // Check that some suffix of |input| has the same hash as the sync password. 93 // Check that some suffix of |input| has the same hash as the sync password.
93 for (size_t i = 0; i + kMinPasswordLengthToCheck <= input.size(); ++i) { 94 for (size_t i = 0; i + kMinPasswordLengthToCheck <= input.size(); ++i) {
94 base::StringPiece16 input_suffix(input.c_str() + i, input.size() - i); 95 base::StringPiece16 input_suffix(input.c_str() + i, input.size() - i);
95 if (password_manager_util::Calculate37BitsOfSHA256Hash(input_suffix) == 96 if (password_manager_util::Calculate37BitsOfSHA256Hash(input_suffix) ==
96 sync_password_hash_.value()) { 97 sync_password_hash_.value()) {
97 consumer->OnReuseFound(input_suffix.as_string(), gaia_origin.host(), 1, 98 consumer->OnReuseFound(input_suffix.as_string(),
99 std::string(safe_browsing::kSyncPasswordDomain), 1,
98 0); 100 0);
99 return true; 101 return true;
100 } 102 }
101 } 103 }
102 104
103 return false; 105 return false;
104 } 106 }
105 107
106 bool PasswordReuseDetector::CheckSavedPasswordReuse( 108 bool PasswordReuseDetector::CheckSavedPasswordReuse(
107 const base::string16& input, 109 const base::string16& input,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 170
169 // Otherwise the previous key is a candidate for password reuse. 171 // Otherwise the previous key is a candidate for password reuse.
170 if (it == passwords_.begin()) 172 if (it == passwords_.begin())
171 return passwords_.end(); 173 return passwords_.end();
172 174
173 --it; 175 --it;
174 return IsSuffix(input, it->first) ? it : passwords_.end(); 176 return IsSuffix(input, it->first) ? it : passwords_.end();
175 } 177 }
176 178
177 } // namespace password_manager 179 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698