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

Unified Diff: chrome/browser/autofill/autofill_external_delegate.cc

Issue 12217024: Use WeakPtr to simplify AutofillPopupControllerImpl memory management (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix android build Created 7 years, 10 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: chrome/browser/autofill/autofill_external_delegate.cc
diff --git a/chrome/browser/autofill/autofill_external_delegate.cc b/chrome/browser/autofill/autofill_external_delegate.cc
index 27d2300a77b34949cad7fa82172bb7469d471fd6..1bc339d51f0588471dff640281d1a76654b9a9bd 100644
--- a/chrome/browser/autofill/autofill_external_delegate.cc
+++ b/chrome/browser/autofill/autofill_external_delegate.cc
@@ -46,7 +46,6 @@ AutofillExternalDelegate::AutofillExternalDelegate(
AutofillManager* autofill_manager)
: web_contents_(web_contents),
autofill_manager_(autofill_manager),
- controller_(NULL),
password_autofill_manager_(web_contents),
autofill_query_id_(0),
display_warning_if_disabled_(false),
@@ -192,8 +191,6 @@ void AutofillExternalDelegate::ApplyAutofillSuggestions(
autofill_labels,
autofill_icons,
autofill_unique_ids);
-
- web_contents()->GetRenderViewHost()->AddKeyboardListener(controller_);
}
void AutofillExternalDelegate::SetCurrentDataListValues(
@@ -207,6 +204,18 @@ void AutofillExternalDelegate::SetCurrentDataListValues(
data_list_unique_ids_ = data_list_unique_ids;
}
+void AutofillExternalDelegate::OnPopupShown(
+ content::KeyboardListener* listener) {
+ if (web_contents_)
+ web_contents_->GetRenderViewHost()->AddKeyboardListener(listener);
+}
+
+void AutofillExternalDelegate::OnPopupHidden(
+ content::KeyboardListener* listener) {
+ if (web_contents_)
+ web_contents_->GetRenderViewHost()->RemoveKeyboardListener(listener);
+}
+
void AutofillExternalDelegate::DidSelectSuggestion(int identifier) {
ClearPreviewedForm();
@@ -268,17 +277,10 @@ void AutofillExternalDelegate::ClearPreviewedForm() {
}
}
-void AutofillExternalDelegate::ControllerDestroyed() {
- web_contents()->GetRenderViewHost()->RemoveKeyboardListener(controller_);
- controller_ = NULL;
-}
-
void AutofillExternalDelegate::HideAutofillPopup() {
if (controller_) {
controller_->Hide();
- // Go ahead and invalidate |controller_|. After calling Hide(), it won't
- // inform |this| of its destruction.
- ControllerDestroyed();
+ OnPopupHidden(controller_.get());
}
}
« no previous file with comments | « chrome/browser/autofill/autofill_external_delegate.h ('k') | chrome/browser/autofill/test_autofill_external_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698