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_password_manager_d
river.h" | 5 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
6 | 6 |
7 #include "components/autofill/content/browser/content_autofill_driver.h" | 7 #include "components/autofill/content/browser/content_autofill_driver.h" |
8 #include "components/autofill/content/common/autofill_messages.h" | 8 #include "components/autofill/content/common/autofill_messages.h" |
9 #include "components/autofill/core/common/form_data.h" | 9 #include "components/autofill/core/common/form_data.h" |
10 #include "components/autofill/core/common/password_form.h" | 10 #include "components/autofill/core/common/password_form.h" |
11 #include "components/password_manager/core/browser/password_manager_client.h" | 11 #include "components/password_manager/core/browser/password_manager_client.h" |
12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
13 #include "content/public/browser/navigation_details.h" | 13 #include "content/public/browser/navigation_details.h" |
14 #include "content/public/browser/navigation_entry.h" | 14 #include "content/public/browser/navigation_entry.h" |
15 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "content/public/common/page_transition_types.h" | 17 #include "content/public/common/page_transition_types.h" |
18 #include "content/public/common/ssl_status.h" | 18 #include "content/public/common/ssl_status.h" |
19 #include "ipc/ipc_message_macros.h" | 19 #include "ipc/ipc_message_macros.h" |
20 #include "net/cert/cert_status_flags.h" | 20 #include "net/cert/cert_status_flags.h" |
21 | 21 |
22 namespace password_manager { | 22 namespace password_manager { |
23 | 23 |
24 ContentPasswordManagerDriver::ContentPasswordManagerDriver( | 24 ContentPasswordManagerDriver::ContentPasswordManagerDriver( |
25 content::WebContents* web_contents, | 25 content::WebContents* web_contents, |
26 PasswordManagerClient* client) | 26 PasswordManagerClient* client, |
| 27 autofill::AutofillManagerDelegate* autofill_manager_delegate) |
27 : WebContentsObserver(web_contents), | 28 : WebContentsObserver(web_contents), |
28 password_manager_(client), | 29 password_manager_(client), |
29 password_generation_manager_(client) { | 30 password_generation_manager_(client), |
| 31 password_autofill_manager_(client, autofill_manager_delegate) { |
30 DCHECK(web_contents); | 32 DCHECK(web_contents); |
31 } | 33 } |
32 | 34 |
33 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() {} | 35 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() {} |
34 | 36 |
35 void ContentPasswordManagerDriver::FillPasswordForm( | 37 void ContentPasswordManagerDriver::FillPasswordForm( |
36 const autofill::PasswordFormFillData& form_data) { | 38 const autofill::PasswordFormFillData& form_data) { |
37 DCHECK(web_contents()); | 39 DCHECK(web_contents()); |
38 web_contents()->GetRenderViewHost()->Send(new AutofillMsg_FillPasswordForm( | 40 web_contents()->GetRenderViewHost()->Send(new AutofillMsg_FillPasswordForm( |
39 web_contents()->GetRenderViewHost()->GetRoutingID(), form_data)); | 41 web_contents()->GetRenderViewHost()->GetRoutingID(), form_data)); |
40 } | 42 } |
41 | 43 |
42 void ContentPasswordManagerDriver::AllowPasswordGenerationForForm( | 44 void ContentPasswordManagerDriver::AllowPasswordGenerationForForm( |
43 autofill::PasswordForm* form) { | 45 autofill::PasswordForm* form) { |
44 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); | 46 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); |
45 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), *form)); | 47 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), *form)); |
46 } | 48 } |
47 | 49 |
48 void ContentPasswordManagerDriver::AccountCreationFormsFound( | 50 void ContentPasswordManagerDriver::AccountCreationFormsFound( |
49 const std::vector<autofill::FormData>& forms) { | 51 const std::vector<autofill::FormData>& forms) { |
50 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); | 52 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); |
51 host->Send(new AutofillMsg_AccountCreationFormsDetected(host->GetRoutingID(), | 53 host->Send(new AutofillMsg_AccountCreationFormsDetected(host->GetRoutingID(), |
52 forms)); | 54 forms)); |
53 } | 55 } |
54 | 56 |
| 57 void ContentPasswordManagerDriver::AcceptPasswordAutofillSuggestion( |
| 58 const base::string16& username, |
| 59 const base::string16& password) { |
| 60 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); |
| 61 host->Send( |
| 62 new AutofillMsg_AcceptPasswordAutofillSuggestion(host->GetRoutingID(), |
| 63 username, |
| 64 password)); |
| 65 } |
| 66 |
55 bool ContentPasswordManagerDriver::DidLastPageLoadEncounterSSLErrors() { | 67 bool ContentPasswordManagerDriver::DidLastPageLoadEncounterSSLErrors() { |
56 DCHECK(web_contents()); | 68 DCHECK(web_contents()); |
57 content::NavigationEntry* entry = | 69 content::NavigationEntry* entry = |
58 web_contents()->GetController().GetLastCommittedEntry(); | 70 web_contents()->GetController().GetLastCommittedEntry(); |
59 if (!entry) { | 71 if (!entry) { |
60 NOTREACHED(); | 72 NOTREACHED(); |
61 return false; | 73 return false; |
62 } | 74 } |
63 | 75 |
64 return net::IsCertStatusError(entry->GetSSL().cert_status); | 76 return net::IsCertStatusError(entry->GetSSL().cert_status); |
65 } | 77 } |
66 | 78 |
67 bool ContentPasswordManagerDriver::IsOffTheRecord() { | 79 bool ContentPasswordManagerDriver::IsOffTheRecord() { |
68 DCHECK(web_contents()); | 80 DCHECK(web_contents()); |
69 return web_contents()->GetBrowserContext()->IsOffTheRecord(); | 81 return web_contents()->GetBrowserContext()->IsOffTheRecord(); |
70 } | 82 } |
71 | 83 |
72 PasswordGenerationManager* | 84 PasswordGenerationManager* |
73 ContentPasswordManagerDriver::GetPasswordGenerationManager() { | 85 ContentPasswordManagerDriver::GetPasswordGenerationManager() { |
74 return &password_generation_manager_; | 86 return &password_generation_manager_; |
75 } | 87 } |
76 | 88 |
77 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() { | 89 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() { |
78 return &password_manager_; | 90 return &password_manager_; |
79 } | 91 } |
80 | 92 |
| 93 PasswordAutofillManager* |
| 94 ContentPasswordManagerDriver::GetPasswordAutofillManager() { |
| 95 return &password_autofill_manager_; |
| 96 } |
| 97 |
81 void ContentPasswordManagerDriver::DidNavigateMainFrame( | 98 void ContentPasswordManagerDriver::DidNavigateMainFrame( |
82 const content::LoadCommittedDetails& details, | 99 const content::LoadCommittedDetails& details, |
83 const content::FrameNavigateParams& params) { | 100 const content::FrameNavigateParams& params) { |
84 password_manager_.DidNavigateMainFrame(details.is_in_page); | 101 password_manager_.DidNavigateMainFrame(details.is_in_page); |
85 } | 102 } |
86 | 103 |
87 bool ContentPasswordManagerDriver::OnMessageReceived( | 104 bool ContentPasswordManagerDriver::OnMessageReceived( |
88 const IPC::Message& message) { | 105 const IPC::Message& message) { |
89 bool handled = true; | 106 bool handled = true; |
90 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message) | 107 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message) |
91 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsParsed, | 108 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsParsed, |
92 &password_manager_, | 109 &password_manager_, |
93 PasswordManager::OnPasswordFormsParsed) | 110 PasswordManager::OnPasswordFormsParsed) |
94 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsRendered, | 111 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsRendered, |
95 &password_manager_, | 112 &password_manager_, |
96 PasswordManager::OnPasswordFormsRendered) | 113 PasswordManager::OnPasswordFormsRendered) |
97 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormSubmitted, | 114 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormSubmitted, |
98 &password_manager_, | 115 &password_manager_, |
99 PasswordManager::OnPasswordFormSubmitted) | 116 PasswordManager::OnPasswordFormSubmitted) |
| 117 IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions, |
| 118 &password_autofill_manager_, |
| 119 PasswordAutofillManager::OnShowPasswordSuggestions) |
| 120 IPC_MESSAGE_FORWARD(AutofillHostMsg_AddPasswordFormMapping, |
| 121 &password_autofill_manager_, |
| 122 PasswordAutofillManager::OnAddPasswordFormMapping) |
100 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, | 123 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, |
101 password_manager_.client(), | 124 password_manager_.client(), |
102 PasswordManagerClient::LogSavePasswordProgress) | 125 PasswordManagerClient::LogSavePasswordProgress) |
103 IPC_MESSAGE_UNHANDLED(handled = false) | 126 IPC_MESSAGE_UNHANDLED(handled = false) |
104 IPC_END_MESSAGE_MAP() | 127 IPC_END_MESSAGE_MAP() |
105 | 128 |
106 return handled; | 129 return handled; |
107 } | 130 } |
108 | 131 |
109 autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() { | 132 autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() { |
110 autofill::ContentAutofillDriver* driver = | 133 autofill::ContentAutofillDriver* driver = |
111 autofill::ContentAutofillDriver::FromWebContents(web_contents()); | 134 autofill::ContentAutofillDriver::FromWebContents(web_contents()); |
112 return driver ? driver->autofill_manager() : NULL; | 135 return driver ? driver->autofill_manager() : NULL; |
113 } | 136 } |
114 | 137 |
115 } // namespace password_manager | 138 } // namespace password_manager |
OLD | NEW |