OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/password_manager/content_password_manager_driver.h" | |
6 | |
7 #include "components/autofill/content/browser/autofill_driver_impl.h" | |
8 #include "components/autofill/content/common/autofill_messages.h" | |
9 #include "components/autofill/core/common/form_data.h" | |
10 #include "components/autofill/core/common/password_form.h" | |
11 #include "content/public/browser/browser_context.h" | |
12 #include "content/public/browser/navigation_details.h" | |
13 #include "content/public/browser/navigation_entry.h" | |
14 #include "content/public/browser/render_view_host.h" | |
15 #include "content/public/browser/web_contents.h" | |
16 #include "content/public/common/page_transition_types.h" | |
17 #include "content/public/common/ssl_status.h" | |
18 #include "ipc/ipc_message_macros.h" | |
19 #include "net/cert/cert_status_flags.h" | |
20 | |
21 ContentPasswordManagerDriver::ContentPasswordManagerDriver( | |
22 content::WebContents* web_contents, | |
23 PasswordManagerClient* client) | |
24 : WebContentsObserver(web_contents), | |
25 password_manager_(client), | |
26 password_generation_manager_(client) { | |
27 DCHECK(web_contents); | |
28 } | |
29 | |
30 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() {} | |
31 | |
32 void ContentPasswordManagerDriver::FillPasswordForm( | |
33 const autofill::PasswordFormFillData& form_data) { | |
34 DCHECK(web_contents()); | |
35 web_contents()->GetRenderViewHost()->Send(new AutofillMsg_FillPasswordForm( | |
36 web_contents()->GetRenderViewHost()->GetRoutingID(), form_data)); | |
37 } | |
38 | |
39 void ContentPasswordManagerDriver::AllowPasswordGenerationForForm( | |
40 autofill::PasswordForm* form) { | |
41 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); | |
42 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), *form)); | |
43 } | |
44 | |
45 void ContentPasswordManagerDriver::AccountCreationFormsFound( | |
46 const std::vector<autofill::FormData>& forms) { | |
47 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); | |
48 host->Send(new AutofillMsg_AccountCreationFormsDetected(host->GetRoutingID(), | |
49 forms)); | |
50 } | |
51 | |
52 bool ContentPasswordManagerDriver::DidLastPageLoadEncounterSSLErrors() { | |
53 DCHECK(web_contents()); | |
54 content::NavigationEntry* entry = | |
55 web_contents()->GetController().GetActiveEntry(); | |
56 if (!entry) { | |
57 NOTREACHED(); | |
58 return false; | |
59 } | |
60 | |
61 return net::IsCertStatusError(entry->GetSSL().cert_status); | |
62 } | |
63 | |
64 bool ContentPasswordManagerDriver::IsOffTheRecord() { | |
65 DCHECK(web_contents()); | |
66 return web_contents()->GetBrowserContext()->IsOffTheRecord(); | |
67 } | |
68 | |
69 PasswordGenerationManager* | |
70 ContentPasswordManagerDriver::GetPasswordGenerationManager() { | |
71 return &password_generation_manager_; | |
72 } | |
73 | |
74 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() { | |
75 return &password_manager_; | |
76 } | |
77 | |
78 void ContentPasswordManagerDriver::DidNavigateMainFrame( | |
79 const content::LoadCommittedDetails& details, | |
80 const content::FrameNavigateParams& params) { | |
81 password_manager_.DidNavigateMainFrame(details.is_in_page); | |
82 } | |
83 | |
84 bool ContentPasswordManagerDriver::OnMessageReceived( | |
85 const IPC::Message& message) { | |
86 bool handled = true; | |
87 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message) | |
88 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsParsed, | |
89 &password_manager_, | |
90 PasswordManager::OnPasswordFormsParsed) | |
91 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsRendered, | |
92 &password_manager_, | |
93 PasswordManager::OnPasswordFormsRendered) | |
94 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormSubmitted, | |
95 &password_manager_, | |
96 PasswordManager::OnPasswordFormSubmitted) | |
97 IPC_MESSAGE_UNHANDLED(handled = false) | |
98 IPC_END_MESSAGE_MAP() | |
99 | |
100 return handled; | |
101 } | |
102 | |
103 autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() { | |
104 autofill::AutofillDriverImpl* driver = | |
105 autofill::AutofillDriverImpl::FromWebContents(web_contents()); | |
106 return driver ? driver->autofill_manager() : NULL; | |
107 } | |
OLD | NEW |