| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "chrome/browser/autofill/autofill_external_delegate.h" | 6 #include "chrome/browser/autofill/autofill_external_delegate.h" |
| 7 #include "chrome/browser/autofill/autofill_manager.h" | 7 #include "chrome/browser/autofill/autofill_manager.h" |
| 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 9 #include "chrome/common/autofill_messages.h" | 9 #include "chrome/common/autofill_messages.h" |
| 10 #include "chrome/common/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 if (suggestions_options_index_ != -1 && | 152 if (suggestions_options_index_ != -1 && |
| 153 index == static_cast<unsigned>(suggestions_options_index_)) { | 153 index == static_cast<unsigned>(suggestions_options_index_)) { |
| 154 // User selected 'Autofill Options'. | 154 // User selected 'Autofill Options'. |
| 155 autofill_manager_->OnShowAutofillDialog(); | 155 autofill_manager_->OnShowAutofillDialog(); |
| 156 } else if (suggestions_clear_index_ != -1 && | 156 } else if (suggestions_clear_index_ != -1 && |
| 157 index == static_cast<unsigned>(suggestions_clear_index_)) { | 157 index == static_cast<unsigned>(suggestions_clear_index_)) { |
| 158 // User selected 'Clear form'. | 158 // User selected 'Clear form'. |
| 159 RenderViewHost* host = | 159 RenderViewHost* host = |
| 160 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); | 160 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); |
| 161 host->Send(new AutofillMsg_ClearForm(host->routing_id())); | 161 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); |
| 162 } else if (!unique_id) { | 162 } else if (!unique_id) { |
| 163 // User selected an Autocomplete entry, so we fill directly. | 163 // User selected an Autocomplete entry, so we fill directly. |
| 164 RenderViewHost* host = | 164 RenderViewHost* host = |
| 165 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); | 165 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); |
| 166 host->Send(new AutofillMsg_SetNodeText( | 166 host->Send(new AutofillMsg_SetNodeText( |
| 167 host->routing_id(), | 167 host->GetRoutingID(), |
| 168 value)); | 168 value)); |
| 169 } else { | 169 } else { |
| 170 FillAutofillFormData(unique_id, false); | 170 FillAutofillFormData(unique_id, false); |
| 171 } | 171 } |
| 172 | 172 |
| 173 HideAutofillPopup(); | 173 HideAutofillPopup(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void AutofillExternalDelegate::ClearPreviewedForm() { | 176 void AutofillExternalDelegate::ClearPreviewedForm() { |
| 177 RenderViewHost* host = | 177 RenderViewHost* host = |
| 178 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); | 178 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); |
| 179 host->Send(new AutofillMsg_ClearPreviewedForm(host->routing_id())); | 179 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void AutofillExternalDelegate::HideAutofillPopup() { | 182 void AutofillExternalDelegate::HideAutofillPopup() { |
| 183 suggestions_clear_index_ = -1; | 183 suggestions_clear_index_ = -1; |
| 184 suggestions_options_index_ = -1; | 184 suggestions_options_index_ = -1; |
| 185 | 185 |
| 186 HideAutofillPopupInternal(); | 186 HideAutofillPopupInternal(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void AutofillExternalDelegate::FillAutofillFormData(int unique_id, | 189 void AutofillExternalDelegate::FillAutofillFormData(int unique_id, |
| 190 bool is_preview) { | 190 bool is_preview) { |
| 191 RenderViewHost* host = | 191 RenderViewHost* host = |
| 192 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); | 192 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); |
| 193 | 193 |
| 194 if (is_preview) { | 194 if (is_preview) { |
| 195 host->Send(new AutofillMsg_SetAutofillActionPreview( | 195 host->Send(new AutofillMsg_SetAutofillActionPreview( |
| 196 host->routing_id())); | 196 host->GetRoutingID())); |
| 197 } else { | 197 } else { |
| 198 host->Send(new AutofillMsg_SetAutofillActionFill( | 198 host->Send(new AutofillMsg_SetAutofillActionFill( |
| 199 host->routing_id())); | 199 host->GetRoutingID())); |
| 200 } | 200 } |
| 201 | 201 |
| 202 // Fill the values for the whole form. | 202 // Fill the values for the whole form. |
| 203 autofill_manager_->OnFillAutofillFormData(autofill_query_id_, | 203 autofill_manager_->OnFillAutofillFormData(autofill_query_id_, |
| 204 autofill_query_form_, | 204 autofill_query_form_, |
| 205 autofill_query_field_, | 205 autofill_query_field_, |
| 206 unique_id); | 206 unique_id); |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Add a "!defined(OS_YOUROS) for each platform that implements this | 209 // Add a "!defined(OS_YOUROS) for each platform that implements this |
| 210 // in an autofill_external_delegate_YOUROS.cc. Currently there are | 210 // in an autofill_external_delegate_YOUROS.cc. Currently there are |
| 211 // none, so all platforms use the default. | 211 // none, so all platforms use the default. |
| 212 | 212 |
| 213 #if !defined(OS_ANDROID) && !defined(TOOLKIT_GTK) | 213 #if !defined(OS_ANDROID) && !defined(TOOLKIT_GTK) |
| 214 | 214 |
| 215 AutofillExternalDelegate* AutofillExternalDelegate::Create( | 215 AutofillExternalDelegate* AutofillExternalDelegate::Create( |
| 216 TabContentsWrapper*, AutofillManager*) { | 216 TabContentsWrapper*, AutofillManager*) { |
| 217 return NULL; | 217 return NULL; |
| 218 } | 218 } |
| 219 | 219 |
| 220 #endif | 220 #endif |
| OLD | NEW |