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