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/prefs/pref_service.h" | |
9 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
11 #include "components/autofill/core/common/password_form.h" | 12 #include "components/autofill/core/common/password_form.h" |
12 #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" |
13 #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" |
14 #include "components/password_manager/content/browser/credential_manager_passwor d_form_manager.h" | 15 #include "components/password_manager/content/browser/credential_manager_passwor d_form_manager.h" |
15 #include "components/password_manager/content/common/credential_manager_messages .h" | 16 #include "components/password_manager/content/common/credential_manager_messages .h" |
16 #include "components/password_manager/core/browser/password_manager_client.h" | 17 #include "components/password_manager/core/browser/password_manager_client.h" |
17 #include "components/password_manager/core/browser/password_store.h" | 18 #include "components/password_manager/core/browser/password_store.h" |
18 #include "components/password_manager/core/common/credential_manager_types.h" | 19 #include "components/password_manager/core/common/credential_manager_types.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 | 230 |
230 // TODO(mkwst): This is a stub; we should be checking the PasswordStore to | 231 // TODO(mkwst): This is a stub; we should be checking the PasswordStore to |
231 // determine whether or not the credential exists, and calling UpdateLogin | 232 // determine whether or not the credential exists, and calling UpdateLogin |
232 // accordingly. | 233 // accordingly. |
233 form_manager_.reset(new CredentialManagerPasswordFormManager( | 234 form_manager_.reset(new CredentialManagerPasswordFormManager( |
234 client_, GetDriver(), *form, this)); | 235 client_, GetDriver(), *form, this)); |
235 } | 236 } |
236 | 237 |
237 void CredentialManagerDispatcher::OnProvisionalSaveComplete() { | 238 void CredentialManagerDispatcher::OnProvisionalSaveComplete() { |
238 DCHECK(form_manager_); | 239 DCHECK(form_manager_); |
239 client_->PromptUserToSavePassword( | 240 if (IsSavingEnabledForCurrentPage() && !form_manager_->IsBlacklisted()) { |
240 form_manager_.Pass(), CredentialSourceType::CREDENTIAL_SOURCE_API); | 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 { | 307 bool CredentialManagerDispatcher::IsSavingEnabledForCurrentPage() const { |
vabr (Chromium)
2015/03/30 10:58:42
Currently, this duplicates PasswordManager::IsSavi
melandory
2015/04/07 13:14:13
Done.
| |
305 // TODO(vasilii): add more, see http://crbug.com/450583. | 308 bool is_saving_enabled = client_->GetPrefs()->GetBoolean( |
306 return !client_->IsOffTheRecord(); | 309 password_manager::prefs::kPasswordManagerSavingEnabled); |
310 return is_saving_enabled && !client_->IsOffTheRecord() && | |
311 !client_->DidLastPageLoadEncounterSSLErrors() && | |
312 client_->IsPasswordManagerEnabledForCurrentPage(); | |
307 } | 313 } |
308 | 314 |
309 bool CredentialManagerDispatcher::IsZeroClickAllowed() const { | 315 bool CredentialManagerDispatcher::IsZeroClickAllowed() const { |
310 return *auto_signin_enabled_ && !client_->IsOffTheRecord(); | 316 return *auto_signin_enabled_ && !client_->IsOffTheRecord(); |
311 } | 317 } |
312 | 318 |
313 base::WeakPtr<PasswordManagerDriver> CredentialManagerDispatcher::GetDriver() { | 319 base::WeakPtr<PasswordManagerDriver> CredentialManagerDispatcher::GetDriver() { |
314 ContentPasswordManagerDriverFactory* driver_factory = | 320 ContentPasswordManagerDriverFactory* driver_factory = |
315 ContentPasswordManagerDriverFactory::FromWebContents(web_contents()); | 321 ContentPasswordManagerDriverFactory::FromWebContents(web_contents()); |
316 DCHECK(driver_factory); | 322 DCHECK(driver_factory); |
(...skipping 24 matching lines...) Expand all Loading... | |
341 pending_request_->id(), info)); | 347 pending_request_->id(), info)); |
342 pending_request_.reset(); | 348 pending_request_.reset(); |
343 } | 349 } |
344 | 350 |
345 void CredentialManagerDispatcher::DoneSigningOut() { | 351 void CredentialManagerDispatcher::DoneSigningOut() { |
346 DCHECK(pending_sign_out_); | 352 DCHECK(pending_sign_out_); |
347 pending_sign_out_.reset(); | 353 pending_sign_out_.reset(); |
348 } | 354 } |
349 | 355 |
350 } // namespace password_manager | 356 } // namespace password_manager |
OLD | NEW |