Add a stub __cxa_demangle to disable LLVM's demangler.
[chromium-blink-merge.git] / components / password_manager / content / browser / content_password_manager_driver.cc
blobffaf3ac58cef509fbd55ecf7b772da1167bec703
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.
5 #include "components/password_manager/content/browser/content_password_manager_driver.h"
7 #include "components/autofill/content/common/autofill_messages.h"
8 #include "components/autofill/core/common/form_data.h"
9 #include "components/autofill/core/common/password_form.h"
10 #include "components/password_manager/content/browser/content_password_manager_driver_factory.h"
11 #include "components/password_manager/core/browser/password_manager_client.h"
12 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/navigation_details.h"
14 #include "content/public/browser/navigation_entry.h"
15 #include "content/public/browser/render_frame_host.h"
16 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/site_instance.h"
18 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/ssl_status.h"
20 #include "ipc/ipc_message_macros.h"
21 #include "net/cert/cert_status_flags.h"
23 namespace password_manager {
25 ContentPasswordManagerDriver::ContentPasswordManagerDriver(
26 content::RenderFrameHost* render_frame_host,
27 PasswordManagerClient* client,
28 autofill::AutofillClient* autofill_client)
29 : render_frame_host_(render_frame_host),
30 client_(client),
31 password_generation_manager_(client, this),
32 password_autofill_manager_(this, autofill_client),
33 next_free_key_(0) {
36 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() {
39 // static
40 ContentPasswordManagerDriver*
41 ContentPasswordManagerDriver::GetForRenderFrameHost(
42 content::RenderFrameHost* render_frame_host) {
43 ContentPasswordManagerDriverFactory* factory =
44 ContentPasswordManagerDriverFactory::FromWebContents(
45 content::WebContents::FromRenderFrameHost(render_frame_host));
46 return factory ? factory->GetDriverForFrame(render_frame_host) : nullptr;
49 void ContentPasswordManagerDriver::FillPasswordForm(
50 const autofill::PasswordFormFillData& form_data) {
51 const int key = next_free_key_++;
52 password_autofill_manager_.OnAddPasswordFormMapping(key, form_data);
53 render_frame_host_->Send(new AutofillMsg_FillPasswordForm(
54 render_frame_host_->GetRoutingID(), key, form_data));
57 void ContentPasswordManagerDriver::AllowPasswordGenerationForForm(
58 const autofill::PasswordForm& form) {
59 if (!GetPasswordGenerationManager()->IsGenerationEnabled())
60 return;
61 content::RenderFrameHost* host = render_frame_host_;
62 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), form));
65 void ContentPasswordManagerDriver::AccountCreationFormsFound(
66 const std::vector<autofill::FormData>& forms) {
67 content::RenderFrameHost* host = render_frame_host_;
68 host->Send(new AutofillMsg_AccountCreationFormsDetected(host->GetRoutingID(),
69 forms));
72 void ContentPasswordManagerDriver::AutofillDataReceived(
73 const std::map<autofill::FormData,
74 autofill::PasswordFormFieldPredictionMap>& predictions) {
75 content::RenderFrameHost* host = render_frame_host_;
76 host->Send(new AutofillMsg_AutofillUsernameAndPasswordDataReceived(
77 host->GetRoutingID(),
78 predictions));
81 void ContentPasswordManagerDriver::GeneratedPasswordAccepted(
82 const base::string16& password) {
83 content::RenderFrameHost* host = render_frame_host_;
84 host->Send(new AutofillMsg_GeneratedPasswordAccepted(host->GetRoutingID(),
85 password));
88 void ContentPasswordManagerDriver::FillSuggestion(
89 const base::string16& username,
90 const base::string16& password) {
91 content::RenderFrameHost* host = render_frame_host_;
92 host->Send(new AutofillMsg_FillPasswordSuggestion(host->GetRoutingID(),
93 username, password));
96 void ContentPasswordManagerDriver::PreviewSuggestion(
97 const base::string16& username,
98 const base::string16& password) {
99 content::RenderFrameHost* host = render_frame_host_;
100 host->Send(new AutofillMsg_PreviewPasswordSuggestion(host->GetRoutingID(),
101 username, password));
104 void ContentPasswordManagerDriver::ClearPreviewedForm() {
105 content::RenderFrameHost* host = render_frame_host_;
106 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID()));
109 void ContentPasswordManagerDriver::ForceSavePassword() {
110 content::RenderFrameHost* host = render_frame_host_;
111 host->Send(new AutofillMsg_FindFocusedPasswordForm(host->GetRoutingID()));
114 PasswordGenerationManager*
115 ContentPasswordManagerDriver::GetPasswordGenerationManager() {
116 return &password_generation_manager_;
119 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() {
120 return client_->GetPasswordManager();
123 PasswordAutofillManager*
124 ContentPasswordManagerDriver::GetPasswordAutofillManager() {
125 return &password_autofill_manager_;
128 bool ContentPasswordManagerDriver::HandleMessage(const IPC::Message& message) {
129 bool handled = true;
130 IPC_BEGIN_MESSAGE_MAP(ContentPasswordManagerDriver, message)
131 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsParsed,
132 OnPasswordFormsParsed)
133 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsRendered,
134 OnPasswordFormsRendered)
135 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormSubmitted,
136 OnPasswordFormSubmitted)
137 IPC_MESSAGE_HANDLER(AutofillHostMsg_InPageNavigation, OnInPageNavigation)
138 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordNoLongerGenerated,
139 OnPasswordNoLongerGenerated)
140 IPC_MESSAGE_HANDLER(AutofillHostMsg_FocusedPasswordFormFound,
141 OnFocusedPasswordFormFound)
142 IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions,
143 &password_autofill_manager_,
144 PasswordAutofillManager::OnShowPasswordSuggestions)
145 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, client_,
146 PasswordManagerClient::LogSavePasswordProgress)
147 IPC_MESSAGE_UNHANDLED(handled = false)
148 IPC_END_MESSAGE_MAP()
149 return handled;
152 void ContentPasswordManagerDriver::OnPasswordFormsParsed(
153 const std::vector<autofill::PasswordForm>& forms) {
154 GetPasswordManager()->OnPasswordFormsParsed(this, forms);
157 void ContentPasswordManagerDriver::OnPasswordFormsRendered(
158 const std::vector<autofill::PasswordForm>& visible_forms,
159 bool did_stop_loading) {
160 GetPasswordManager()->OnPasswordFormsRendered(this, visible_forms,
161 did_stop_loading);
164 void ContentPasswordManagerDriver::OnPasswordFormSubmitted(
165 const autofill::PasswordForm& password_form) {
166 GetPasswordManager()->OnPasswordFormSubmitted(this, password_form);
169 void ContentPasswordManagerDriver::OnFocusedPasswordFormFound(
170 const autofill::PasswordForm& password_form) {
171 GetPasswordManager()->OnPasswordFormForceSaveRequested(this, password_form);
174 void ContentPasswordManagerDriver::DidNavigateFrame(
175 const content::LoadCommittedDetails& details,
176 const content::FrameNavigateParams& params) {
177 // Clear page specific data after main frame navigation.
178 if (!render_frame_host_->GetParent() && !details.is_in_page) {
179 GetPasswordManager()->DidNavigateMainFrame();
180 GetPasswordAutofillManager()->DidNavigateMainFrame();
184 void ContentPasswordManagerDriver::OnInPageNavigation(
185 const autofill::PasswordForm& password_form) {
186 GetPasswordManager()->OnInPageNavigation(this, password_form);
189 void ContentPasswordManagerDriver::OnPasswordNoLongerGenerated(
190 const autofill::PasswordForm& password_form) {
191 GetPasswordManager()->SetHasGeneratedPasswordForForm(this, password_form,
192 false);
195 } // namespace password_manager