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