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

Side by Side Diff: chrome/renderer/autofill/autofill_agent.cc

Issue 11273096: [autofill] When hiding popups in the renderer also hide those in the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/autofill/autofill_agent.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/renderer/autofill/autofill_agent.h" 5 #include "chrome/renderer/autofill/autofill_agent.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 NULL)) { 197 NULL)) {
198 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data, 198 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data,
199 base::TimeTicks::Now())); 199 base::TimeTicks::Now()));
200 } 200 }
201 } 201 }
202 202
203 void AutofillAgent::ZoomLevelChanged() { 203 void AutofillAgent::ZoomLevelChanged() {
204 // Any time the zoom level changes, the page's content moves, so any Autofill 204 // Any time the zoom level changes, the page's content moves, so any Autofill
205 // popups should be hidden. This is only needed for the new Autofill UI 205 // popups should be hidden. This is only needed for the new Autofill UI
206 // because WebKit already knows to hide the old UI when this occurs. 206 // because WebKit already knows to hide the old UI when this occurs.
207 Send(new AutofillHostMsg_HideAutofillPopup(routing_id())); 207 HideHostPopups();
208 } 208 }
209 209
210 void AutofillAgent::DidChangeScrollOffset(WebKit::WebFrame*) { 210 void AutofillAgent::DidChangeScrollOffset(WebKit::WebFrame*) {
211 // Any time the scroll offset changes, the page's content moves, so Autofill 211 // Any time the scroll offset changes, the page's content moves, so Autofill
212 // popups should be hidden. This is only needed for the new Autofill UI 212 // popups should be hidden. This is only needed for the new Autofill UI
213 // because WebKit already knows to hide the old UI when this occurs. 213 // because WebKit already knows to hide the old UI when this occurs.
214 Send(new AutofillHostMsg_HideAutofillPopup(routing_id())); 214 HideHostPopups();
215 } 215 }
216 216
217 void AutofillAgent::didRequestAutocomplete(WebKit::WebFrame* frame, 217 void AutofillAgent::didRequestAutocomplete(WebKit::WebFrame* frame,
218 const WebFormElement& form) { 218 const WebFormElement& form) {
219 FormData form_data; 219 FormData form_data;
220 if (!in_flight_request_form_.isNull() || 220 if (!in_flight_request_form_.isNull() ||
221 !WebFormElementToFormData(form, 221 !WebFormElementToFormData(form,
222 WebFormControlElement(), 222 WebFormControlElement(),
223 REQUIRE_AUTOCOMPLETE, 223 REQUIRE_AUTOCOMPLETE,
224 EXTRACT_NONE, 224 EXTRACT_NONE,
(...skipping 15 matching lines...) Expand all
240 bool AutofillAgent::InputElementClicked(const WebInputElement& element, 240 bool AutofillAgent::InputElementClicked(const WebInputElement& element,
241 bool was_focused, 241 bool was_focused,
242 bool is_focused) { 242 bool is_focused) {
243 if (was_focused) 243 if (was_focused)
244 ShowSuggestions(element, true, false, true); 244 ShowSuggestions(element, true, false, true);
245 245
246 return false; 246 return false;
247 } 247 }
248 248
249 bool AutofillAgent::InputElementLostFocus() { 249 bool AutofillAgent::InputElementLostFocus() {
250 Send(new AutofillHostMsg_HideAutofillPopup(routing_id())); 250 HideHostPopups();
251 251
252 return false; 252 return false;
253 } 253 }
254 254
255 void AutofillAgent::didAcceptAutofillSuggestion(const WebNode& node, 255 void AutofillAgent::didAcceptAutofillSuggestion(const WebNode& node,
256 const WebString& value, 256 const WebString& value,
257 const WebString& label, 257 const WebString& label,
258 int item_id, 258 int item_id,
259 unsigned index) { 259 unsigned index) {
260 if (password_autofill_manager_->DidAcceptAutofillSuggestion(node, value)) 260 if (password_autofill_manager_->DidAcceptAutofillSuggestion(node, value))
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 i.push_back(string16()); 482 i.push_back(string16());
483 ids.push_back(WebAutofillClient::MenuItemIDSeparator); 483 ids.push_back(WebAutofillClient::MenuItemIDSeparator);
484 } 484 }
485 485
486 // Append the Autofill suggestions. 486 // Append the Autofill suggestions.
487 v.insert(v.end(), values.begin(), values.end()); 487 v.insert(v.end(), values.begin(), values.end());
488 l.insert(l.end(), labels.begin(), labels.end()); 488 l.insert(l.end(), labels.begin(), labels.end());
489 i.insert(i.end(), icons.begin(), icons.end()); 489 i.insert(i.end(), icons.begin(), icons.end());
490 ids.insert(ids.end(), item_ids.begin(), item_ids.end()); 490 ids.insert(ids.end(), item_ids.begin(), item_ids.end());
491 491
492 if (v.empty()) {
493 // No suggestions, any popup currently showing is obsolete.
494 HidePopups();
495 return;
496 }
497
492 WebKit::WebView* web_view = render_view()->GetWebView(); 498 WebKit::WebView* web_view = render_view()->GetWebView();
493 if (!web_view) 499 if (!web_view)
494 return; 500 return;
495 501
496 if (v.empty()) {
497 // No suggestions, any popup currently showing is obsolete.
498 web_view->hidePopups();
499 return;
500 }
501
502 // Send to WebKit for display. 502 // Send to WebKit for display.
503 web_view->applyAutofillSuggestions(element, v, l, i, ids); 503 web_view->applyAutofillSuggestions(element, v, l, i, ids);
504 504
505 Send(new AutofillHostMsg_DidShowAutofillSuggestions( 505 Send(new AutofillHostMsg_DidShowAutofillSuggestions(
506 routing_id(), 506 routing_id(),
507 has_autofill_item && !has_shown_autofill_popup_for_current_edit_)); 507 has_autofill_item && !has_shown_autofill_popup_for_current_edit_));
508 has_shown_autofill_popup_for_current_edit_ |= has_autofill_item; 508 has_shown_autofill_popup_for_current_edit_ |= has_autofill_item;
509 } 509 }
510 510
511 void AutofillAgent::AcceptDataListSuggestion(const string16& suggested_value) { 511 void AutofillAgent::AcceptDataListSuggestion(const string16& suggested_value) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 string16 substring = value; 722 string16 substring = value;
723 substring = substring.substr(0, node->maxLength()); 723 substring = substring.substr(0, node->maxLength());
724 724
725 node->setEditingValue(substring); 725 node->setEditingValue(substring);
726 } 726 }
727 727
728 void AutofillAgent::HidePopups() { 728 void AutofillAgent::HidePopups() {
729 WebKit::WebView* web_view = render_view()->GetWebView(); 729 WebKit::WebView* web_view = render_view()->GetWebView();
730 if (web_view) 730 if (web_view)
731 web_view->hidePopups(); 731 web_view->hidePopups();
732
733 HideHostPopups();
734 }
735
736 void AutofillAgent::HideHostPopups() {
737 Send(new AutofillHostMsg_HideAutofillPopup(routing_id()));
732 } 738 }
733 739
734 } // namespace autofill 740 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/autofill_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698