OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/content/browser/autofill_driver_impl.h" | 5 #include "components/autofill/content/browser/autofill_driver_impl.h" |
6 | 6 |
| 7 #include "base/command_line.h" |
7 #include "components/autofill/core/browser/autofill_external_delegate.h" | 8 #include "components/autofill/core/browser/autofill_external_delegate.h" |
8 #include "components/autofill/core/browser/autofill_manager.h" | 9 #include "components/autofill/core/browser/autofill_manager.h" |
9 #include "components/autofill/core/browser/autofill_manager_delegate.h" | 10 #include "components/autofill/core/browser/autofill_manager_delegate.h" |
10 #include "components/autofill/core/common/autofill_messages.h" | 11 #include "components/autofill/core/common/autofill_messages.h" |
| 12 #include "components/autofill/core/browser/form_structure.h" |
| 13 #include "components/autofill/core/common/autofill_switches.h" |
11 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
12 #include "content/public/browser/navigation_details.h" | 15 #include "content/public/browser/navigation_details.h" |
13 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
14 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
15 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
16 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/frame_navigate_params.h" | 21 #include "content/public/common/frame_navigate_params.h" |
19 #include "ipc/ipc_message_macros.h" | 22 #include "ipc/ipc_message_macros.h" |
20 | 23 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 91 |
89 void AutofillDriverImpl::SendFormDataToRenderer(int query_id, | 92 void AutofillDriverImpl::SendFormDataToRenderer(int query_id, |
90 const FormData& data) { | 93 const FormData& data) { |
91 if (!RendererIsAvailable()) | 94 if (!RendererIsAvailable()) |
92 return; | 95 return; |
93 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); | 96 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); |
94 host->Send( | 97 host->Send( |
95 new AutofillMsg_FormDataFilled(host->GetRoutingID(), query_id, data)); | 98 new AutofillMsg_FormDataFilled(host->GetRoutingID(), query_id, data)); |
96 } | 99 } |
97 | 100 |
| 101 void AutofillDriverImpl::SendAutofillTypePredictionsToRenderer( |
| 102 const std::vector<FormStructure*>& forms) { |
| 103 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 104 switches::kShowAutofillTypePredictions)) |
| 105 return; |
| 106 |
| 107 content::RenderViewHost* host = GetWebContents()->GetRenderViewHost(); |
| 108 if (!host) |
| 109 return; |
| 110 |
| 111 std::vector<FormDataPredictions> type_predictions; |
| 112 FormStructure::GetFieldTypePredictions(forms, &type_predictions); |
| 113 host->Send( |
| 114 new AutofillMsg_FieldTypePredictionsAvailable(host->GetRoutingID(), |
| 115 type_predictions)); |
| 116 } |
| 117 |
98 bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) { | 118 bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) { |
99 bool handled = true; | 119 bool handled = true; |
100 IPC_BEGIN_MESSAGE_MAP(AutofillDriverImpl, message) | 120 IPC_BEGIN_MESSAGE_MAP(AutofillDriverImpl, message) |
101 IPC_MESSAGE_FORWARD(AutofillHostMsg_FormsSeen, autofill_manager_.get(), | 121 IPC_MESSAGE_FORWARD(AutofillHostMsg_FormsSeen, autofill_manager_.get(), |
102 AutofillManager::OnFormsSeen) | 122 AutofillManager::OnFormsSeen) |
103 IPC_MESSAGE_FORWARD(AutofillHostMsg_FormSubmitted, autofill_manager_.get(), | 123 IPC_MESSAGE_FORWARD(AutofillHostMsg_FormSubmitted, autofill_manager_.get(), |
104 AutofillManager::OnFormSubmitted) | 124 AutofillManager::OnFormSubmitted) |
105 IPC_MESSAGE_FORWARD(AutofillHostMsg_TextFieldDidChange, | 125 IPC_MESSAGE_FORWARD(AutofillHostMsg_TextFieldDidChange, |
106 autofill_manager_.get(), | 126 autofill_manager_.get(), |
107 AutofillManager::OnTextFieldDidChange) | 127 AutofillManager::OnTextFieldDidChange) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 if (!*content::Details<bool>(details).ptr()) | 199 if (!*content::Details<bool>(details).ptr()) |
180 autofill_manager_->delegate()->HideAutofillPopup(); | 200 autofill_manager_->delegate()->HideAutofillPopup(); |
181 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { | 201 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { |
182 autofill_manager_->delegate()->HideAutofillPopup(); | 202 autofill_manager_->delegate()->HideAutofillPopup(); |
183 } else { | 203 } else { |
184 NOTREACHED(); | 204 NOTREACHED(); |
185 } | 205 } |
186 } | 206 } |
187 | 207 |
188 } // namespace autofill | 208 } // namespace autofill |
OLD | NEW |