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

Side by Side Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 151503006: Re-land r248110 with ASAN error fixed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Punctuation Created 6 years, 10 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/content/renderer/autofill_agent.h" 5 #include "components/autofill/content/renderer/autofill_agent.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "components/autofill/content/common/autofill_messages.h" 14 #include "components/autofill/content/common/autofill_messages.h"
15 #include "components/autofill/content/renderer/form_autofill_util.h" 15 #include "components/autofill/content/renderer/form_autofill_util.h"
16 #include "components/autofill/content/renderer/page_click_tracker.h" 16 #include "components/autofill/content/renderer/page_click_tracker.h"
17 #include "components/autofill/content/renderer/password_autofill_agent.h" 17 #include "components/autofill/content/renderer/password_autofill_agent.h"
18 #include "components/autofill/content/renderer/password_generation_agent.h"
18 #include "components/autofill/core/common/autofill_constants.h" 19 #include "components/autofill/core/common/autofill_constants.h"
19 #include "components/autofill/core/common/autofill_data_validation.h" 20 #include "components/autofill/core/common/autofill_data_validation.h"
20 #include "components/autofill/core/common/autofill_switches.h" 21 #include "components/autofill/core/common/autofill_switches.h"
21 #include "components/autofill/core/common/form_data.h" 22 #include "components/autofill/core/common/form_data.h"
22 #include "components/autofill/core/common/form_data_predictions.h" 23 #include "components/autofill/core/common/form_data_predictions.h"
23 #include "components/autofill/core/common/form_field_data.h" 24 #include "components/autofill/core/common/form_field_data.h"
24 #include "components/autofill/core/common/password_form.h" 25 #include "components/autofill/core/common/password_form.h"
25 #include "components/autofill/core/common/web_element_descriptor.h" 26 #include "components/autofill/core/common/web_element_descriptor.h"
26 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
27 #include "content/public/common/ssl_status.h" 28 #include "content/public/common/ssl_status.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if (strings->size() > kMaxListSize) 103 if (strings->size() > kMaxListSize)
103 strings->resize(kMaxListSize); 104 strings->resize(kMaxListSize);
104 105
105 // Limit the size of the strings in the vector. 106 // Limit the size of the strings in the vector.
106 for (size_t i = 0; i < strings->size(); ++i) { 107 for (size_t i = 0; i < strings->size(); ++i) {
107 if ((*strings)[i].length() > kMaxDataLength) 108 if ((*strings)[i].length() > kMaxDataLength)
108 (*strings)[i].resize(kMaxDataLength); 109 (*strings)[i].resize(kMaxDataLength);
109 } 110 }
110 } 111 }
111 112
112 gfx::RectF GetScaledBoundingBox(float scale, WebInputElement* element) {
113 gfx::Rect bounding_box(element->boundsInViewportSpace());
114 return gfx::RectF(bounding_box.x() * scale,
115 bounding_box.y() * scale,
116 bounding_box.width() * scale,
117 bounding_box.height() * scale);
118 }
119
120 } // namespace 113 } // namespace
121 114
122 AutofillAgent::AutofillAgent(content::RenderView* render_view, 115 AutofillAgent::AutofillAgent(content::RenderView* render_view,
123 PasswordAutofillAgent* password_autofill_agent) 116 PasswordAutofillAgent* password_autofill_agent,
117 PasswordGenerationAgent* password_generation_agent)
124 : content::RenderViewObserver(render_view), 118 : content::RenderViewObserver(render_view),
125 password_autofill_agent_(password_autofill_agent), 119 password_autofill_agent_(password_autofill_agent),
120 password_generation_agent_(password_generation_agent),
126 autofill_query_id_(0), 121 autofill_query_id_(0),
127 autofill_action_(AUTOFILL_NONE), 122 autofill_action_(AUTOFILL_NONE),
128 web_view_(render_view->GetWebView()), 123 web_view_(render_view->GetWebView()),
129 display_warning_if_disabled_(false), 124 display_warning_if_disabled_(false),
130 was_query_node_autofilled_(false), 125 was_query_node_autofilled_(false),
131 has_shown_autofill_popup_for_current_edit_(false), 126 has_shown_autofill_popup_for_current_edit_(false),
132 did_set_node_text_(false), 127 did_set_node_text_(false),
133 has_new_forms_for_browser_(false), 128 has_new_forms_for_browser_(false),
134 ignore_text_changes_(false), 129 ignore_text_changes_(false),
135 weak_ptr_factory_(this) { 130 weak_ptr_factory_(this) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 weak_ptr_factory_.GetWeakPtr(), 322 weak_ptr_factory_.GetWeakPtr(),
328 element)); 323 element));
329 } 324 }
330 325
331 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) { 326 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) {
332 // If the element isn't focused then the changes don't matter. This check is 327 // If the element isn't focused then the changes don't matter. This check is
333 // required to properly handle IME interactions. 328 // required to properly handle IME interactions.
334 if (!element.focused()) 329 if (!element.focused())
335 return; 330 return;
336 331
332 if (password_generation_agent_ &&
333 password_generation_agent_->TextDidChangeInTextField(element)) {
334 return;
335 }
336
337 if (password_autofill_agent_->TextDidChangeInTextField(element)) { 337 if (password_autofill_agent_->TextDidChangeInTextField(element)) {
338 element_ = element; 338 element_ = element;
339 return; 339 return;
340 } 340 }
341 341
342 ShowSuggestions(element, false, true, false, false); 342 ShowSuggestions(element, false, true, false, false);
343 343
344 FormData form; 344 FormData form;
345 FormFieldData field; 345 FormFieldData field;
346 if (FindFormAndFieldForInputElement(element, &form, &field, REQUIRE_NONE)) { 346 if (FindFormAndFieldForInputElement(element, &form, &field, REQUIRE_NONE)) {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 // Only monitors dynamic forms created in the top frame. Dynamic forms 630 // Only monitors dynamic forms created in the top frame. Dynamic forms
631 // inserted in iframes are not captured yet. 631 // inserted in iframes are not captured yet.
632 if (!frame->parent()) { 632 if (!frame->parent()) {
633 password_autofill_agent_->OnDynamicFormsSeen(frame); 633 password_autofill_agent_->OnDynamicFormsSeen(frame);
634 return; 634 return;
635 } 635 }
636 } 636 }
637 } 637 }
638 638
639 } // namespace autofill 639 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/renderer/autofill_agent.h ('k') | components/autofill/content/renderer/form_autofill_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698