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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_bubble_model.cc

Issue 257153003: We have a problem in the process on destroying WebContentsImpl because (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Rebased onto origin/master again, resolved conflicts Created 6 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 "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
6 6
7 #include "chrome/browser/password_manager/password_store_factory.h" 7 #include "chrome/browser/password_manager/password_store_factory.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h" 9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 10 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
11 #include "components/password_manager/core/browser/password_store.h" 11 #include "components/password_manager/core/browser/password_store.h"
12 #include "components/password_manager/core/common/password_manager_ui.h" 12 #include "components/password_manager/core/common/password_manager_ui.h"
13 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 15
16 using autofill::PasswordFormMap; 16 using autofill::PasswordFormMap;
17 using content::WebContents; 17 using content::WebContents;
18 18
19 ManagePasswordsBubbleModel::ManagePasswordsBubbleModel( 19 ManagePasswordsBubbleModel::ManagePasswordsBubbleModel(
20 content::WebContents* web_contents) 20 content::WebContents* web_contents)
21 : content::WebContentsObserver(web_contents), 21 : content::WebContentsObserver(web_contents),
22 web_contents_(web_contents),
23 display_disposition_( 22 display_disposition_(
24 password_manager::metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING), 23 password_manager::metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING),
25 dismissal_reason_(password_manager::metrics_util::NOT_DISPLAYED) { 24 dismissal_reason_(password_manager::metrics_util::NOT_DISPLAYED) {
26 ManagePasswordsUIController* controller = 25 ManagePasswordsUIController* controller =
27 ManagePasswordsUIController::FromWebContents(web_contents_); 26 ManagePasswordsUIController::FromWebContents(web_contents);
28 27
29 // TODO(mkwst): Reverse this logic. The controller should populate the model 28 // TODO(mkwst): Reverse this logic. The controller should populate the model
30 // directly rather than the model pulling from the controller. Perhaps like 29 // directly rather than the model pulling from the controller. Perhaps like
31 // `controller->PopulateModel(this)`. 30 // `controller->PopulateModel(this)`.
32 state_ = controller->state(); 31 state_ = controller->state();
33 if (password_manager::ui::IsPendingState(state_)) 32 if (password_manager::ui::IsPendingState(state_))
34 pending_credentials_ = controller->PendingCredentials(); 33 pending_credentials_ = controller->PendingCredentials();
35 best_matches_ = controller->best_matches(); 34 best_matches_ = controller->best_matches();
36 35
37 title_ = l10n_util::GetStringUTF16( 36 title_ = l10n_util::GetStringUTF16(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 75 }
77 76
78 void ManagePasswordsBubbleModel::OnNopeClicked() { 77 void ManagePasswordsBubbleModel::OnNopeClicked() {
79 dismissal_reason_ = password_manager::metrics_util::CLICKED_NOPE; 78 dismissal_reason_ = password_manager::metrics_util::CLICKED_NOPE;
80 state_ = password_manager::ui::PENDING_PASSWORD_STATE; 79 state_ = password_manager::ui::PENDING_PASSWORD_STATE;
81 } 80 }
82 81
83 void ManagePasswordsBubbleModel::OnNeverForThisSiteClicked() { 82 void ManagePasswordsBubbleModel::OnNeverForThisSiteClicked() {
84 dismissal_reason_ = password_manager::metrics_util::CLICKED_NEVER; 83 dismissal_reason_ = password_manager::metrics_util::CLICKED_NEVER;
85 ManagePasswordsUIController* manage_passwords_ui_controller = 84 ManagePasswordsUIController* manage_passwords_ui_controller =
86 ManagePasswordsUIController::FromWebContents(web_contents_); 85 ManagePasswordsUIController::FromWebContents(web_contents());
87 manage_passwords_ui_controller->NeverSavePassword(); 86 manage_passwords_ui_controller->NeverSavePassword();
88 state_ = password_manager::ui::BLACKLIST_STATE; 87 state_ = password_manager::ui::BLACKLIST_STATE;
89 } 88 }
90 89
91 void ManagePasswordsBubbleModel::OnUnblacklistClicked() { 90 void ManagePasswordsBubbleModel::OnUnblacklistClicked() {
92 dismissal_reason_ = password_manager::metrics_util::CLICKED_UNBLACKLIST; 91 dismissal_reason_ = password_manager::metrics_util::CLICKED_UNBLACKLIST;
93 ManagePasswordsUIController* manage_passwords_ui_controller = 92 ManagePasswordsUIController* manage_passwords_ui_controller =
94 ManagePasswordsUIController::FromWebContents(web_contents_); 93 ManagePasswordsUIController::FromWebContents(web_contents());
95 manage_passwords_ui_controller->UnblacklistSite(); 94 manage_passwords_ui_controller->UnblacklistSite();
96 state_ = password_manager::ui::MANAGE_STATE; 95 state_ = password_manager::ui::MANAGE_STATE;
97 } 96 }
98 97
99 void ManagePasswordsBubbleModel::OnSaveClicked() { 98 void ManagePasswordsBubbleModel::OnSaveClicked() {
100 dismissal_reason_ = password_manager::metrics_util::CLICKED_SAVE; 99 dismissal_reason_ = password_manager::metrics_util::CLICKED_SAVE;
101 ManagePasswordsUIController* manage_passwords_ui_controller = 100 ManagePasswordsUIController* manage_passwords_ui_controller =
102 ManagePasswordsUIController::FromWebContents(web_contents_); 101 ManagePasswordsUIController::FromWebContents(web_contents());
103 manage_passwords_ui_controller->SavePassword(); 102 manage_passwords_ui_controller->SavePassword();
104 state_ = password_manager::ui::MANAGE_STATE; 103 state_ = password_manager::ui::MANAGE_STATE;
105 } 104 }
106 105
107 void ManagePasswordsBubbleModel::OnDoneClicked() { 106 void ManagePasswordsBubbleModel::OnDoneClicked() {
108 dismissal_reason_ = password_manager::metrics_util::CLICKED_DONE; 107 dismissal_reason_ = password_manager::metrics_util::CLICKED_DONE;
109 } 108 }
110 109
111 void ManagePasswordsBubbleModel::OnManageLinkClicked() { 110 void ManagePasswordsBubbleModel::OnManageLinkClicked() {
112 dismissal_reason_ = password_manager::metrics_util::CLICKED_MANAGE; 111 dismissal_reason_ = password_manager::metrics_util::CLICKED_MANAGE;
113 ManagePasswordsUIController::FromWebContents(web_contents_) 112 ManagePasswordsUIController::FromWebContents(web_contents())
114 ->NavigateToPasswordManagerSettingsPage(); 113 ->NavigateToPasswordManagerSettingsPage();
115 } 114 }
116 115
117 void ManagePasswordsBubbleModel::OnPasswordAction( 116 void ManagePasswordsBubbleModel::OnPasswordAction(
118 const autofill::PasswordForm& password_form, 117 const autofill::PasswordForm& password_form,
119 PasswordAction action) { 118 PasswordAction action) {
120 if (!web_contents_) 119 if (!web_contents())
121 return; 120 return;
122 Profile* profile = 121 Profile* profile =
123 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); 122 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
124 password_manager::PasswordStore* password_store = 123 password_manager::PasswordStore* password_store =
125 PasswordStoreFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS) 124 PasswordStoreFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS)
126 .get(); 125 .get();
127 DCHECK(password_store); 126 DCHECK(password_store);
128 if (action == REMOVE_PASSWORD) 127 if (action == REMOVE_PASSWORD)
129 password_store->RemoveLogin(password_form); 128 password_store->RemoveLogin(password_form);
130 else 129 else
131 password_store->AddLogin(password_form); 130 password_store->AddLogin(password_form);
132 } 131 }
133
134 void ManagePasswordsBubbleModel::WebContentsDestroyed(
135 content::WebContents* web_contents) {
136 // The WebContents have been destroyed.
137 web_contents_ = NULL;
138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698