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

Unified Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 1946143002: Destroy (Password)AutofillAgent safely (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also setChecked Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/content/renderer/autofill_agent.cc
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc
index c45d5125a1f2102c75d052f4a1ef65de1a6f795d..cb55cf19c5ca47e31378ce785e207b2534e79827 100644
--- a/components/autofill/content/renderer/autofill_agent.cc
+++ b/components/autofill/content/renderer/autofill_agent.cc
@@ -319,6 +319,16 @@ void AutofillAgent::FocusedNodeChanged(const WebNode& node) {
element_ = *element;
}
+void AutofillAgent::OnDestruct() {
+ Shutdown();
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
+}
+
+void AutofillAgent::Shutdown() {
+ legacy_.Shutdown();
+ weak_ptr_factory_.InvalidateWeakPtrs();
+}
+
void AutofillAgent::FocusChangeComplete() {
WebDocument doc = render_frame()->GetWebFrame()->document();
WebElement focused_element;
@@ -862,12 +872,17 @@ AutofillAgent::LegacyAutofillAgent::LegacyAutofillAgent(
AutofillAgent::LegacyAutofillAgent::~LegacyAutofillAgent() {
}
+void AutofillAgent::LegacyAutofillAgent::Shutdown() {
+ agent_ = nullptr;
+}
+
void AutofillAgent::LegacyAutofillAgent::OnDestruct() {
// No-op. Don't delete |this|.
}
void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() {
- agent_->FocusChangeComplete();
+ if (agent_)
+ agent_->FocusChangeComplete();
}
} // namespace autofill
« no previous file with comments | « components/autofill/content/renderer/autofill_agent.h ('k') | components/autofill/content/renderer/form_autofill_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698