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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 contents_(contents), 131 contents_(contents),
132 form_structure_(form), 132 form_structure_(form),
133 source_url_(source_url), 133 source_url_(source_url),
134 ssl_status_(ssl_status), 134 ssl_status_(ssl_status),
135 callback_(callback), 135 callback_(callback),
136 wallet_client_(profile_->GetRequestContext()), 136 wallet_client_(profile_->GetRequestContext()),
137 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), 137 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)),
138 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), 138 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)),
139 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), 139 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)),
140 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), 140 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)),
141 popup_controller_(NULL),
142 section_showing_popup_(SECTION_BILLING) { 141 section_showing_popup_(SECTION_BILLING) {
143 // TODO(estade): |this| should observe PersonalDataManager. 142 // TODO(estade): |this| should observe PersonalDataManager.
144 // TODO(estade): remove duplicates from |form|? 143 // TODO(estade): remove duplicates from |form|?
145 144
146 content::NavigationEntry* entry = contents->GetController().GetActiveEntry(); 145 content::NavigationEntry* entry = contents->GetController().GetActiveEntry();
147 const GURL& active_url = entry ? entry->GetURL() : web_contents()->GetURL(); 146 const GURL& active_url = entry ? entry->GetURL() : web_contents()->GetURL();
148 invoked_from_same_origin_ = active_url.GetOrigin() == source_url_.GetOrigin(); 147 invoked_from_same_origin_ = active_url.GetOrigin() == source_url_.GetOrigin();
149 } 148 }
150 149
151 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { 150 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() {
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 return profile_; 582 return profile_;
584 } 583 }
585 584
586 content::WebContents* AutofillDialogControllerImpl::web_contents() { 585 content::WebContents* AutofillDialogControllerImpl::web_contents() {
587 return contents_; 586 return contents_;
588 } 587 }
589 588
590 //////////////////////////////////////////////////////////////////////////////// 589 ////////////////////////////////////////////////////////////////////////////////
591 // AutofillPopupDelegate 590 // AutofillPopupDelegate
592 591
592 void AutofillDialogControllerImpl::OnPopupShown(
593 content::KeyboardListener* listener) {}
594
595 void AutofillDialogControllerImpl::OnPopupHidden(
596 content::KeyboardListener* listener) {}
597
593 void AutofillDialogControllerImpl::DidSelectSuggestion(int identifier) { 598 void AutofillDialogControllerImpl::DidSelectSuggestion(int identifier) {
594 // TODO(estade): implement. 599 // TODO(estade): implement.
595 } 600 }
596 601
597 void AutofillDialogControllerImpl::DidAcceptSuggestion(const string16& value, 602 void AutofillDialogControllerImpl::DidAcceptSuggestion(const string16& value,
598 int identifier) { 603 int identifier) {
599 const PersonalDataManager::GUIDPair& pair = popup_guids_[identifier]; 604 const PersonalDataManager::GUIDPair& pair = popup_guids_[identifier];
600 605
601 FormGroup* form_group = section_showing_popup_ == SECTION_CC ? 606 FormGroup* form_group = section_showing_popup_ == SECTION_CC ?
602 static_cast<FormGroup*>(GetManager()->GetCreditCardByGUID(pair.first)) : 607 static_cast<FormGroup*>(GetManager()->GetCreditCardByGUID(pair.first)) :
(...skipping 15 matching lines...) Expand all
618 623
619 void AutofillDialogControllerImpl::RemoveSuggestion(const string16& value, 624 void AutofillDialogControllerImpl::RemoveSuggestion(const string16& value,
620 int identifier) { 625 int identifier) {
621 // TODO(estade): implement. 626 // TODO(estade): implement.
622 } 627 }
623 628
624 void AutofillDialogControllerImpl::ClearPreviewedForm() { 629 void AutofillDialogControllerImpl::ClearPreviewedForm() {
625 // TODO(estade): implement. 630 // TODO(estade): implement.
626 } 631 }
627 632
628 void AutofillDialogControllerImpl::ControllerDestroyed() {
629 popup_controller_ = NULL;
630 }
631
632 //////////////////////////////////////////////////////////////////////////////// 633 ////////////////////////////////////////////////////////////////////////////////
633 // content::NotificationObserver 634 // content::NotificationObserver
634 635
635 void AutofillDialogControllerImpl::Observe( 636 void AutofillDialogControllerImpl::Observe(
636 int type, 637 int type,
637 const content::NotificationSource& source, 638 const content::NotificationSource& source,
638 const content::NotificationDetails& details) { 639 const content::NotificationDetails& details) {
639 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); 640 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED);
640 content::LoadCommittedDetails* load_details = 641 content::LoadCommittedDetails* load_details =
641 content::Details<content::LoadCommittedDetails>(details).ptr(); 642 content::Details<content::LoadCommittedDetails>(details).ptr();
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 PersonalDataManager* AutofillDialogControllerImpl::GetManager() { 935 PersonalDataManager* AutofillDialogControllerImpl::GetManager() {
935 return PersonalDataManagerFactory::GetForProfile(profile_); 936 return PersonalDataManagerFactory::GetForProfile(profile_);
936 } 937 }
937 938
938 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( 939 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection(
939 DialogSection section) { 940 DialogSection section) {
940 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); 941 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section));
941 } 942 }
942 943
943 void AutofillDialogControllerImpl::HidePopup() { 944 void AutofillDialogControllerImpl::HidePopup() {
944 if (popup_controller_) { 945 if (popup_controller_)
945 popup_controller_->Hide(); 946 popup_controller_->Hide();
946 ControllerDestroyed();
947 }
948 } 947 }
949 948
950 } // namespace autofill 949 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698