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

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

Issue 63273002: Rename WebKit namespace to blink (part 4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
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"
(...skipping 24 matching lines...) Expand all
35 #include "third_party/WebKit/public/web/WebFormElement.h" 35 #include "third_party/WebKit/public/web/WebFormElement.h"
36 #include "third_party/WebKit/public/web/WebFrame.h" 36 #include "third_party/WebKit/public/web/WebFrame.h"
37 #include "third_party/WebKit/public/web/WebInputEvent.h" 37 #include "third_party/WebKit/public/web/WebInputEvent.h"
38 #include "third_party/WebKit/public/web/WebNode.h" 38 #include "third_party/WebKit/public/web/WebNode.h"
39 #include "third_party/WebKit/public/web/WebNodeCollection.h" 39 #include "third_party/WebKit/public/web/WebNodeCollection.h"
40 #include "third_party/WebKit/public/web/WebOptionElement.h" 40 #include "third_party/WebKit/public/web/WebOptionElement.h"
41 #include "third_party/WebKit/public/web/WebView.h" 41 #include "third_party/WebKit/public/web/WebView.h"
42 #include "ui/base/l10n/l10n_util.h" 42 #include "ui/base/l10n/l10n_util.h"
43 #include "ui/events/keycodes/keyboard_codes.h" 43 #include "ui/events/keycodes/keyboard_codes.h"
44 44
45 using WebKit::WebAutofillClient; 45 using blink::WebAutofillClient;
46 using WebKit::WebFormControlElement; 46 using blink::WebFormControlElement;
47 using WebKit::WebFormElement; 47 using blink::WebFormElement;
48 using WebKit::WebFrame; 48 using blink::WebFrame;
49 using WebKit::WebInputElement; 49 using blink::WebInputElement;
50 using WebKit::WebKeyboardEvent; 50 using blink::WebKeyboardEvent;
51 using WebKit::WebNode; 51 using blink::WebNode;
52 using WebKit::WebNodeCollection; 52 using blink::WebNodeCollection;
53 using WebKit::WebOptionElement; 53 using blink::WebOptionElement;
54 using WebKit::WebString; 54 using blink::WebString;
55 55
56 namespace { 56 namespace {
57 57
58 // The size above which we stop triggering autofill for an input text field 58 // The size above which we stop triggering autofill for an input text field
59 // (so to avoid sending long strings through IPC). 59 // (so to avoid sending long strings through IPC).
60 const size_t kMaximumTextSizeForAutofill = 1000; 60 const size_t kMaximumTextSizeForAutofill = 1000;
61 61
62 // The maximum number of data list elements to send to the browser process 62 // The maximum number of data list elements to send to the browser process
63 // via IPC (to prevent long IPC messages). 63 // via IPC (to prevent long IPC messages).
64 const size_t kMaximumDataListSizeForAutofill = 30; 64 const size_t kMaximumDataListSizeForAutofill = 30;
65 65
66 66
67 // Gets all the data list values (with corresponding label) for the given 67 // Gets all the data list values (with corresponding label) for the given
68 // element. 68 // element.
69 void GetDataListSuggestions(const WebKit::WebInputElement& element, 69 void GetDataListSuggestions(const blink::WebInputElement& element,
70 std::vector<base::string16>* values, 70 std::vector<base::string16>* values,
71 std::vector<base::string16>* labels) { 71 std::vector<base::string16>* labels) {
72 WebNodeCollection options = element.dataListOptions(); 72 WebNodeCollection options = element.dataListOptions();
73 if (options.isNull()) 73 if (options.isNull())
74 return; 74 return;
75 75
76 base::string16 prefix = element.editingValue(); 76 base::string16 prefix = element.editingValue();
77 if (element.isMultiple() && 77 if (element.isMultiple() &&
78 element.formControlType() == WebString::fromUTF8("email")) { 78 element.formControlType() == WebString::fromUTF8("email")) {
79 std::vector<base::string16> parts; 79 std::vector<base::string16> parts;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 226 }
227 } 227 }
228 228
229 void AutofillAgent::ZoomLevelChanged() { 229 void AutofillAgent::ZoomLevelChanged() {
230 // Any time the zoom level changes, the page's content moves, so any Autofill 230 // Any time the zoom level changes, the page's content moves, so any Autofill
231 // popups should be hidden. This is only needed for the new Autofill UI 231 // popups should be hidden. This is only needed for the new Autofill UI
232 // because WebKit already knows to hide the old UI when this occurs. 232 // because WebKit already knows to hide the old UI when this occurs.
233 HideAutofillUI(); 233 HideAutofillUI();
234 } 234 }
235 235
236 void AutofillAgent::FocusedNodeChanged(const WebKit::WebNode& node) { 236 void AutofillAgent::FocusedNodeChanged(const blink::WebNode& node) {
237 if (node.isNull() || !node.isElementNode()) 237 if (node.isNull() || !node.isElementNode())
238 return; 238 return;
239 239
240 WebKit::WebElement web_element = node.toConst<WebKit::WebElement>(); 240 blink::WebElement web_element = node.toConst<blink::WebElement>();
241 241
242 if (!web_element.document().frame()) 242 if (!web_element.document().frame())
243 return; 243 return;
244 244
245 const WebInputElement* element = toWebInputElement(&web_element); 245 const WebInputElement* element = toWebInputElement(&web_element);
246 246
247 if (!element || !element->isEnabled() || element->isReadOnly() || 247 if (!element || !element->isEnabled() || element->isReadOnly() ||
248 !element->isTextField() || element->isPasswordField()) 248 !element->isTextField() || element->isPasswordField())
249 return; 249 return;
250 250
251 element_ = *element; 251 element_ = *element;
252 } 252 }
253 253
254 void AutofillAgent::OrientationChangeEvent(int orientation) { 254 void AutofillAgent::OrientationChangeEvent(int orientation) {
255 HideAutofillUI(); 255 HideAutofillUI();
256 } 256 }
257 257
258 void AutofillAgent::DidChangeScrollOffset(WebKit::WebFrame*) { 258 void AutofillAgent::DidChangeScrollOffset(blink::WebFrame*) {
259 HideAutofillUI(); 259 HideAutofillUI();
260 } 260 }
261 261
262 void AutofillAgent::didRequestAutocomplete(WebKit::WebFrame* frame, 262 void AutofillAgent::didRequestAutocomplete(blink::WebFrame* frame,
263 const WebFormElement& form) { 263 const WebFormElement& form) {
264 GURL url(frame->document().url()); 264 GURL url(frame->document().url());
265 content::SSLStatus ssl_status = render_view()->GetSSLStatusOfFrame(frame); 265 content::SSLStatus ssl_status = render_view()->GetSSLStatusOfFrame(frame);
266 FormData form_data; 266 FormData form_data;
267 if (!in_flight_request_form_.isNull() || 267 if (!in_flight_request_form_.isNull() ||
268 (url.SchemeIs(content::kHttpsScheme) && 268 (url.SchemeIs(content::kHttpsScheme) &&
269 (net::IsCertStatusError(ssl_status.cert_status) || 269 (net::IsCertStatusError(ssl_status.cert_status) ||
270 net::IsCertStatusMinorError(ssl_status.cert_status))) || 270 net::IsCertStatusMinorError(ssl_status.cert_status))) ||
271 !WebFormElementToFormData(form, 271 !WebFormElementToFormData(form,
272 WebFormControlElement(), 272 WebFormControlElement(),
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 &field, REQUIRE_AUTOCOMPLETE)) { 588 &field, REQUIRE_AUTOCOMPLETE)) {
589 return; 589 return;
590 } 590 }
591 591
592 autofill_action_ = action; 592 autofill_action_ = action;
593 Send(new AutofillHostMsg_FillAutofillFormData( 593 Send(new AutofillHostMsg_FillAutofillFormData(
594 routing_id(), autofill_query_id_, form, field, unique_id)); 594 routing_id(), autofill_query_id_, form, field, unique_id));
595 } 595 }
596 596
597 void AutofillAgent::SetNodeText(const base::string16& value, 597 void AutofillAgent::SetNodeText(const base::string16& value,
598 WebKit::WebInputElement* node) { 598 blink::WebInputElement* node) {
599 did_set_node_text_ = true; 599 did_set_node_text_ = true;
600 base::string16 substring = value; 600 base::string16 substring = value;
601 substring = substring.substr(0, node->maxLength()); 601 substring = substring.substr(0, node->maxLength());
602 602
603 node->setEditingValue(substring); 603 node->setEditingValue(substring);
604 } 604 }
605 605
606 void AutofillAgent::HideAutofillUI() { 606 void AutofillAgent::HideAutofillUI() {
607 Send(new AutofillHostMsg_HideAutofillUI(routing_id())); 607 Send(new AutofillHostMsg_HideAutofillUI(routing_id()));
608 } 608 }
609 609
610 // TODO(isherman): Decide if we want to support non-password autofill with AJAX. 610 // TODO(isherman): Decide if we want to support non-password autofill with AJAX.
611 void AutofillAgent::didAssociateFormControls( 611 void AutofillAgent::didAssociateFormControls(
612 const WebKit::WebVector<WebKit::WebNode>& nodes) { 612 const blink::WebVector<blink::WebNode>& nodes) {
613 for (size_t i = 0; i < nodes.size(); ++i) { 613 for (size_t i = 0; i < nodes.size(); ++i) {
614 WebKit::WebFrame* frame = nodes[i].document().frame(); 614 blink::WebFrame* frame = nodes[i].document().frame();
615 // Only monitors dynamic forms created in the top frame. Dynamic forms 615 // Only monitors dynamic forms created in the top frame. Dynamic forms
616 // inserted in iframes are not captured yet. 616 // inserted in iframes are not captured yet.
617 if (!frame->parent()) { 617 if (!frame->parent()) {
618 password_autofill_agent_->OnDynamicFormsSeen(frame); 618 password_autofill_agent_->OnDynamicFormsSeen(frame);
619 return; 619 return;
620 } 620 }
621 } 621 }
622 } 622 }
623 623
624 } // namespace autofill 624 } // 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