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

Unified Diff: chrome/browser/ui/passwords/manage_passwords_bubble_model.cc

Issue 228603003: Password bubble: Move WebContents completely into the UI controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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/ui/passwords/manage_passwords_bubble_model.cc
diff --git a/chrome/browser/ui/passwords/manage_passwords_bubble_model.cc b/chrome/browser/ui/passwords/manage_passwords_bubble_model.cc
index 274eb50b52c36b33ae0409c6829d7ed59bca7c33..afb23ff8c512d71a49f5f1aebe4e977edd33b048 100644
--- a/chrome/browser/ui/passwords/manage_passwords_bubble_model.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_bubble_model.cc
@@ -5,29 +5,18 @@
#include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
#include "chrome/browser/password_manager/password_store_factory.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/chrome_pages.h"
-#include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h"
-#include "chrome/common/url_constants.h"
+#include "chrome/browser/profiles/profile.h"
#include "components/password_manager/core/browser/password_store.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
-using content::WebContents;
using autofill::PasswordFormMap;
ManagePasswordsBubbleModel::ManagePasswordsBubbleModel(
- content::WebContents* web_contents)
- : content::WebContentsObserver(web_contents),
- web_contents_(web_contents) {
- ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller =
- ManagePasswordsBubbleUIController::FromWebContents(web_contents_);
-
- password_submitted_ =
- manage_passwords_bubble_ui_controller->password_submitted();
- if (password_submitted_) {
- if (manage_passwords_bubble_ui_controller->password_to_be_saved())
+ ManagePasswordsBubbleUIController* ui_controller)
+ : ui_controller_(ui_controller) {
+ if (password_submitted()) {
+ if (ui_controller_->password_to_be_saved())
manage_passwords_bubble_state_ = PASSWORD_TO_BE_SAVED;
else
manage_passwords_bubble_state_ = MANAGE_PASSWORDS_AFTER_SAVING;
@@ -39,10 +28,9 @@ ManagePasswordsBubbleModel::ManagePasswordsBubbleModel(
(manage_passwords_bubble_state_ == PASSWORD_TO_BE_SAVED) ?
IDS_SAVE_PASSWORD : IDS_MANAGE_PASSWORDS);
if (password_submitted_) {
- pending_credentials_ =
- manage_passwords_bubble_ui_controller->pending_credentials();
+ pending_credentials_ = ui_controller_->pending_credentials();
}
- best_matches_ = manage_passwords_bubble_ui_controller->best_matches();
+ best_matches_ = ui_controller_->best_matches();
manage_link_ =
l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK);
}
@@ -54,33 +42,25 @@ void ManagePasswordsBubbleModel::OnNopeClicked() {
}
void ManagePasswordsBubbleModel::OnNeverForThisSiteClicked() {
- ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller =
- ManagePasswordsBubbleUIController::FromWebContents(web_contents_);
- manage_passwords_bubble_ui_controller->NeverSavePassword();
- manage_passwords_bubble_ui_controller->unset_password_to_be_saved();
+ ui_controller_->NeverSavePassword();
+ ui_controller_->unset_password_to_be_saved();
manage_passwords_bubble_state_ = NEVER_SAVE_PASSWORDS;
}
void ManagePasswordsBubbleModel::OnSaveClicked() {
- ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller =
- ManagePasswordsBubbleUIController::FromWebContents(web_contents_);
- manage_passwords_bubble_ui_controller->SavePassword();
- manage_passwords_bubble_ui_controller->unset_password_to_be_saved();
+ ui_controller_->SavePassword();
+ ui_controller_->unset_password_to_be_saved();
manage_passwords_bubble_state_ = MANAGE_PASSWORDS_AFTER_SAVING;
}
void ManagePasswordsBubbleModel::OnManageLinkClicked() {
- chrome::ShowSettingsSubPage(chrome::FindBrowserWithWebContents(web_contents_),
- chrome::kPasswordManagerSubPage);
+ ui_controller_->NavigateToPasswordManagerSettingsPage();
}
void ManagePasswordsBubbleModel::OnPasswordAction(
const autofill::PasswordForm& password_form,
PasswordAction action) {
- if (!web_contents_)
- return;
- Profile* profile =
- Profile::FromBrowserContext(web_contents_->GetBrowserContext());
+ Profile* profile = ui_controller_->profile();
PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
profile, Profile::EXPLICIT_ACCESS).get();
DCHECK(password_store);
@@ -91,19 +71,11 @@ void ManagePasswordsBubbleModel::OnPasswordAction(
// This is necessary in case the bubble is instantiated again, we thus do not
// display the pending credentials if they were deleted.
if (password_form.username_value == pending_credentials_.username_value) {
- ManagePasswordsBubbleUIController::FromWebContents(web_contents_)
- ->set_password_submitted(action == ADD_PASSWORD);
+ ui_controller_->set_password_submitted(action == ADD_PASSWORD);
}
}
void ManagePasswordsBubbleModel::DeleteFromBestMatches(
autofill::PasswordForm password_form) {
- ManagePasswordsBubbleUIController::FromWebContents(web_contents_)->
- RemoveFromBestMatches(password_form);
-}
-
-void ManagePasswordsBubbleModel::WebContentsDestroyed(
- content::WebContents* web_contents) {
- // The WebContents have been destroyed.
- web_contents_ = NULL;
+ ui_controller_->RemoveFromBestMatches(password_form);
}

Powered by Google App Engine
This is Rietveld 408576698