Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: components/autofill/core/browser/autofill_external_delegate.cc

Issue 148413002: Add "previewing on hover" support for single-field autocomplete input (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Ilya's 2nd set comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/core/browser/autofill_external_delegate.h" 5 #include "components/autofill/core/browser/autofill_external_delegate.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "components/autofill/core/browser/autocomplete_history_manager.h" 8 #include "components/autofill/core/browser/autocomplete_history_manager.h"
9 #include "components/autofill/core/browser/autofill_driver.h" 9 #include "components/autofill/core/browser/autofill_driver.h"
10 #include "components/autofill/core/browser/autofill_manager.h" 10 #include "components/autofill/core/browser/autofill_manager.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 156
157 void AutofillExternalDelegate::OnPopupHidden() { 157 void AutofillExternalDelegate::OnPopupHidden() {
158 } 158 }
159 159
160 bool AutofillExternalDelegate::ShouldRepostEvent(const ui::MouseEvent& event) { 160 bool AutofillExternalDelegate::ShouldRepostEvent(const ui::MouseEvent& event) {
161 NOTREACHED(); 161 NOTREACHED();
162 return true; 162 return true;
163 } 163 }
164 164
165 void AutofillExternalDelegate::DidSelectSuggestion(int identifier) { 165 void AutofillExternalDelegate::DidSelectSuggestion(
166 const base::string16& value,
167 int identifier) {
166 ClearPreviewedForm(); 168 ClearPreviewedForm();
167 169
168 // Only preview the data if it is a profile. 170 // Only preview the data if it is a profile.
169 if (identifier > 0) 171 if (identifier > 0)
170 FillAutofillFormData(identifier, true); 172 FillAutofillFormData(identifier, true);
173 else if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY)
174 autofill_driver_->RendererShouldPreviewFieldWithValue(value);
171 } 175 }
172 176
173 void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, 177 void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value,
174 int identifier) { 178 int identifier) {
175 if (identifier == POPUP_ITEM_ID_AUTOFILL_OPTIONS) { 179 if (identifier == POPUP_ITEM_ID_AUTOFILL_OPTIONS) {
176 // User selected 'Autofill Options'. 180 // User selected 'Autofill Options'.
177 autofill_manager_->ShowAutofillSettings(); 181 autofill_manager_->ShowAutofillSettings();
178 } else if (identifier == POPUP_ITEM_ID_CLEAR_FORM) { 182 } else if (identifier == POPUP_ITEM_ID_CLEAR_FORM) {
179 // User selected 'Clear form'. 183 // User selected 'Clear form'.
180 autofill_driver_->RendererShouldClearFilledForm(); 184 autofill_driver_->RendererShouldClearFilledForm();
181 } else if (identifier == POPUP_ITEM_ID_PASSWORD_ENTRY) { 185 } else if (identifier == POPUP_ITEM_ID_PASSWORD_ENTRY) {
182 bool success = password_autofill_manager_.DidAcceptAutofillSuggestion( 186 bool success = password_autofill_manager_.DidAcceptAutofillSuggestion(
183 autofill_query_field_, value); 187 autofill_query_field_, value);
184 DCHECK(success); 188 DCHECK(success);
185 } else if (identifier == POPUP_ITEM_ID_DATALIST_ENTRY) { 189 } else if (identifier == POPUP_ITEM_ID_DATALIST_ENTRY) {
186 autofill_driver_->RendererShouldAcceptDataListSuggestion(value); 190 autofill_driver_->RendererShouldAcceptDataListSuggestion(value);
187 } else if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) { 191 } else if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) {
188 // User selected an Autocomplete, so we fill directly. 192 // User selected an Autocomplete, so we fill directly.
189 autofill_driver_->RendererShouldSetNodeText(value); 193 autofill_driver_->RendererShouldFillFieldWithValue(value);
190 } else { 194 } else {
191 FillAutofillFormData(identifier, false); 195 FillAutofillFormData(identifier, false);
192 } 196 }
193 197
194 autofill_manager_->delegate()->HideAutofillPopup(); 198 autofill_manager_->delegate()->HideAutofillPopup();
195 } 199 }
196 200
197 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, 201 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value,
198 int identifier) { 202 int identifier) {
199 if (identifier > 0) { 203 if (identifier > 0) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // Set the values that all datalist elements share. 348 // Set the values that all datalist elements share.
345 autofill_icons->insert(autofill_icons->begin(), 349 autofill_icons->insert(autofill_icons->begin(),
346 data_list_values_.size(), 350 data_list_values_.size(),
347 base::string16()); 351 base::string16());
348 autofill_unique_ids->insert(autofill_unique_ids->begin(), 352 autofill_unique_ids->insert(autofill_unique_ids->begin(),
349 data_list_values_.size(), 353 data_list_values_.size(),
350 POPUP_ITEM_ID_DATALIST_ENTRY); 354 POPUP_ITEM_ID_DATALIST_ENTRY);
351 } 355 }
352 356
353 } // namespace autofill 357 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698