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

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

Issue 1943873002: Postpone deletion of (Password)AutofillAgent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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 <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
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 // As described in http://crbug.com/608100, there might be an AutofillAgent
317 // method in-progress lower on the stack. Destroying |this| would cause
318 // use-after-free once the lower stack frame becomes active. Instead, a task
319 // needs to be posted to delete this.
320 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
321 }
322
315 void AutofillAgent::FocusChangeComplete() { 323 void AutofillAgent::FocusChangeComplete() {
316 WebDocument doc = render_frame()->GetWebFrame()->document(); 324 WebDocument doc = render_frame()->GetWebFrame()->document();
317 WebElement focused_element; 325 WebElement focused_element;
318 if (!doc.isNull()) 326 if (!doc.isNull())
319 focused_element = doc.focusedElement(); 327 focused_element = doc.focusedElement();
320 328
321 if (!focused_element.isNull() && password_generation_agent_ && 329 if (!focused_element.isNull() && password_generation_agent_ &&
322 password_generation_agent_->FocusedNodeHasChanged(focused_element)) { 330 password_generation_agent_->FocusedNodeHasChanged(focused_element)) {
323 is_generation_popup_possibly_visible_ = true; 331 is_generation_popup_possibly_visible_ = true;
324 is_popup_possibly_visible_ = true; 332 is_popup_possibly_visible_ = true;
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 854
847 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { 855 void AutofillAgent::LegacyAutofillAgent::OnDestruct() {
848 // No-op. Don't delete |this|. 856 // No-op. Don't delete |this|.
849 } 857 }
850 858
851 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { 859 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() {
852 agent_->FocusChangeComplete(); 860 agent_->FocusChangeComplete();
853 } 861 }
854 862
855 } // namespace autofill 863 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/renderer/autofill_agent.h ('k') | components/autofill/content/renderer/password_autofill_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698