diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-30 00:33:10 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-30 00:33:10 +0000 |
commit | 8d4cc15e95bdce1ec41b68c2b1cc5685642c39e0 (patch) | |
tree | 0e00e143095ae775ee1ba1cc886c9142ae06f82f /chrome/browser/ui | |
parent | c1a47df6521776547b5a3a9966dba63aab9e2e6b (diff) | |
download | chromium_src-8d4cc15e95bdce1ec41b68c2b1cc5685642c39e0.zip chromium_src-8d4cc15e95bdce1ec41b68c2b1cc5685642c39e0.tar.gz chromium_src-8d4cc15e95bdce1ec41b68c2b1cc5685642c39e0.tar.bz2 |
Introduce AutofillClient and use it to get rid of PasswordManager dependency.
Also, this switches use of InfoBarTabService and PrefServiceBase in
AutofillManager from calling their ::ForXyz methods, to retrieving
them via AutofillClient.
BUG=140037
Review URL: https://chromiumcodereview.appspot.com/10837363
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r-- | chrome/browser/ui/autofill/OWNERS | 5 | ||||
-rw-r--r-- | chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc | 29 | ||||
-rw-r--r-- | chrome/browser/ui/autofill/tab_autofill_manager_delegate.h | 28 | ||||
-rw-r--r-- | chrome/browser/ui/tab_contents/tab_contents.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/tab_contents/tab_contents.h | 2 |
5 files changed, 67 insertions, 1 deletions
diff --git a/chrome/browser/ui/autofill/OWNERS b/chrome/browser/ui/autofill/OWNERS new file mode 100644 index 0000000..1957692 --- /dev/null +++ b/chrome/browser/ui/autofill/OWNERS @@ -0,0 +1,5 @@ +dhollowa@chromium.org +isherman@chromium.org + +# Temporary owner, for refactoring changes only. +joi@chromium.org diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc new file mode 100644 index 0000000..7dbbf86 --- /dev/null +++ b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc @@ -0,0 +1,29 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" + +#include "base/logging.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/password_manager/password_manager.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/tab_contents/tab_contents.h" + +TabAutofillManagerDelegate::TabAutofillManagerDelegate(TabContents* tab) + : tab_(tab) { + DCHECK(tab_); +} + +InfoBarTabService* TabAutofillManagerDelegate::GetInfoBarService() { + return tab_->infobar_tab_helper(); +} + +PrefServiceBase* TabAutofillManagerDelegate::GetPrefs() { + return tab_->profile()->GetPrefs(); +} + +bool TabAutofillManagerDelegate::IsSavingPasswordsEnabled() const { + return tab_->password_manager()->IsSavingEnabled(); +} diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h new file mode 100644 index 0000000..5769c5d6 --- /dev/null +++ b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h @@ -0,0 +1,28 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_AUTOFILL_TAB_AUTOFILL_MANAGER_DELEGATE_H_ +#define CHROME_BROWSER_UI_AUTOFILL_TAB_AUTOFILL_MANAGER_DELEGATE_H_ + +#include "base/compiler_specific.h" +#include "chrome/browser/autofill/api/autofill_manager_delegate.h" + +class TabContents; + +// Chrome implementation of AutofillManagerDelegate. +class TabAutofillManagerDelegate : public autofill::AutofillManagerDelegate { + public: + // Lifetime of |tab| must exceed lifetime of TabAutofillManagerDelegate. + explicit TabAutofillManagerDelegate(TabContents* tab); + virtual ~TabAutofillManagerDelegate() {} + + virtual InfoBarTabService* GetInfoBarService() OVERRIDE; + virtual PrefServiceBase* GetPrefs() OVERRIDE; + virtual bool IsSavingPasswordsEnabled() const OVERRIDE; + + private: + TabContents* const tab_; +}; + +#endif // CHROME_BROWSER_UI_AUTOFILL_TAB_AUTOFILL_MANAGER_DELEGATE_H_ diff --git a/chrome/browser/ui/tab_contents/tab_contents.cc b/chrome/browser/ui/tab_contents/tab_contents.cc index 09b4965..1396484 100644 --- a/chrome/browser/ui/tab_contents/tab_contents.cc +++ b/chrome/browser/ui/tab_contents/tab_contents.cc @@ -35,6 +35,7 @@ #include "chrome/browser/tab_contents/thumbnail_generator.h" #include "chrome/browser/translate/translate_tab_helper.h" #include "chrome/browser/ui/alternate_error_tab_observer.h" +#include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" #include "chrome/browser/ui/constrained_window_tab_helper.h" @@ -111,7 +112,8 @@ TabContents::TabContents(WebContents* contents) restore_tab_helper_.reset(new RestoreTabHelper(contents)); autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); - autofill_manager_ = new AutofillManager(this); + autofill_delegate_.reset(new TabAutofillManagerDelegate(this)); + autofill_manager_ = new AutofillManager(autofill_delegate_.get(), this); if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kExternalAutofillPopup)) { autofill_external_delegate_.reset( diff --git a/chrome/browser/ui/tab_contents/tab_contents.h b/chrome/browser/ui/tab_contents/tab_contents.h index cd27fc5..05b8494 100644 --- a/chrome/browser/ui/tab_contents/tab_contents.h +++ b/chrome/browser/ui/tab_contents/tab_contents.h @@ -56,6 +56,7 @@ class SadTabHelper; class SearchEngineTabHelper; class ShellWindow; class SnapshotTabHelper; +class TabAutofillManagerDelegate; class TabContentsSSLHelper; class TabContentsTestHarness; class TabSpecificContentSettings; @@ -347,6 +348,7 @@ class TabContents : public content::WebContentsObserver { scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; scoped_refptr<AutofillManager> autofill_manager_; + scoped_ptr<TabAutofillManagerDelegate> autofill_delegate_; scoped_ptr<AutofillExternalDelegate> autofill_external_delegate_; scoped_ptr<AutomationTabHelper> automation_tab_helper_; scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_; |