| 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/content_credential_manager
_dispatcher.h" | 5 #include "components/password_manager/content/browser/content_credential_manager
_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "components/autofill/core/common/password_form.h" | 9 #include "components/autofill/core/common/password_form.h" |
| 10 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
| 11 #include "components/password_manager/content/browser/content_password_manager_d
river_factory.h" |
| 10 #include "components/password_manager/content/browser/credential_manager_passwor
d_form_manager.h" | 12 #include "components/password_manager/content/browser/credential_manager_passwor
d_form_manager.h" |
| 11 #include "components/password_manager/content/common/credential_manager_messages
.h" | 13 #include "components/password_manager/content/common/credential_manager_messages
.h" |
| 12 #include "components/password_manager/content/common/credential_manager_types.h" | 14 #include "components/password_manager/content/common/credential_manager_types.h" |
| 13 #include "components/password_manager/core/browser/password_manager_client.h" | 15 #include "components/password_manager/core/browser/password_manager_client.h" |
| 14 #include "components/password_manager/core/browser/password_store.h" | 16 #include "components/password_manager/core/browser/password_store.h" |
| 15 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
| 16 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 17 #include "ipc/ipc_message_macros.h" | 19 #include "ipc/ipc_message_macros.h" |
| 18 | 20 |
| 19 namespace password_manager { | 21 namespace password_manager { |
| 20 | 22 |
| 21 ContentCredentialManagerDispatcher::ContentCredentialManagerDispatcher( | 23 ContentCredentialManagerDispatcher::ContentCredentialManagerDispatcher( |
| 22 content::WebContents* web_contents, | 24 content::WebContents* web_contents, |
| 23 PasswordManagerClient* client) | 25 PasswordManagerClient* client) |
| 24 : WebContentsObserver(web_contents), | 26 : WebContentsObserver(web_contents), |
| 25 client_(client), | 27 client_(client), |
| 28 driver_(nullptr), |
| 26 pending_request_id_(0) { | 29 pending_request_id_(0) { |
| 27 DCHECK(web_contents); | 30 DCHECK(web_contents); |
| 31 |
| 32 ContentPasswordManagerDriverFactory* driver_factory = |
| 33 ContentPasswordManagerDriverFactory::FromWebContents(web_contents); |
| 34 if (driver_factory) |
| 35 driver_ = driver_factory->GetDriverForFrame(web_contents->GetMainFrame()); |
| 28 } | 36 } |
| 29 | 37 |
| 30 ContentCredentialManagerDispatcher::~ContentCredentialManagerDispatcher() {} | 38 ContentCredentialManagerDispatcher::~ContentCredentialManagerDispatcher() {} |
| 31 | 39 |
| 32 bool ContentCredentialManagerDispatcher::OnMessageReceived( | 40 bool ContentCredentialManagerDispatcher::OnMessageReceived( |
| 33 const IPC::Message& message) { | 41 const IPC::Message& message) { |
| 34 bool handled = true; | 42 bool handled = true; |
| 35 IPC_BEGIN_MESSAGE_MAP(ContentCredentialManagerDispatcher, message) | 43 IPC_BEGIN_MESSAGE_MAP(ContentCredentialManagerDispatcher, message) |
| 36 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_NotifyFailedSignIn, | 44 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_NotifyFailedSignIn, |
| 37 OnNotifyFailedSignIn); | 45 OnNotifyFailedSignIn); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 60 const password_manager::CredentialInfo& credential) { | 68 const password_manager::CredentialInfo& credential) { |
| 61 DCHECK(request_id); | 69 DCHECK(request_id); |
| 62 scoped_ptr<autofill::PasswordForm> form( | 70 scoped_ptr<autofill::PasswordForm> form( |
| 63 CreatePasswordFormFromCredentialInfo(credential, | 71 CreatePasswordFormFromCredentialInfo(credential, |
| 64 web_contents()->GetLastCommittedURL().GetOrigin())); | 72 web_contents()->GetLastCommittedURL().GetOrigin())); |
| 65 | 73 |
| 66 // TODO(mkwst): This is a stub; we should be checking the PasswordStore to | 74 // TODO(mkwst): This is a stub; we should be checking the PasswordStore to |
| 67 // determine whether or not the credential exists, and calling UpdateLogin | 75 // determine whether or not the credential exists, and calling UpdateLogin |
| 68 // accordingly. | 76 // accordingly. |
| 69 form_manager_.reset( | 77 form_manager_.reset( |
| 70 new CredentialManagerPasswordFormManager(client_, *form, this)); | 78 new CredentialManagerPasswordFormManager(client_, driver_, *form, this)); |
| 71 | 79 |
| 72 web_contents()->GetRenderViewHost()->Send( | 80 web_contents()->GetRenderViewHost()->Send( |
| 73 new CredentialManagerMsg_AcknowledgeSignedIn( | 81 new CredentialManagerMsg_AcknowledgeSignedIn( |
| 74 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); | 82 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); |
| 75 } | 83 } |
| 76 | 84 |
| 77 void ContentCredentialManagerDispatcher::OnProvisionalSaveComplete() { | 85 void ContentCredentialManagerDispatcher::OnProvisionalSaveComplete() { |
| 78 DCHECK(form_manager_); | 86 DCHECK(form_manager_); |
| 79 client_->PromptUserToSavePassword(form_manager_.Pass()); | 87 client_->PromptUserToSavePassword(form_manager_.Pass()); |
| 80 } | 88 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 pending_request_id_, | 143 pending_request_id_, |
| 136 info)); | 144 info)); |
| 137 pending_request_id_ = 0; | 145 pending_request_id_ = 0; |
| 138 } | 146 } |
| 139 | 147 |
| 140 PasswordStore* ContentCredentialManagerDispatcher::GetPasswordStore() { | 148 PasswordStore* ContentCredentialManagerDispatcher::GetPasswordStore() { |
| 141 return client_ ? client_->GetPasswordStore() : nullptr; | 149 return client_ ? client_->GetPasswordStore() : nullptr; |
| 142 } | 150 } |
| 143 | 151 |
| 144 } // namespace password_manager | 152 } // namespace password_manager |
| OLD | NEW |