summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/autofill_manager_unittest.cc
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-19 22:40:55 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-19 22:40:55 +0000
commiteb70011eee4c7190e09bb1c89bdbea4132b3419b (patch)
tree2cd638e2dec4abebdc0f23ff1c8d6d1ef30358c9 /chrome/browser/autofill/autofill_manager_unittest.cc
parentdccb900d7022e5b5b093e13a7da6567b1f00f3a0 (diff)
downloadchromium_src-eb70011eee4c7190e09bb1c89bdbea4132b3419b.zip
chromium_src-eb70011eee4c7190e09bb1c89bdbea4132b3419b.tar.gz
chromium_src-eb70011eee4c7190e09bb1c89bdbea4132b3419b.tar.bz2
sync: don't inherit SupportsWeakPtr from ProfileSyncService
AutofillManager was the last use of this. This patch makes AutofillManager look up the sync service directly instead of caching a pointer to it. Note that AutofillManager is ref counted and can outlive ProfileSyncService. Since AutofillManager now asks ProfileSyncServiceFactory for a ProfileSyncService reference per-use, it may return null if the profile is in incognito. UpdatePassphraseGenerationState didn't run into this before and a null profile sync service meant something different -- updated that code accordingly. I also made AutofillManager listen for TAB_CONTENTS_DESTROYED. I'm not sure if this was a bug in the wild (although A.M is ref counted, so maybe), but the TestTabContents infrastructure creates a scenario during SetUp where multiple AutofillManagers get created, and creating the second instance resets the TabContents that was used for the first instance. This makes certain methods on A.M instance 1's tab_contents_ pointer dangerous to call from ~AutofillManager, because parts of the owning TabContents have been destroyed by the time we get to ~AutofillManager. The remaining use of WeakPtr was the FrontendDataTypeController, and I removed that use in http://src.chromium.org/viewvc/chrome?view=rev&revision=142836 BUG=100829 TEST=AutofillManagerTest Review URL: https://chromiumcodereview.appspot.com/10584017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143069 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/autofill_manager_unittest.cc')
-rw-r--r--chrome/browser/autofill/autofill_manager_unittest.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index ef34fdf..eb1c3e4 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tab_contents/test_tab_contents.h"
@@ -703,10 +704,6 @@ class AutofillManagerTest : public TabContentsTestHarness {
return true;
}
- ProfileSyncService* GetProfileSyncService() {
- return autofill_manager_->sync_service_;
- }
-
protected:
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
@@ -2930,7 +2927,8 @@ TEST_F(AutofillManagerTest, UpdatePasswordSyncState) {
// Sync some things, but not passwords. Shouldn't send anything since
// password generation is disabled by default.
- ProfileSyncService* sync_service = GetProfileSyncService();
+ ProfileSyncService* sync_service = ProfileSyncServiceFactory::GetForProfile(
+ profile());
sync_service->SetSyncSetupCompleted();
syncable::ModelTypeSet preferred_set;
preferred_set.Put(syncable::EXTENSIONS);
@@ -2980,7 +2978,8 @@ TEST_F(AutofillManagerTest, UpdatePasswordGenerationState) {
// Always set password sync enabled so we can test the behavior of password
// generation.
profile()->GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false);
- ProfileSyncService* sync_service = GetProfileSyncService();
+ ProfileSyncService* sync_service = ProfileSyncServiceFactory::GetForProfile(
+ profile());
sync_service->SetSyncSetupCompleted();
syncable::ModelTypeSet preferred_set;
preferred_set.Put(syncable::PASSWORDS);