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

Side by Side Diff: components/password_manager/content/browser/credential_manager_impl.cc

Issue 2083433002: Mojo: Remove url type converters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 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/password_manager/content/browser/credential_manager_impl.h" 5 #include "components/password_manager/content/browser/credential_manager_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "components/autofill/core/common/password_form.h" 12 #include "components/autofill/core/common/password_form.h"
13 #include "components/password_manager/content/browser/content_password_manager_d river.h" 13 #include "components/password_manager/content/browser/content_password_manager_d river.h"
14 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h" 14 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h"
15 #include "components/password_manager/content/public/cpp/type_converters.h" 15 #include "components/password_manager/content/public/cpp/type_converters.h"
16 #include "components/password_manager/core/browser/affiliated_match_helper.h" 16 #include "components/password_manager/core/browser/affiliated_match_helper.h"
17 #include "components/password_manager/core/browser/password_manager_client.h" 17 #include "components/password_manager/core/browser/password_manager_client.h"
18 #include "components/password_manager/core/browser/password_store.h" 18 #include "components/password_manager/core/browser/password_store.h"
19 #include "components/password_manager/core/common/credential_manager_types.h" 19 #include "components/password_manager/core/common/credential_manager_types.h"
20 #include "components/password_manager/core/common/password_manager_pref_names.h" 20 #include "components/password_manager/core/common/password_manager_pref_names.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "mojo/common/url_type_converters.h"
23 22
24 namespace password_manager { 23 namespace password_manager {
25 24
26 namespace { 25 namespace {
27 26
28 void RunMojoGetCallback(const mojom::CredentialManager::GetCallback& callback, 27 void RunMojoGetCallback(const mojom::CredentialManager::GetCallback& callback,
29 const CredentialInfo& info) { 28 const CredentialInfo& info) {
30 mojom::CredentialInfoPtr credential = mojom::CredentialInfo::From(info); 29 mojom::CredentialInfoPtr credential = mojom::CredentialInfo::From(info);
31 callback.Run(mojom::CredentialManagerError::SUCCESS, std::move(credential)); 30 callback.Run(mojom::CredentialManagerError::SUCCESS, std::move(credential));
32 } 31 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 pending_require_user_mediation_->AddOrigin( 142 pending_require_user_mediation_->AddOrigin(
144 web_contents()->GetLastCommittedURL().GetOrigin()); 143 web_contents()->GetLastCommittedURL().GetOrigin());
145 } 144 }
146 145
147 // Send acknowledge response back. 146 // Send acknowledge response back.
148 callback.Run(); 147 callback.Run();
149 } 148 }
150 149
151 void CredentialManagerImpl::Get(bool zero_click_only, 150 void CredentialManagerImpl::Get(bool zero_click_only,
152 bool include_passwords, 151 bool include_passwords,
153 mojo::Array<mojo::String> federations, 152 mojo::Array<GURL> federations,
154 const GetCallback& callback) { 153 const GetCallback& callback) {
155 PasswordStore* store = GetPasswordStore(); 154 PasswordStore* store = GetPasswordStore();
156 if (pending_request_ || !store) { 155 if (pending_request_ || !store) {
157 // Callback error. 156 // Callback error.
158 callback.Run(pending_request_ 157 callback.Run(pending_request_
159 ? mojom::CredentialManagerError::PENDINGREQUEST 158 ? mojom::CredentialManagerError::PENDINGREQUEST
160 : mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE, 159 : mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE,
161 nullptr); 160 nullptr);
162 return; 161 return;
163 } 162 }
164 163
165 // Return an empty credential if zero-click is required but disabled, or if 164 // Return an empty credential if zero-click is required but disabled, or if
166 // the current page has TLS errors. 165 // the current page has TLS errors.
167 if ((zero_click_only && !IsZeroClickAllowed()) || 166 if ((zero_click_only && !IsZeroClickAllowed()) ||
168 client_->DidLastPageLoadEncounterSSLErrors()) { 167 client_->DidLastPageLoadEncounterSSLErrors()) {
169 // Callback with empty credential info. 168 // Callback with empty credential info.
170 callback.Run(mojom::CredentialManagerError::SUCCESS, 169 callback.Run(mojom::CredentialManagerError::SUCCESS,
171 mojom::CredentialInfo::New()); 170 mojom::CredentialInfo::New());
172 return; 171 return;
173 } 172 }
174 173
175 if (store->affiliated_match_helper()) { 174 if (store->affiliated_match_helper()) {
176 store->affiliated_match_helper()->GetAffiliatedAndroidRealms( 175 store->affiliated_match_helper()->GetAffiliatedAndroidRealms(
177 GetSynthesizedFormForOrigin(), 176 GetSynthesizedFormForOrigin(),
178 base::Bind(&CredentialManagerImpl::ScheduleRequestTask, 177 base::Bind(&CredentialManagerImpl::ScheduleRequestTask,
179 weak_factory_.GetWeakPtr(), callback, zero_click_only, 178 weak_factory_.GetWeakPtr(), callback, zero_click_only,
180 include_passwords, federations.To<std::vector<GURL>>())); 179 include_passwords, federations.PassStorage()));
181 } else { 180 } else {
182 std::vector<std::string> no_affiliated_realms; 181 std::vector<std::string> no_affiliated_realms;
183 ScheduleRequestTask(callback, zero_click_only, include_passwords, 182 ScheduleRequestTask(callback, zero_click_only, include_passwords,
184 federations.To<std::vector<GURL>>(), 183 federations.PassStorage(), no_affiliated_realms);
185 no_affiliated_realms);
186 } 184 }
187 } 185 }
188 186
189 void CredentialManagerImpl::ScheduleRequestTask( 187 void CredentialManagerImpl::ScheduleRequestTask(
190 const GetCallback& callback, 188 const GetCallback& callback,
191 bool zero_click_only, 189 bool zero_click_only,
192 bool include_passwords, 190 bool include_passwords,
193 const std::vector<GURL>& federations, 191 const std::vector<GURL>& federations,
194 const std::vector<std::string>& android_realms) { 192 const std::vector<std::string>& android_realms) {
195 DCHECK(GetPasswordStore()); 193 DCHECK(GetPasswordStore());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 DCHECK(pending_require_user_mediation_); 273 DCHECK(pending_require_user_mediation_);
276 pending_require_user_mediation_.reset(); 274 pending_require_user_mediation_.reset();
277 } 275 }
278 276
279 bool CredentialManagerImpl::IsUpdatingCredentialAllowed() const { 277 bool CredentialManagerImpl::IsUpdatingCredentialAllowed() const {
280 return !client_->DidLastPageLoadEncounterSSLErrors() && 278 return !client_->DidLastPageLoadEncounterSSLErrors() &&
281 !client_->IsOffTheRecord(); 279 !client_->IsOffTheRecord();
282 } 280 }
283 281
284 } // namespace password_manager 282 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698