| 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 19 matching lines...) Expand all Loading... |
| 30 tab_contents_wrapper ? tab_contents_wrapper->web_contents() : NULL), | 30 tab_contents_wrapper ? tab_contents_wrapper->web_contents() : NULL), |
| 31 autofill_query_id_(0), | 31 autofill_query_id_(0), |
| 32 display_warning_if_disabled_(false), | 32 display_warning_if_disabled_(false), |
| 33 has_shown_autofill_popup_for_current_edit_(false), | 33 has_shown_autofill_popup_for_current_edit_(false), |
| 34 suggestions_clear_index_(-1), | 34 suggestions_clear_index_(-1), |
| 35 suggestions_options_index_(-1) { | 35 suggestions_options_index_(-1) { |
| 36 } | 36 } |
| 37 | 37 |
| 38 void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id, | 38 void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id, |
| 39 int list_index) { | 39 int list_index) { |
| 40 if (password_autofill_manager_.DidSelectAutofillSuggestion( | 40 if (unique_id == WebAutofillClient::MenuItemIDPasswordEntry) |
| 41 autofill_query_field_)) | |
| 42 return; | 41 return; |
| 43 | 42 |
| 44 if (list_index == suggestions_options_index_ || | 43 if (list_index == suggestions_options_index_ || |
| 45 list_index == suggestions_clear_index_ || | 44 list_index == suggestions_clear_index_ || |
| 46 unique_id == WebAutofillClient::MenuItemIDWarningMessage) | 45 unique_id == WebAutofillClient::MenuItemIDWarningMessage) |
| 47 return; | 46 return; |
| 48 | 47 |
| 49 FillAutofillFormData(unique_id, true); | 48 FillAutofillFormData(unique_id, true); |
| 50 } | 49 } |
| 51 | 50 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 if (suggestions_options_index_ != -1 && | 177 if (suggestions_options_index_ != -1 && |
| 179 index == static_cast<unsigned>(suggestions_options_index_)) { | 178 index == static_cast<unsigned>(suggestions_options_index_)) { |
| 180 // User selected 'Autofill Options'. | 179 // User selected 'Autofill Options'. |
| 181 autofill_manager_->OnShowAutofillDialog(); | 180 autofill_manager_->OnShowAutofillDialog(); |
| 182 } else if (suggestions_clear_index_ != -1 && | 181 } else if (suggestions_clear_index_ != -1 && |
| 183 index == static_cast<unsigned>(suggestions_clear_index_)) { | 182 index == static_cast<unsigned>(suggestions_clear_index_)) { |
| 184 // User selected 'Clear form'. | 183 // User selected 'Clear form'. |
| 185 RenderViewHost* host = | 184 RenderViewHost* host = |
| 186 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); | 185 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); |
| 187 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); | 186 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); |
| 188 } else if (password_autofill_manager_.DidAcceptAutofillSuggestion( | 187 } else if (unique_id == WebAutofillClient::MenuItemIDPasswordEntry && |
| 188 password_autofill_manager_.DidAcceptAutofillSuggestion( |
| 189 autofill_query_field_, value)) { | 189 autofill_query_field_, value)) { |
| 190 // DidAcceptAutofillSuggestion has already handled the work to fill in | 190 // DidAcceptAutofillSuggestion has already handled the work to fill in |
| 191 // the page as required. | 191 // the page as required. |
| 192 } else if (!unique_id) { | 192 } else if (!unique_id) { |
| 193 // User selected an Autocomplete, so we fill directly. | 193 // User selected an Autocomplete, so we fill directly. |
| 194 RenderViewHost* host = | 194 RenderViewHost* host = |
| 195 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); | 195 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); |
| 196 host->Send(new AutofillMsg_SetNodeText( | 196 host->Send(new AutofillMsg_SetNodeText( |
| 197 host->GetRoutingID(), | 197 host->GetRoutingID(), |
| 198 value)); | 198 value)); |
| 199 } else { | 199 } else { |
| 200 FillAutofillFormData(unique_id, false); | 200 FillAutofillFormData(unique_id, false); |
| 201 } | 201 } |
| 202 | 202 |
| 203 HideAutofillPopup(); | 203 HideAutofillPopup(); |
| 204 | 204 |
| 205 return true; | 205 return true; |
| 206 } | 206 } |
| 207 | 207 |
| 208 void AutofillExternalDelegate::ClearPreviewedForm() { | 208 void AutofillExternalDelegate::ClearPreviewedForm() { |
| 209 if (password_autofill_manager_.DidClearAutofillSelection( | |
| 210 autofill_query_field_)) | |
| 211 return; | |
| 212 | |
| 213 RenderViewHost* host = | 209 RenderViewHost* host = |
| 214 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); | 210 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); |
| 215 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); | 211 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); |
| 216 } | 212 } |
| 217 | 213 |
| 218 void AutofillExternalDelegate::HideAutofillPopup() { | 214 void AutofillExternalDelegate::HideAutofillPopup() { |
| 219 suggestions_clear_index_ = -1; | 215 suggestions_clear_index_ = -1; |
| 220 suggestions_options_index_ = -1; | 216 suggestions_options_index_ = -1; |
| 221 | 217 |
| 222 HideAutofillPopupInternal(); | 218 HideAutofillPopupInternal(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // none, so all platforms use the default. | 255 // none, so all platforms use the default. |
| 260 | 256 |
| 261 #if !defined(OS_ANDROID) && !defined(TOOLKIT_GTK) | 257 #if !defined(OS_ANDROID) && !defined(TOOLKIT_GTK) |
| 262 | 258 |
| 263 AutofillExternalDelegate* AutofillExternalDelegate::Create( | 259 AutofillExternalDelegate* AutofillExternalDelegate::Create( |
| 264 TabContentsWrapper*, AutofillManager*) { | 260 TabContentsWrapper*, AutofillManager*) { |
| 265 return NULL; | 261 return NULL; |
| 266 } | 262 } |
| 267 | 263 |
| 268 #endif | 264 #endif |
| OLD | NEW |