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

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

Issue 87853004: Refactoring Manage Passwords Bubble Code to exclude TabSpecificContentSettings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@movingclasses
Patch Set: adding controller files Created 7 years, 1 month 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 f67a172b4ca4d94f5990a1a07d440e6822c5c084..9e2775afd1deeff96d8c5f43929630ae5d21f3aa 100644
--- a/chrome/browser/ui/passwords/manage_passwords_bubble_model.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_bubble_model.cc
@@ -9,6 +9,7 @@
#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_controller.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -17,15 +18,15 @@ using content::WebContents;
using autofill::PasswordFormMap;
ManagePasswordsBubbleModel::ManagePasswordsBubbleModel(
- WebContents* web_contents)
+ content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
web_contents_(web_contents) {
- TabSpecificContentSettings* content_settings =
- TabSpecificContentSettings::FromWebContents(web_contents);
+ ManagePasswordsController* manage_passwords_controller =
+ ManagePasswordsController::FromWebContents(web_contents_);
- password_submitted_ = content_settings->password_submitted();
+ password_submitted_ = manage_passwords_controller->password_submitted();
if (password_submitted_) {
- if (content_settings->password_to_be_saved())
+ if (manage_passwords_controller->password_to_be_saved())
manage_passwords_bubble_state_ = PASSWORD_TO_BE_SAVED;
else
manage_passwords_bubble_state_ = MANAGE_PASSWORDS_AFTER_SAVING;
@@ -36,9 +37,10 @@ ManagePasswordsBubbleModel::ManagePasswordsBubbleModel(
title_ = l10n_util::GetStringUTF16(
(manage_passwords_bubble_state_ == PASSWORD_TO_BE_SAVED) ?
IDS_SAVE_PASSWORD : IDS_MANAGE_PASSWORDS);
- if (password_submitted_)
- pending_credentials_ = content_settings->pending_credentials();
- best_matches_ = content_settings->best_matches();
+ if (password_submitted_) {
markusheintz_ 2013/11/26 12:44:37 nit: no need to add the {. Please remove for the s
npentrel 2013/11/26 14:25:55 Done.
+ pending_credentials_ = manage_passwords_controller->pending_credentials();
+ }
+ best_matches_ = manage_passwords_controller->best_matches();
manage_link_ =
l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK);
}
@@ -50,10 +52,10 @@ void ManagePasswordsBubbleModel::OnCancelClicked() {
}
void ManagePasswordsBubbleModel::OnSaveClicked() {
- TabSpecificContentSettings* content_settings =
- TabSpecificContentSettings::FromWebContents(web_contents_);
- content_settings->SavePassword();
- content_settings->unset_password_to_be_saved();
+ ManagePasswordsController* manage_passwords_controller =
+ ManagePasswordsController::FromWebContents(web_contents_);
+ manage_passwords_controller->SavePassword();
+ manage_passwords_controller->unset_password_to_be_saved();
manage_passwords_bubble_state_ = MANAGE_PASSWORDS_AFTER_SAVING;
}
@@ -62,8 +64,9 @@ void ManagePasswordsBubbleModel::OnManageLinkClicked() {
chrome::kPasswordManagerSubPage);
}
-void ManagePasswordsBubbleModel::PasswordAction(
- autofill::PasswordForm password_form, bool remove) {
+void ManagePasswordsBubbleModel::AddOrRemovePassword(
+ autofill::PasswordForm password_form,
+ bool remove) {
if (!web_contents_)
return;
Profile* profile =
@@ -78,17 +81,15 @@ void ManagePasswordsBubbleModel::PasswordAction(
// 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) {
- TabSpecificContentSettings* content_settings =
- TabSpecificContentSettings::FromWebContents(web_contents_);
- content_settings->password_submitted(!remove);
+ ManagePasswordsController::FromWebContents(web_contents_)->
+ set_password_submitted(!remove);
}
}
void ManagePasswordsBubbleModel::DeleteFromBestMatches(
autofill::PasswordForm password_form) {
- TabSpecificContentSettings* content_settings =
- TabSpecificContentSettings::FromWebContents(web_contents_);
- content_settings->remove_from_best_matches(password_form);
+ ManagePasswordsController::FromWebContents(web_contents_)->
+ RemoveFromBestMatches(password_form);
}
void ManagePasswordsBubbleModel::WebContentsDestroyed(

Powered by Google App Engine
This is Rietveld 408576698