OLD | NEW |
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_dispatc
her.h" | 5 #include "components/password_manager/content/browser/credential_manager_dispatc
her.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 void CredentialManagerDispatcher::OnNotifySignedIn( | 214 void CredentialManagerDispatcher::OnNotifySignedIn( |
215 int request_id, | 215 int request_id, |
216 const password_manager::CredentialInfo& credential) { | 216 const password_manager::CredentialInfo& credential) { |
217 DCHECK(credential.type != CredentialType::CREDENTIAL_TYPE_EMPTY); | 217 DCHECK(credential.type != CredentialType::CREDENTIAL_TYPE_EMPTY); |
218 DCHECK(request_id); | 218 DCHECK(request_id); |
219 web_contents()->GetRenderViewHost()->Send( | 219 web_contents()->GetRenderViewHost()->Send( |
220 new CredentialManagerMsg_AcknowledgeSignedIn( | 220 new CredentialManagerMsg_AcknowledgeSignedIn( |
221 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); | 221 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); |
222 | 222 |
223 if (!IsSavingEnabledForCurrentPage()) | 223 if (!client_->IsSavingEnabledForCurrentPage()) |
224 return; | 224 return; |
225 | 225 |
226 scoped_ptr<autofill::PasswordForm> form(CreatePasswordFormFromCredentialInfo( | 226 scoped_ptr<autofill::PasswordForm> form(CreatePasswordFormFromCredentialInfo( |
227 credential, web_contents()->GetLastCommittedURL().GetOrigin())); | 227 credential, web_contents()->GetLastCommittedURL().GetOrigin())); |
228 form->skip_zero_click = !IsZeroClickAllowed(); | 228 form->skip_zero_click = !IsZeroClickAllowed(); |
229 | 229 |
230 // TODO(mkwst): This is a stub; we should be checking the PasswordStore to | 230 // TODO(mkwst): This is a stub; we should be checking the PasswordStore to |
231 // determine whether or not the credential exists, and calling UpdateLogin | 231 // determine whether or not the credential exists, and calling UpdateLogin |
232 // accordingly. | 232 // accordingly. |
233 form_manager_.reset(new CredentialManagerPasswordFormManager( | 233 form_manager_.reset(new CredentialManagerPasswordFormManager( |
234 client_, GetDriver(), *form, this)); | 234 client_, GetDriver(), *form, this)); |
235 } | 235 } |
236 | 236 |
237 void CredentialManagerDispatcher::OnProvisionalSaveComplete() { | 237 void CredentialManagerDispatcher::OnProvisionalSaveComplete() { |
238 DCHECK(form_manager_); | 238 DCHECK(form_manager_); |
239 client_->PromptUserToSavePassword( | 239 if (client_->IsSavingEnabledForCurrentPage() && |
240 form_manager_.Pass(), CredentialSourceType::CREDENTIAL_SOURCE_API); | 240 !form_manager_->IsBlacklisted()) { |
| 241 client_->PromptUserToSavePassword( |
| 242 form_manager_.Pass(), CredentialSourceType::CREDENTIAL_SOURCE_API); |
| 243 } |
241 } | 244 } |
242 | 245 |
243 void CredentialManagerDispatcher::OnNotifySignedOut(int request_id) { | 246 void CredentialManagerDispatcher::OnNotifySignedOut(int request_id) { |
244 DCHECK(request_id); | 247 DCHECK(request_id); |
245 | 248 |
246 PasswordStore* store = GetPasswordStore(); | 249 PasswordStore* store = GetPasswordStore(); |
247 if (store) { | 250 if (store) { |
248 if (!pending_sign_out_) { | 251 if (!pending_sign_out_) { |
249 pending_sign_out_.reset(new PendingSignedOutTask( | 252 pending_sign_out_.reset(new PendingSignedOutTask( |
250 this, web_contents()->GetLastCommittedURL().GetOrigin())); | 253 this, web_contents()->GetLastCommittedURL().GetOrigin())); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 297 |
295 // This will result in a callback to | 298 // This will result in a callback to |
296 // PendingRequestTask::OnGetPasswordStoreResults(). | 299 // PendingRequestTask::OnGetPasswordStoreResults(). |
297 store->GetAutofillableLogins(pending_request_.get()); | 300 store->GetAutofillableLogins(pending_request_.get()); |
298 } | 301 } |
299 | 302 |
300 PasswordStore* CredentialManagerDispatcher::GetPasswordStore() { | 303 PasswordStore* CredentialManagerDispatcher::GetPasswordStore() { |
301 return client_ ? client_->GetPasswordStore() : nullptr; | 304 return client_ ? client_->GetPasswordStore() : nullptr; |
302 } | 305 } |
303 | 306 |
304 bool CredentialManagerDispatcher::IsSavingEnabledForCurrentPage() const { | |
305 // TODO(vasilii): add more, see http://crbug.com/450583. | |
306 return !client_->IsOffTheRecord(); | |
307 } | |
308 | |
309 bool CredentialManagerDispatcher::IsZeroClickAllowed() const { | 307 bool CredentialManagerDispatcher::IsZeroClickAllowed() const { |
310 return *auto_signin_enabled_ && !client_->IsOffTheRecord(); | 308 return *auto_signin_enabled_ && !client_->IsOffTheRecord(); |
311 } | 309 } |
312 | 310 |
313 base::WeakPtr<PasswordManagerDriver> CredentialManagerDispatcher::GetDriver() { | 311 base::WeakPtr<PasswordManagerDriver> CredentialManagerDispatcher::GetDriver() { |
314 ContentPasswordManagerDriverFactory* driver_factory = | 312 ContentPasswordManagerDriverFactory* driver_factory = |
315 ContentPasswordManagerDriverFactory::FromWebContents(web_contents()); | 313 ContentPasswordManagerDriverFactory::FromWebContents(web_contents()); |
316 DCHECK(driver_factory); | 314 DCHECK(driver_factory); |
317 PasswordManagerDriver* driver = | 315 PasswordManagerDriver* driver = |
318 driver_factory->GetDriverForFrame(web_contents()->GetMainFrame()); | 316 driver_factory->GetDriverForFrame(web_contents()->GetMainFrame()); |
(...skipping 22 matching lines...) Expand all Loading... |
341 pending_request_->id(), info)); | 339 pending_request_->id(), info)); |
342 pending_request_.reset(); | 340 pending_request_.reset(); |
343 } | 341 } |
344 | 342 |
345 void CredentialManagerDispatcher::DoneSigningOut() { | 343 void CredentialManagerDispatcher::DoneSigningOut() { |
346 DCHECK(pending_sign_out_); | 344 DCHECK(pending_sign_out_); |
347 pending_sign_out_.reset(); | 345 pending_sign_out_.reset(); |
348 } | 346 } |
349 | 347 |
350 } // namespace password_manager | 348 } // namespace password_manager |
OLD | NEW |