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 "components/autofill/core/browser/autofill_external_delegate.h" | 7 #include "components/autofill/core/browser/autofill_external_delegate.h" |
8 #include "components/autofill/core/browser/autofill_manager.h" | 8 #include "components/autofill/core/browser/autofill_manager.h" |
9 #include "components/autofill/core/browser/autofill_manager_delegate.h" | 9 #include "components/autofill/core/browser/autofill_manager_delegate.h" |
10 #include "components/autofill/core/common/autofill_messages.h" | 10 #include "components/autofill/core/common/autofill_messages.h" |
11 #include "content/public/browser/navigation_details.h" | 11 #include "content/public/browser/navigation_details.h" |
| 12 #include "content/public/browser/render_view_host.h" |
12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
13 #include "content/public/common/frame_navigate_params.h" | 14 #include "content/public/common/frame_navigate_params.h" |
14 #include "ipc/ipc_message_macros.h" | 15 #include "ipc/ipc_message_macros.h" |
15 | 16 |
16 namespace autofill { | 17 namespace autofill { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 const char kAutofillDriverImplWebContentsUserDataKey[] = | 21 const char kAutofillDriverImplWebContentsUserDataKey[] = |
21 "web_contents_autofill_driver_impl"; | 22 "web_contents_autofill_driver_impl"; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 SetAutofillExternalDelegate(scoped_ptr<AutofillExternalDelegate>( | 62 SetAutofillExternalDelegate(scoped_ptr<AutofillExternalDelegate>( |
62 new AutofillExternalDelegate(web_contents, autofill_manager_.get()))); | 63 new AutofillExternalDelegate(web_contents, autofill_manager_.get()))); |
63 } | 64 } |
64 | 65 |
65 AutofillDriverImpl::~AutofillDriverImpl() {} | 66 AutofillDriverImpl::~AutofillDriverImpl() {} |
66 | 67 |
67 content::WebContents* AutofillDriverImpl::GetWebContents() { | 68 content::WebContents* AutofillDriverImpl::GetWebContents() { |
68 return web_contents(); | 69 return web_contents(); |
69 } | 70 } |
70 | 71 |
| 72 bool AutofillDriverImpl::RendererIsAvailable() { |
| 73 return (web_contents()->GetRenderViewHost() != NULL); |
| 74 } |
| 75 |
| 76 void AutofillDriverImpl::SendFormDataToRenderer(int query_id, |
| 77 const FormData& data) { |
| 78 if (!RendererIsAvailable()) |
| 79 return; |
| 80 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); |
| 81 host->Send( |
| 82 new AutofillMsg_FormDataFilled(host->GetRoutingID(), query_id, data)); |
| 83 } |
| 84 |
71 bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) { | 85 bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) { |
72 bool handled = true; | 86 bool handled = true; |
73 IPC_BEGIN_MESSAGE_MAP(AutofillDriverImpl, message) | 87 IPC_BEGIN_MESSAGE_MAP(AutofillDriverImpl, message) |
74 IPC_MESSAGE_FORWARD(AutofillHostMsg_FormsSeen, autofill_manager_.get(), | 88 IPC_MESSAGE_FORWARD(AutofillHostMsg_FormsSeen, autofill_manager_.get(), |
75 AutofillManager::OnFormsSeen) | 89 AutofillManager::OnFormsSeen) |
76 IPC_MESSAGE_FORWARD(AutofillHostMsg_FormSubmitted, autofill_manager_.get(), | 90 IPC_MESSAGE_FORWARD(AutofillHostMsg_FormSubmitted, autofill_manager_.get(), |
77 AutofillManager::OnFormSubmitted) | 91 AutofillManager::OnFormSubmitted) |
78 IPC_MESSAGE_FORWARD(AutofillHostMsg_TextFieldDidChange, | 92 IPC_MESSAGE_FORWARD(AutofillHostMsg_TextFieldDidChange, |
79 autofill_manager_.get(), | 93 autofill_manager_.get(), |
80 AutofillManager::OnTextFieldDidChange) | 94 AutofillManager::OnTextFieldDidChange) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get()); | 152 autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get()); |
139 } | 153 } |
140 | 154 |
141 void AutofillDriverImpl::SetAutofillManager( | 155 void AutofillDriverImpl::SetAutofillManager( |
142 scoped_ptr<AutofillManager> manager) { | 156 scoped_ptr<AutofillManager> manager) { |
143 autofill_manager_ = manager.Pass(); | 157 autofill_manager_ = manager.Pass(); |
144 autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get()); | 158 autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get()); |
145 } | 159 } |
146 | 160 |
147 } // namespace autofill | 161 } // namespace autofill |
OLD | NEW |