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