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

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

Issue 2716583003: Rename Origin.unique() to opaque().
Patch Set: Update new uses post-rebase Created 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/credential_manager_pending_re quest_task.h" 5 #include "components/password_manager/core/browser/credential_manager_pending_re quest_task.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // Remove duplicates in |forms| before displaying them in the account chooser. 64 // Remove duplicates in |forms| before displaying them in the account chooser.
65 void FilterDuplicates( 65 void FilterDuplicates(
66 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) { 66 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) {
67 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_forms; 67 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_forms;
68 // The key is [username, signon_realm]. signon_realm is used only for PSL 68 // The key is [username, signon_realm]. signon_realm is used only for PSL
69 // matches because those entries have it in the UI. 69 // matches because those entries have it in the UI.
70 std::map<std::pair<base::string16, std::string>, 70 std::map<std::pair<base::string16, std::string>,
71 std::unique_ptr<autofill::PasswordForm>> 71 std::unique_ptr<autofill::PasswordForm>>
72 credentials; 72 credentials;
73 for (auto& form : *forms) { 73 for (auto& form : *forms) {
74 if (!form->federation_origin.unique()) { 74 if (!form->federation_origin.opaque()) {
75 federated_forms.push_back(std::move(form)); 75 federated_forms.push_back(std::move(form));
76 } else { 76 } else {
77 auto key = std::make_pair( 77 auto key = std::make_pair(
78 form->username_value, 78 form->username_value,
79 form->is_public_suffix_match ? form->signon_realm : std::string()); 79 form->is_public_suffix_match ? form->signon_realm : std::string());
80 auto it = credentials.find(key); 80 auto it = credentials.find(key);
81 if (it == credentials.end() || IsBetterMatch(*form, *it->second)) 81 if (it == credentials.end() || IsBetterMatch(*form, *it->second))
82 credentials[key] = std::move(form); 82 credentials[key] = std::move(form);
83 } 83 }
84 } 84 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 mediation_); 154 mediation_);
155 delegate_->SendCredential(send_callback_, CredentialInfo()); 155 delegate_->SendCredential(send_callback_, CredentialInfo());
156 return; 156 return;
157 } 157 }
158 158
159 std::vector<std::unique_ptr<autofill::PasswordForm>> local_results; 159 std::vector<std::unique_ptr<autofill::PasswordForm>> local_results;
160 std::vector<std::unique_ptr<autofill::PasswordForm>> psl_results; 160 std::vector<std::unique_ptr<autofill::PasswordForm>> psl_results;
161 for (auto& form : results) { 161 for (auto& form : results) {
162 // Ensure that the form we're looking at matches the password and 162 // Ensure that the form we're looking at matches the password and
163 // federation filters provided. 163 // federation filters provided.
164 if (!((form->federation_origin.unique() && include_passwords_) || 164 if (!((form->federation_origin.opaque() && include_passwords_) ||
165 (!form->federation_origin.unique() && 165 (!form->federation_origin.opaque() &&
166 federations_.count(form->federation_origin.Serialize())))) { 166 federations_.count(form->federation_origin.Serialize())))) {
167 continue; 167 continue;
168 } 168 }
169 169
170 // PasswordFrom and GURL have different definition of origin. 170 // PasswordFrom and GURL have different definition of origin.
171 // PasswordForm definition: scheme, host, port and path. 171 // PasswordForm definition: scheme, host, port and path.
172 // GURL definition: scheme, host, and port. 172 // GURL definition: scheme, host, and port.
173 // So we can't compare them directly. 173 // So we can't compare them directly.
174 if (form->is_affiliation_based_match || 174 if (form->is_affiliation_based_match ||
175 form->origin.GetOrigin() == origin_.GetOrigin()) { 175 form->origin.GetOrigin() == origin_.GetOrigin()) {
(...skipping 15 matching lines...) Expand all
191 // 191 //
192 // Moreover, we only return such a credential if the user has opted-in via the 192 // Moreover, we only return such a credential if the user has opted-in via the
193 // first-run experience. 193 // first-run experience.
194 const bool can_use_autosignin = 194 const bool can_use_autosignin =
195 mediation_ != CredentialMediationRequirement::kRequired && 195 mediation_ != CredentialMediationRequirement::kRequired &&
196 local_results.size() == 1u && delegate_->IsZeroClickAllowed(); 196 local_results.size() == 1u && delegate_->IsZeroClickAllowed();
197 if (can_use_autosignin && !local_results[0]->skip_zero_click && 197 if (can_use_autosignin && !local_results[0]->skip_zero_click &&
198 !password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( 198 !password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience(
199 delegate_->client()->GetPrefs())) { 199 delegate_->client()->GetPrefs())) {
200 CredentialInfo info(*local_results[0], 200 CredentialInfo info(*local_results[0],
201 local_results[0]->federation_origin.unique() 201 local_results[0]->federation_origin.opaque()
202 ? CredentialType::CREDENTIAL_TYPE_PASSWORD 202 ? CredentialType::CREDENTIAL_TYPE_PASSWORD
203 : CredentialType::CREDENTIAL_TYPE_FEDERATED); 203 : CredentialType::CREDENTIAL_TYPE_FEDERATED);
204 delegate_->client()->NotifyUserAutoSignin(std::move(local_results), 204 delegate_->client()->NotifyUserAutoSignin(std::move(local_results),
205 origin_); 205 origin_);
206 base::RecordAction(base::UserMetricsAction("CredentialManager_Autosignin")); 206 base::RecordAction(base::UserMetricsAction("CredentialManager_Autosignin"));
207 LogCredentialManagerGetResult( 207 LogCredentialManagerGetResult(
208 metrics_util::CREDENTIAL_MANAGER_GET_AUTOSIGNIN, mediation_); 208 metrics_util::CREDENTIAL_MANAGER_GET_AUTOSIGNIN, mediation_);
209 delegate_->SendCredential(send_callback_, info); 209 delegate_->SendCredential(send_callback_, info);
210 return; 210 return;
211 } 211 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 base::Bind( 257 base::Bind(
258 &CredentialManagerPendingRequestTaskDelegate::SendPasswordForm, 258 &CredentialManagerPendingRequestTaskDelegate::SendPasswordForm,
259 base::Unretained(delegate_), send_callback_, mediation_))) { 259 base::Unretained(delegate_), send_callback_, mediation_))) {
260 LogCredentialManagerGetResult(metrics_util::CREDENTIAL_MANAGER_GET_NONE, 260 LogCredentialManagerGetResult(metrics_util::CREDENTIAL_MANAGER_GET_NONE,
261 mediation_); 261 mediation_);
262 delegate_->SendCredential(send_callback_, CredentialInfo()); 262 delegate_->SendCredential(send_callback_, CredentialInfo());
263 } 263 }
264 } 264 }
265 265
266 } // namespace password_manager 266 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698