OLD | NEW |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 42 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
43 #include "third_party/WebKit/public/web/WebNode.h" | 43 #include "third_party/WebKit/public/web/WebNode.h" |
44 #include "third_party/WebKit/public/web/WebOptionElement.h" | 44 #include "third_party/WebKit/public/web/WebOptionElement.h" |
45 #include "third_party/WebKit/public/web/WebTextAreaElement.h" | 45 #include "third_party/WebKit/public/web/WebTextAreaElement.h" |
46 #include "third_party/WebKit/public/web/WebView.h" | 46 #include "third_party/WebKit/public/web/WebView.h" |
47 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
48 #include "ui/events/keycodes/keyboard_codes.h" | 48 #include "ui/events/keycodes/keyboard_codes.h" |
49 | 49 |
50 using blink::WebAutofillClient; | 50 using blink::WebAutofillClient; |
51 using blink::WebConsoleMessage; | 51 using blink::WebConsoleMessage; |
| 52 using blink::WebDocument; |
52 using blink::WebElement; | 53 using blink::WebElement; |
53 using blink::WebElementCollection; | 54 using blink::WebElementCollection; |
54 using blink::WebFormControlElement; | 55 using blink::WebFormControlElement; |
55 using blink::WebFormElement; | 56 using blink::WebFormElement; |
56 using blink::WebFrame; | 57 using blink::WebFrame; |
57 using blink::WebInputElement; | 58 using blink::WebInputElement; |
58 using blink::WebKeyboardEvent; | 59 using blink::WebKeyboardEvent; |
59 using blink::WebLocalFrame; | 60 using blink::WebLocalFrame; |
60 using blink::WebNode; | 61 using blink::WebNode; |
61 using blink::WebOptionElement; | 62 using blink::WebOptionElement; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 209 |
209 void AutofillAgent::FocusedNodeChanged(const WebNode& node) { | 210 void AutofillAgent::FocusedNodeChanged(const WebNode& node) { |
210 HidePopup(); | 211 HidePopup(); |
211 | 212 |
212 if (node.isNull() || !node.isElementNode()) | 213 if (node.isNull() || !node.isElementNode()) |
213 return; | 214 return; |
214 | 215 |
215 if (node.document().frame() != render_frame()->GetWebFrame()) | 216 if (node.document().frame() != render_frame()->GetWebFrame()) |
216 return; | 217 return; |
217 | 218 |
218 if (password_generation_agent_ && | |
219 password_generation_agent_->FocusedNodeHasChanged(node)) { | |
220 is_popup_possibly_visible_ = true; | |
221 return; | |
222 } | |
223 | |
224 WebElement web_element = node.toConst<WebElement>(); | 219 WebElement web_element = node.toConst<WebElement>(); |
225 | 220 |
226 if (!web_element.document().frame()) | 221 if (!web_element.document().frame()) |
227 return; | 222 return; |
228 | 223 |
229 const WebInputElement* element = toWebInputElement(&web_element); | 224 const WebInputElement* element = toWebInputElement(&web_element); |
230 | 225 |
231 if (!element || !element->isEnabled() || element->isReadOnly() || | 226 if (!element || !element->isEnabled() || element->isReadOnly() || |
232 !element->isTextField() || element->isPasswordField()) | 227 !element->isTextField()) |
233 return; | 228 return; |
234 | 229 |
235 element_ = *element; | 230 element_ = *element; |
236 } | 231 } |
237 | 232 |
| 233 void AutofillAgent::FocusChangeComplete() { |
| 234 WebDocument doc = render_frame()->GetWebFrame()->document(); |
| 235 WebElement focused_element; |
| 236 if (!doc.isNull()) |
| 237 focused_element = doc.focusedElement(); |
| 238 |
| 239 if (!focused_element.isNull() && password_generation_agent_ && |
| 240 password_generation_agent_->FocusedNodeHasChanged(focused_element)) { |
| 241 is_popup_possibly_visible_ = true; |
| 242 } |
| 243 } |
| 244 |
238 void AutofillAgent::didRequestAutocomplete( | 245 void AutofillAgent::didRequestAutocomplete( |
239 const WebFormElement& form) { | 246 const WebFormElement& form) { |
240 DCHECK_EQ(form.document().frame(), render_frame()->GetWebFrame()); | 247 DCHECK_EQ(form.document().frame(), render_frame()->GetWebFrame()); |
241 | 248 |
242 // Disallow the dialog over non-https or broken https, except when the | 249 // Disallow the dialog over non-https or broken https, except when the |
243 // ignore SSL flag is passed. See http://crbug.com/272512. | 250 // ignore SSL flag is passed. See http://crbug.com/272512. |
244 // TODO(palmer): this should be moved to the browser process after frames | 251 // TODO(palmer): this should be moved to the browser process after frames |
245 // get their own processes. | 252 // get their own processes. |
246 GURL url(form.document().url()); | 253 GURL url(form.document().url()); |
247 content::SSLStatus ssl_status = | 254 content::SSLStatus ssl_status = |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 | 783 |
777 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 784 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
778 // No-op. Don't delete |this|. | 785 // No-op. Don't delete |this|. |
779 } | 786 } |
780 | 787 |
781 void AutofillAgent::LegacyAutofillAgent::FocusedNodeChanged( | 788 void AutofillAgent::LegacyAutofillAgent::FocusedNodeChanged( |
782 const WebNode& node) { | 789 const WebNode& node) { |
783 agent_->FocusedNodeChanged(node); | 790 agent_->FocusedNodeChanged(node); |
784 } | 791 } |
785 | 792 |
| 793 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
| 794 agent_->FocusChangeComplete(); |
| 795 } |
| 796 |
786 } // namespace autofill | 797 } // namespace autofill |
OLD | NEW |