diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 17:24:18 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 17:24:18 +0000 |
commit | a6a7ced56b518de42dab6d3ac18de490fb494696 (patch) | |
tree | b89d63fe26927a79e9d6d07519fa1983a5466f5a /chrome/browser/autofill | |
parent | 38d455b3bc1ab2a7b9efc58d78c7ba9ec5067001 (diff) | |
download | chromium_src-a6a7ced56b518de42dab6d3ac18de490fb494696.zip chromium_src-a6a7ced56b518de42dab6d3ac18de490fb494696.tar.gz chromium_src-a6a7ced56b518de42dab6d3ac18de490fb494696.tar.bz2 |
Remove content::NotificationObserver dependency from most Prefs code.
Instead of using content::NotificationObserver, introduce specific
type-safe observer classes and update users to use them. In a very
large number of cases this was the users' only reason for being a
content::NotificationObserver and they would have a lot of
boiler-plate code such as a DCHECK on the notification type and
unpacking of the generic NotificationDetails types, so this change
removes a bunch of boilerplate and introduces more type safety.
This is part of enabling more of the Prefs code to live in
base/prefs/.
TBR=ben@chromium.org,brettw@chromium.org
BUG=155525
Review URL: https://chromiumcodereview.appspot.com/11345008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165414 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 10 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.h | 13 |
2 files changed, 9 insertions, 14 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index f9dfd82..132d4ce 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -290,14 +290,10 @@ void AutofillManager::RenderViewCreated(content::RenderViewHost* host) { UpdatePasswordGenerationState(host, true); } -void AutofillManager::Observe( - int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { +void AutofillManager::OnPreferenceChanged(PrefServiceBase* service, + const std::string& pref_name) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); - std::string* pref = content::Details<std::string>(details).ptr(); - DCHECK(prefs::kPasswordGenerationEnabled == *pref); + DCHECK(prefs::kPasswordGenerationEnabled == pref_name); UpdatePasswordGenerationState(web_contents()->GetRenderViewHost(), false); } diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h index 4be3a4f5..af42fbe 100644 --- a/chrome/browser/autofill/autofill_manager.h +++ b/chrome/browser/autofill/autofill_manager.h @@ -18,6 +18,7 @@ #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" #include "base/prefs/public/pref_change_registrar.h" +#include "base/prefs/public/pref_observer.h" #include "base/string16.h" #include "base/time.h" #include "chrome/browser/api/sync/profile_sync_service_observer.h" @@ -25,7 +26,6 @@ #include "chrome/browser/autofill/autofill_download.h" #include "chrome/browser/autofill/field_types.h" #include "chrome/browser/autofill/form_structure.h" -#include "content/public/browser/notification_observer.h" #include "content/public/browser/web_contents_observer.h" class AutofillExternalDelegate; @@ -64,10 +64,10 @@ class Message; // Manages saving and restoring the user's personal information entered into web // forms. -class AutofillManager : public content::NotificationObserver, - public content::WebContentsObserver, +class AutofillManager : public content::WebContentsObserver, public AutofillDownloadManager::Observer, public ProfileSyncServiceObserver, + public PrefObserver, public base::RefCounted<AutofillManager> { public: static void CreateForWebContentsAndDelegate( @@ -191,10 +191,9 @@ class AutofillManager : public content::NotificationObserver, // Register as an observer with the sync service. void RegisterWithSyncService(); - // content::NotificationObserver override - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; + // PrefObserver. + virtual void OnPreferenceChanged(PrefServiceBase* service, + const std::string& pref_name) OVERRIDE; // Determines what the current state of password generation is, and if it has // changed from |password_generation_enabled_|. If it has changed or if |