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

Unified Diff: chrome/browser/ui/views/passwords/credentials_selection_view.cc

Issue 2691323002: Fixed memory leak in Password Manager UI. (Closed)
Patch Set: Addressing reviewer's comments Created 3 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
« no previous file with comments | « chrome/browser/ui/views/passwords/credentials_selection_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/passwords/credentials_selection_view.cc
diff --git a/chrome/browser/ui/views/passwords/credentials_selection_view.cc b/chrome/browser/ui/views/passwords/credentials_selection_view.cc
index 54a8f3749e92395a4905219d99c7e16e778abb88..15832cb9951c117e5961df84daf8fc0ce841aa82 100644
--- a/chrome/browser/ui/views/passwords/credentials_selection_view.cc
+++ b/chrome/browser/ui/views/passwords/credentials_selection_view.cc
@@ -55,9 +55,9 @@ CredentialsSelectionView::CredentialsSelectionView(
// The username combobox and password label.
layout->StartRowWithPadding(0, column_set_id, 0,
views::kRelatedControlVerticalSpacing);
- combobox_ = GenerateUsernameCombobox(
+ GenerateUsernameCombobox(
manage_passwords_bubble_model->pending_password().username_value);
- layout->AddView(combobox_);
+ layout->AddView(combobox_.get());
views::Label* label =
GeneratePasswordLabel(manage_passwords_bubble_model->pending_password());
layout->AddView(label);
@@ -67,6 +67,10 @@ CredentialsSelectionView::CredentialsSelectionView(
CredentialsSelectionView::~CredentialsSelectionView() {
ReportUserActionOnce(true, -1);
+ // |combobox_| has a pointer to |combobox_model_|, so |combobox_| should be
+ // deleted before deleting of |combobox_model_|. To ensure this, let's delete
+ // it now.
+ combobox_.reset();
Mathieu 2017/02/15 13:46:57 you could also have combobox_model_ be above combo
dvadym 2017/02/15 13:57:13 Yeah, sure. In other places it was done this way.
}
const autofill::PasswordForm*
@@ -77,7 +81,7 @@ CredentialsSelectionView::GetSelectedCredentials() {
return &password_forms_->at(combobox_->selected_index());
}
-views::Combobox* CredentialsSelectionView::GenerateUsernameCombobox(
+void CredentialsSelectionView::GenerateUsernameCombobox(
const base::string16& best_matched_username) {
std::vector<base::string16> usernames;
size_t best_matched_username_index = password_forms_->size();
@@ -92,19 +96,18 @@ views::Combobox* CredentialsSelectionView::GenerateUsernameCombobox(
}
}
- views::Combobox* combobox =
- new views::Combobox(new ui::SimpleComboboxModel(usernames));
+ combobox_model_.reset(new ui::SimpleComboboxModel(usernames));
+ combobox_.reset(new views::Combobox(combobox_model_.get()));
if (best_matched_username_index < password_forms_->size()) {
is_default_best_match_ = true;
default_index_ = best_matched_username_index;
- combobox->SetSelectedIndex(best_matched_username_index);
+ combobox_->SetSelectedIndex(best_matched_username_index);
} else if (preferred_form_index < password_forms_->size()) {
is_default_preferred_ = true;
default_index_ = preferred_form_index;
- combobox->SetSelectedIndex(preferred_form_index);
+ combobox_->SetSelectedIndex(preferred_form_index);
}
- return combobox;
}
void CredentialsSelectionView::ReportUserActionOnce(bool was_update_rejected,
« no previous file with comments | « chrome/browser/ui/views/passwords/credentials_selection_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698