| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <tuple> | 9 #include <tuple> |
| 10 | 10 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 return; | 305 return; |
| 306 } | 306 } |
| 307 | 307 |
| 308 if (!element || !element->isEnabled() || element->isReadOnly() || | 308 if (!element || !element->isEnabled() || element->isReadOnly() || |
| 309 !element->isTextField()) | 309 !element->isTextField()) |
| 310 return; | 310 return; |
| 311 | 311 |
| 312 element_ = *element; | 312 element_ = *element; |
| 313 } | 313 } |
| 314 | 314 |
| 315 void AutofillAgent::OnDestruct() { |
| 316 Shutdown(); |
| 317 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 318 } |
| 319 |
| 320 void AutofillAgent::Shutdown() { |
| 321 legacy_.Shutdown(); |
| 322 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 323 } |
| 324 |
| 315 void AutofillAgent::FocusChangeComplete() { | 325 void AutofillAgent::FocusChangeComplete() { |
| 316 WebDocument doc = render_frame()->GetWebFrame()->document(); | 326 WebDocument doc = render_frame()->GetWebFrame()->document(); |
| 317 WebElement focused_element; | 327 WebElement focused_element; |
| 318 if (!doc.isNull()) | 328 if (!doc.isNull()) |
| 319 focused_element = doc.focusedElement(); | 329 focused_element = doc.focusedElement(); |
| 320 | 330 |
| 321 if (!focused_element.isNull() && password_generation_agent_ && | 331 if (!focused_element.isNull() && password_generation_agent_ && |
| 322 password_generation_agent_->FocusedNodeHasChanged(focused_element)) { | 332 password_generation_agent_->FocusedNodeHasChanged(focused_element)) { |
| 323 is_generation_popup_possibly_visible_ = true; | 333 is_generation_popup_possibly_visible_ = true; |
| 324 is_popup_possibly_visible_ = true; | 334 is_popup_possibly_visible_ = true; |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 | 847 |
| 838 AutofillAgent::LegacyAutofillAgent::LegacyAutofillAgent( | 848 AutofillAgent::LegacyAutofillAgent::LegacyAutofillAgent( |
| 839 content::RenderView* render_view, | 849 content::RenderView* render_view, |
| 840 AutofillAgent* agent) | 850 AutofillAgent* agent) |
| 841 : content::RenderViewObserver(render_view), agent_(agent) { | 851 : content::RenderViewObserver(render_view), agent_(agent) { |
| 842 } | 852 } |
| 843 | 853 |
| 844 AutofillAgent::LegacyAutofillAgent::~LegacyAutofillAgent() { | 854 AutofillAgent::LegacyAutofillAgent::~LegacyAutofillAgent() { |
| 845 } | 855 } |
| 846 | 856 |
| 857 void AutofillAgent::LegacyAutofillAgent::Shutdown() { |
| 858 agent_ = nullptr; |
| 859 } |
| 860 |
| 847 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 861 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
| 848 // No-op. Don't delete |this|. | 862 // No-op. Don't delete |this|. |
| 849 } | 863 } |
| 850 | 864 |
| 851 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 865 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
| 852 agent_->FocusChangeComplete(); | 866 if (agent_) |
| 867 agent_->FocusChangeComplete(); |
| 853 } | 868 } |
| 854 | 869 |
| 855 } // namespace autofill | 870 } // namespace autofill |
| OLD | NEW |