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

Unified Diff: chrome/browser/autofill/autofill_manager.cc

Issue 10837363: Introduce AutofillClient and use it to get rid of PasswordManager dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix header Created 8 years, 4 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/autofill/autofill_manager.h ('k') | chrome/browser/autofill/autofill_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_manager.cc
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index c8b5b5039e4792670c931ead003f85160df230dc..8a28c0caac3f6d5e9b39a9b64cffe0f2a7200a99 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -20,6 +20,7 @@
#include "base/threading/sequenced_worker_pool.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/api/infobars/infobar_tab_service.h"
+#include "chrome/browser/autofill/api/autofill_manager_delegate.h"
#include "chrome/browser/autofill/autocomplete_history_manager.h"
#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
#include "chrome/browser/autofill/autofill_external_delegate.h"
@@ -36,7 +37,6 @@
#include "chrome/browser/autofill/phone_number.h"
#include "chrome/browser/autofill/phone_number_i18n.h"
#include "chrome/browser/autofill/select_control_handler.h"
-#include "chrome/browser/password_manager/password_manager.h"
#include "chrome/browser/api/prefs/pref_service_base.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
@@ -178,8 +178,10 @@ void DeterminePossibleFieldTypesForUpload(
} // namespace
-AutofillManager::AutofillManager(TabContents* tab_contents)
+AutofillManager::AutofillManager(autofill::AutofillManagerDelegate* delegate,
+ TabContents* tab_contents)
: content::WebContentsObserver(tab_contents->web_contents()),
+ manager_delegate_(delegate),
tab_contents_(tab_contents),
personal_data_(NULL),
download_manager_(tab_contents->profile(), this),
@@ -197,7 +199,7 @@ AutofillManager::AutofillManager(TabContents* tab_contents)
personal_data_ = PersonalDataManagerFactory::GetForProfile(
tab_contents->profile()->GetOriginalProfile());
RegisterWithSyncService();
- registrar_.Init(PrefServiceBase::ForProfile(tab_contents->profile()));
+ registrar_.Init(manager_delegate_->GetPrefs());
registrar_.Add(prefs::kPasswordGenerationEnabled, this);
notification_registrar_.Add(this,
chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED,
@@ -262,17 +264,13 @@ void AutofillManager::UpdatePasswordGenerationState(
service->HasSyncSetupCompleted() && sync_set.Has(syncer::PASSWORDS);
}
- bool password_manager_enabled =
- tab_contents_->password_manager()->IsSavingEnabled();
-
- Profile* profile = Profile::FromBrowserContext(
- web_contents()->GetBrowserContext());
- bool preference_checked = PrefServiceBase::ForProfile(profile)->GetBoolean(
+ bool saving_passwords_enabled = manager_delegate_->IsSavingPasswordsEnabled();
+ bool preference_checked = manager_delegate_->GetPrefs()->GetBoolean(
prefs::kPasswordGenerationEnabled);
bool new_password_generation_enabled =
password_sync_enabled &&
- password_manager_enabled &&
+ saving_passwords_enabled &&
preference_checked;
if (new_password_generation_enabled != password_generation_enabled_ ||
@@ -813,10 +811,7 @@ void AutofillManager::OnDidEndTextFieldEditing() {
}
bool AutofillManager::IsAutofillEnabled() const {
- Profile* profile = Profile::FromBrowserContext(
- const_cast<AutofillManager*>(this)->web_contents()->GetBrowserContext());
- return PrefServiceBase::ForProfile(profile)->GetBoolean(
- prefs::kAutofillEnabled);
+ return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled);
}
void AutofillManager::SendAutofillTypePredictions(
@@ -845,8 +840,7 @@ void AutofillManager::ImportFormData(const FormStructure& submitted_form) {
// it.
scoped_ptr<const CreditCard> scoped_credit_card(imported_credit_card);
if (imported_credit_card && web_contents()) {
- InfoBarTabService* infobar_service =
- InfoBarTabService::ForTab(tab_contents_);
+ InfoBarTabService* infobar_service = manager_delegate_->GetInfoBarService();
infobar_service->AddInfoBar(
new AutofillCCInfoBarDelegate(infobar_service,
scoped_credit_card.release(),
@@ -910,9 +904,11 @@ void AutofillManager::Reset() {
external_delegate_->Reset();
}
-AutofillManager::AutofillManager(TabContents* tab_contents,
+AutofillManager::AutofillManager(autofill::AutofillManagerDelegate* delegate,
+ TabContents* tab_contents,
PersonalDataManager* personal_data)
: content::WebContentsObserver(tab_contents->web_contents()),
+ manager_delegate_(delegate),
tab_contents_(tab_contents),
personal_data_(personal_data),
download_manager_(tab_contents->profile(), this),
@@ -926,7 +922,8 @@ AutofillManager::AutofillManager(TabContents* tab_contents,
user_did_edit_autofilled_field_(false),
password_generation_enabled_(false),
external_delegate_(NULL) {
- DCHECK(tab_contents);
+ DCHECK(tab_contents_);
+ DCHECK(manager_delegate_);
RegisterWithSyncService();
// Test code doesn't need registrar_.
}
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698