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

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: Address comments and fix test 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 contents_(contents), 130 contents_(contents),
131 form_structure_(form), 131 form_structure_(form),
132 source_url_(source_url), 132 source_url_(source_url),
133 ssl_status_(ssl_status), 133 ssl_status_(ssl_status),
134 callback_(callback), 134 callback_(callback),
135 wallet_client_(profile_->GetRequestContext()), 135 wallet_client_(profile_->GetRequestContext()),
136 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), 136 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)),
137 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), 137 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)),
138 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), 138 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)),
139 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), 139 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)),
140 popup_controller_(NULL),
141 section_showing_popup_(SECTION_BILLING) { 140 section_showing_popup_(SECTION_BILLING) {
142 // TODO(estade): |this| should observe PersonalDataManager. 141 // TODO(estade): |this| should observe PersonalDataManager.
143 // TODO(estade): remove duplicates from |form|? 142 // TODO(estade): remove duplicates from |form|?
144 143
145 content::NavigationEntry* entry = contents->GetController().GetActiveEntry(); 144 content::NavigationEntry* entry = contents->GetController().GetActiveEntry();
146 const GURL& active_url = entry ? entry->GetURL() : web_contents()->GetURL(); 145 const GURL& active_url = entry ? entry->GetURL() : web_contents()->GetURL();
147 invoked_from_same_origin_ = active_url.GetOrigin() == source_url_.GetOrigin(); 146 invoked_from_same_origin_ = active_url.GetOrigin() == source_url_.GetOrigin();
148 } 147 }
149 148
150 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { 149 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 return profile_; 574 return profile_;
576 } 575 }
577 576
578 content::WebContents* AutofillDialogControllerImpl::web_contents() { 577 content::WebContents* AutofillDialogControllerImpl::web_contents() {
579 return contents_; 578 return contents_;
580 } 579 }
581 580
582 //////////////////////////////////////////////////////////////////////////////// 581 ////////////////////////////////////////////////////////////////////////////////
583 // AutofillPopupDelegate 582 // AutofillPopupDelegate
584 583
584 void AutofillDialogControllerImpl::OnPopupShown(
585 content::KeyboardListener* listener) {}
586
587 void AutofillDialogControllerImpl::OnPopupHidden(
588 content::KeyboardListener* listener) {}
589
585 void AutofillDialogControllerImpl::DidSelectSuggestion(int identifier) { 590 void AutofillDialogControllerImpl::DidSelectSuggestion(int identifier) {
586 // TODO(estade): implement. 591 // TODO(estade): implement.
587 } 592 }
588 593
589 void AutofillDialogControllerImpl::DidAcceptSuggestion(const string16& value, 594 void AutofillDialogControllerImpl::DidAcceptSuggestion(const string16& value,
590 int identifier) { 595 int identifier) {
591 const PersonalDataManager::GUIDPair& pair = popup_guids_[identifier]; 596 const PersonalDataManager::GUIDPair& pair = popup_guids_[identifier];
592 597
593 FormGroup* form_group = section_showing_popup_ == SECTION_CC ? 598 FormGroup* form_group = section_showing_popup_ == SECTION_CC ?
594 static_cast<FormGroup*>(GetManager()->GetCreditCardByGUID(pair.first)) : 599 static_cast<FormGroup*>(GetManager()->GetCreditCardByGUID(pair.first)) :
(...skipping 15 matching lines...) Expand all
610 615
611 void AutofillDialogControllerImpl::RemoveSuggestion(const string16& value, 616 void AutofillDialogControllerImpl::RemoveSuggestion(const string16& value,
612 int identifier) { 617 int identifier) {
613 // TODO(estade): implement. 618 // TODO(estade): implement.
614 } 619 }
615 620
616 void AutofillDialogControllerImpl::ClearPreviewedForm() { 621 void AutofillDialogControllerImpl::ClearPreviewedForm() {
617 // TODO(estade): implement. 622 // TODO(estade): implement.
618 } 623 }
619 624
620 void AutofillDialogControllerImpl::ControllerDestroyed() {
621 popup_controller_ = NULL;
622 }
623
624 //////////////////////////////////////////////////////////////////////////////// 625 ////////////////////////////////////////////////////////////////////////////////
625 // content::NotificationObserver 626 // content::NotificationObserver
626 627
627 void AutofillDialogControllerImpl::Observe( 628 void AutofillDialogControllerImpl::Observe(
628 int type, 629 int type,
629 const content::NotificationSource& source, 630 const content::NotificationSource& source,
630 const content::NotificationDetails& details) { 631 const content::NotificationDetails& details) {
631 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); 632 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED);
632 content::LoadCommittedDetails* load_details = 633 content::LoadCommittedDetails* load_details =
633 content::Details<content::LoadCommittedDetails>(details).ptr(); 634 content::Details<content::LoadCommittedDetails>(details).ptr();
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 PersonalDataManager* AutofillDialogControllerImpl::GetManager() { 927 PersonalDataManager* AutofillDialogControllerImpl::GetManager() {
927 return PersonalDataManagerFactory::GetForProfile(profile_); 928 return PersonalDataManagerFactory::GetForProfile(profile_);
928 } 929 }
929 930
930 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( 931 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection(
931 DialogSection section) { 932 DialogSection section) {
932 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); 933 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section));
933 } 934 }
934 935
935 void AutofillDialogControllerImpl::HidePopup() { 936 void AutofillDialogControllerImpl::HidePopup() {
936 if (popup_controller_) { 937 if (popup_controller_)
937 popup_controller_->Hide(); 938 popup_controller_->Hide();
938 ControllerDestroyed();
939 }
940 } 939 }
941 940
942 } // namespace autofill 941 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698