summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 01:58:27 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 01:58:27 +0000
commitd4ccda53c97d25057d8e5c8aebca4e6151037e8e (patch)
treeb8e79a9a41f95bba1c6f78ae362f39b383e16f1d
parent3f82d02e93797f3689e31cd67952840588409cdf (diff)
downloadchromium_src-d4ccda53c97d25057d8e5c8aebca4e6151037e8e.zip
chromium_src-d4ccda53c97d25057d8e5c8aebca4e6151037e8e.tar.gz
chromium_src-d4ccda53c97d25057d8e5c8aebca4e6151037e8e.tar.bz2
Convert final GetProfileSyncService callers to use profile keyed factory.
TBR=jcivelli@chromium.org TBR=jhawkins@chromium.org TBR=asargent@chromium.org BUG=93922 Review URL: http://codereview.chromium.org/9293020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120903 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/app_notify_channel_ui.cc3
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.cc10
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.h2
-rw-r--r--chrome/browser/profiles/profile.h9
-rw-r--r--chrome/browser/profiles/profile_impl.cc11
-rw-r--r--chrome/browser/profiles/profile_impl.h3
-rw-r--r--chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc2
-rw-r--r--chrome/browser/sync/glue/new_non_frontend_data_type_controller_unittest.cc2
-rw-r--r--chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service_autofill_unittest.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service_harness.cc13
-rw-r--r--chrome/browser/sync/profile_sync_service_password_unittest.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service_typed_url_unittest.cc2
-rw-r--r--chrome/browser/sync/sync_setup_flow.cc4
-rw-r--r--chrome/browser/sync/sync_ui_util.cc4
-rw-r--r--chrome/browser/sync/sync_ui_util_mac.mm7
-rw-r--r--chrome/browser/sync/test/integration/passwords_helper.cc5
-rw-r--r--chrome/browser/sync/test/integration/sessions_helper.cc21
-rw-r--r--chrome/browser/ui/webui/sessions_ui.cc6
-rw-r--r--chrome/browser/ui/webui/sync_internals_ui.cc6
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc4
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc4
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc4
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler.cc14
-rw-r--r--chrome/test/base/profile_mock.h3
-rw-r--r--chrome/test/base/testing_profile.cc15
-rw-r--r--chrome/test/base/testing_profile.h3
27 files changed, 68 insertions, 95 deletions
diff --git a/chrome/browser/extensions/app_notify_channel_ui.cc b/chrome/browser/extensions/app_notify_channel_ui.cc
index 2885266..5732945 100644
--- a/chrome/browser/extensions/app_notify_channel_ui.cc
+++ b/chrome/browser/extensions/app_notify_channel_ui.cc
@@ -102,7 +102,8 @@ void AppNotifyChannelUIImpl::PromptSyncSetup(
CHECK(delegate_ == NULL);
delegate_ = delegate;
- if (!browser_->profile()->HasProfileSyncService()) {
+ if (!ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(
+ browser_->profile()->GetOriginalProfile())) {
delegate_->OnSyncSetupResult(false);
return;
}
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc
index 8231089..09c63f1 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -32,7 +32,6 @@
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
-#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/transport_security_persister.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
@@ -415,11 +414,6 @@ UserStyleSheetWatcher* OffTheRecordProfileImpl::GetUserStyleSheetWatcher() {
return profile_->GetUserStyleSheetWatcher();
}
-bool OffTheRecordProfileImpl::HasProfileSyncService() {
- // We never have a profile sync service.
- return false;
-}
-
bool OffTheRecordProfileImpl::DidLastSessionExitCleanly() {
return profile_->DidLastSessionExitCleanly();
}
@@ -436,10 +430,6 @@ TokenService* OffTheRecordProfileImpl::GetTokenService() {
return NULL;
}
-ProfileSyncService* OffTheRecordProfileImpl::GetProfileSyncService() {
- return NULL;
-}
-
bool OffTheRecordProfileImpl::IsSameProfile(Profile* profile) {
return (profile == this) || (profile == profile_);
}
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h
index 1c04c62..a6bb732 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.h
+++ b/chrome/browser/profiles/off_the_record_profile_impl.h
@@ -84,12 +84,10 @@ class OffTheRecordProfileImpl : public Profile,
GetGeolocationPermissionContext() OVERRIDE;
virtual SpeechInputPreferences* GetSpeechInputPreferences() OVERRIDE;
virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() OVERRIDE;
- virtual bool HasProfileSyncService() OVERRIDE;
virtual bool DidLastSessionExitCleanly() OVERRIDE;
virtual BookmarkModel* GetBookmarkModel() OVERRIDE;
virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() OVERRIDE;
virtual TokenService* GetTokenService() OVERRIDE;
- virtual ProfileSyncService* GetProfileSyncService() OVERRIDE;
virtual bool IsSameProfile(Profile* profile) OVERRIDE;
virtual Time GetStartTime() const OVERRIDE;
virtual WebKitContext* GetWebKitContext() OVERRIDE;
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index b8e1a65..3d5a4ed 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -36,7 +36,6 @@ class HistoryService;
class HostContentSettingsMap;
class PasswordStore;
class PrefService;
-class ProfileSyncService;
class PromoCounter;
class ProtocolHandlerRegistry;
class SpeechInputPreferences;
@@ -381,10 +380,6 @@ class Profile : public content::BrowserContext {
// Returns the user style sheet watcher.
virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() = 0;
- // Returns true if this profile has a profile sync service.
- // TODO(tim): Bug 93922 - remove this.
- virtual bool HasProfileSyncService() = 0;
-
// Returns true if the last time this profile was open it was exited cleanly.
virtual bool DidLastSessionExitCleanly() = 0;
@@ -397,10 +392,6 @@ class Profile : public content::BrowserContext {
// Returns the Gaia Token Service, creating if not yet created.
virtual TokenService* GetTokenService() = 0;
- // Returns the ProfileSyncService, creating if not yet created.
- // TODO(tim): Bug 93922 - remove this.
- virtual ProfileSyncService* GetProfileSyncService() = 0;
-
// Return whether 2 profiles are the same. 2 profiles are the same if they
// represent the same profile. This can happen if there is pointer equality
// or if one profile is the incognito version of another profile (or vice
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index eaf6714..32cc731 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -1155,10 +1155,6 @@ quota::QuotaManager* ProfileImpl::GetQuotaManager() {
return quota_manager_.get();
}
-bool ProfileImpl::HasProfileSyncService() {
- return ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(this);
-}
-
bool ProfileImpl::DidLastSessionExitCleanly() {
// last_session_exited_cleanly_ is set when the preferences are loaded. Force
// it to be set by asking for the prefs.
@@ -1314,7 +1310,8 @@ void ProfileImpl::Observe(int type,
break;
}
case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED:
- GetProfileSyncService(); // Causes lazy-load if sync is enabled.
+ // Causes lazy-load if sync is enabled.
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(this);
registrar_.Remove(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED,
content::Source<Profile>(this));
break;
@@ -1354,10 +1351,6 @@ TokenService* ProfileImpl::GetTokenService() {
return token_service_.get();
}
-ProfileSyncService* ProfileImpl::GetProfileSyncService() {
- return ProfileSyncServiceFactory::GetInstance()->GetForProfile(this);
-}
-
ChromeBlobStorageContext* ProfileImpl::GetBlobStorageContext() {
if (!blob_storage_context_) {
blob_storage_context_ = new ChromeBlobStorageContext();
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index 5be442f..a4ef65f 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -25,7 +25,6 @@ class ExtensionPrefs;
class ExtensionPrefValueMap;
class NetPrefObserver;
class PrefService;
-class ProfileSyncService;
class PromoResourceService;
class SpeechInputPreferences;
class SSLConfigServiceManager;
@@ -109,7 +108,6 @@ class ProfileImpl : public Profile,
virtual net::SSLConfigService* GetSSLConfigService() OVERRIDE;
virtual HostContentSettingsMap* GetHostContentSettingsMap() OVERRIDE;
virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() OVERRIDE;
- virtual bool HasProfileSyncService() OVERRIDE;
virtual bool DidLastSessionExitCleanly() OVERRIDE;
virtual BookmarkModel* GetBookmarkModel() OVERRIDE;
virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() OVERRIDE;
@@ -121,7 +119,6 @@ class ProfileImpl : public Profile,
virtual void InitRegisteredProtocolHandlers() OVERRIDE;
virtual FilePath last_selected_directory() OVERRIDE;
virtual void set_last_selected_directory(const FilePath& path) OVERRIDE;
- virtual ProfileSyncService* GetProfileSyncService() OVERRIDE;
virtual TokenService* GetTokenService() OVERRIDE;
virtual ExtensionInfoMap* GetExtensionInfoMap() OVERRIDE;
virtual PromoCounter* GetInstantPromoCounter() OVERRIDE;
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
index 8627fea..9640e35 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
@@ -123,8 +123,6 @@ class AutofillDataTypeControllerTest : public testing::Test {
db_thread_.DeprecatedGetThreadObject());
db_notification_service_->Init();
web_data_service_ = new WebDataServiceFake();
- EXPECT_CALL(profile_, GetProfileSyncService()).WillRepeatedly(
- Return(&service_));
autofill_dtc_ =
new AutofillDataTypeControllerMock(&profile_sync_factory_,
&profile_,
diff --git a/chrome/browser/sync/glue/new_non_frontend_data_type_controller_unittest.cc b/chrome/browser/sync/glue/new_non_frontend_data_type_controller_unittest.cc
index 4517981..ab80ada 100644
--- a/chrome/browser/sync/glue/new_non_frontend_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/new_non_frontend_data_type_controller_unittest.cc
@@ -126,8 +126,6 @@ class NewNonFrontendDataTypeControllerTest : public testing::Test {
db_thread_(BrowserThread::DB) {}
virtual void SetUp() OVERRIDE {
- EXPECT_CALL(profile_, GetProfileSyncService()).WillRepeatedly(
- Return(&service_));
EXPECT_CALL(service_, GetUserShare()).WillRepeatedly(
Return((sync_api::UserShare*)NULL));
db_thread_.Start();
diff --git a/chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc b/chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc
index 6d7c4aa..01d208b 100644
--- a/chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc
@@ -112,8 +112,6 @@ class NonFrontendDataTypeControllerTest : public testing::Test {
change_processor_(NULL) {}
virtual void SetUp() {
- EXPECT_CALL(profile_, GetProfileSyncService()).WillRepeatedly(
- Return(&service_));
db_thread_.Start();
profile_sync_factory_.reset(
new StrictMock<ProfileSyncComponentsFactoryMock>());
diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
index 75fec91..466fa03 100644
--- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
@@ -411,8 +411,6 @@ class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest {
ProfileSyncService::AUTO_START,
false,
callback));
- EXPECT_CALL(profile_, GetProfileSyncService()).WillRepeatedly(
- Return(service_.get()));
DataTypeController* data_type_controller =
factory->CreateDataTypeController(components_factory,
&profile_,
diff --git a/chrome/browser/sync/profile_sync_service_harness.cc b/chrome/browser/sync/profile_sync_service_harness.cc
index 5e4d856..34b6124 100644
--- a/chrome/browser/sync/profile_sync_service_harness.cc
+++ b/chrome/browser/sync/profile_sync_service_harness.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/sync/glue/data_type_controller.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/sessions/session_state.h"
#include "chrome/browser/sync/sync_ui_util.h"
@@ -107,7 +108,8 @@ ProfileSyncServiceHarness::ProfileSyncServiceHarness(
password_(password),
profile_debug_name_(profile->GetDebugName()) {
if (IsSyncAlreadySetup()) {
- service_ = profile_->GetProfileSyncService();
+ service_ = ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ profile_);
service_->AddObserver(this);
ignore_result(TryListeningToMigrationEvents());
wait_state_ = FULLY_SYNCED;
@@ -119,7 +121,8 @@ ProfileSyncServiceHarness::~ProfileSyncServiceHarness() {}
// static
ProfileSyncServiceHarness* ProfileSyncServiceHarness::CreateAndAttach(
Profile* profile) {
- if (!profile->HasProfileSyncService()) {
+ if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(
+ profile)) {
NOTREACHED() << "Profile has never signed into sync.";
return NULL;
}
@@ -133,7 +136,8 @@ void ProfileSyncServiceHarness::SetCredentials(const std::string& username,
}
bool ProfileSyncServiceHarness::IsSyncAlreadySetup() {
- return profile_->HasProfileSyncService();
+ return ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(
+ profile_);
}
bool ProfileSyncServiceHarness::SetupSync() {
@@ -151,7 +155,8 @@ bool ProfileSyncServiceHarness::SetupSync() {
bool ProfileSyncServiceHarness::SetupSync(
syncable::ModelTypeSet synced_datatypes) {
// Initialize the sync client's profile sync service object.
- service_ = profile_->GetProfileSyncService();
+ service_ =
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
if (service_ == NULL) {
LOG(ERROR) << "SetupSync(): service_ is null.";
return false;
diff --git a/chrome/browser/sync/profile_sync_service_password_unittest.cc b/chrome/browser/sync/profile_sync_service_password_unittest.cc
index 0b2bbf0..d8d481d 100644
--- a/chrome/browser/sync/profile_sync_service_password_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_password_unittest.cc
@@ -227,8 +227,6 @@ class ProfileSyncServicePasswordTest : public AbstractProfileSyncServiceTest {
service_->GetPreferredDataTypes();
preferred_types.Put(syncable::PASSWORDS);
service_->ChangePreferredDataTypes(preferred_types);
- EXPECT_CALL(profile_, GetProfileSyncService()).WillRepeatedly(
- Return(service_.get()));
PasswordDataTypeController* data_type_controller =
new PasswordDataTypeController(factory,
&profile_,
diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
index 6e71108..34012a7 100644
--- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
@@ -193,8 +193,6 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest {
ProfileSyncService::AUTO_START,
false,
callback));
- EXPECT_CALL(profile_, GetProfileSyncService()).WillRepeatedly(
- Return(service_.get()));
TypedUrlDataTypeController* data_type_controller =
new TypedUrlDataTypeController(factory,
&profile_,
diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc
index c1abbee..67e0a5a 100644
--- a/chrome/browser/sync/sync_setup_flow.cc
+++ b/chrome/browser/sync/sync_setup_flow.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/sync_setup_flow_handler.h"
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/user_selectable_sync_type.h"
@@ -79,7 +80,8 @@ bool HasConfigurationChanged(const SyncConfiguration& configuration,
UpdateCustomConfigHistogram);
// If service is null or if this is a first time configuration, return true.
- ProfileSyncService* service = profile->GetProfileSyncService();
+ ProfileSyncService* service =
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
if (!service || !service->HasSyncSetupCompleted())
return true;
diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc
index 3dd7571..2775d4d 100644
--- a/chrome/browser/sync/sync_ui_util.cc
+++ b/chrome/browser/sync/sync_ui_util.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/protocol/proto_enum_conversions.h"
#include "chrome/browser/sync/protocol/sync_protocol_error.h"
#include "chrome/browser/sync/syncable/model_type.h"
@@ -427,7 +428,8 @@ void OpenSyncMyBookmarksDialog(Profile* profile,
Browser* browser,
ProfileSyncService::SyncEventCodes code) {
ProfileSyncService* service =
- profile->GetOriginalProfile()->GetProfileSyncService();
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ profile->GetOriginalProfile());
if (!service || !service->IsSyncEnabled()) {
LOG(DFATAL) << "OpenSyncMyBookmarksDialog called with sync disabled";
return;
diff --git a/chrome/browser/sync/sync_ui_util_mac.mm b/chrome/browser/sync/sync_ui_util_mac.mm
index 6cc6ff6..322c1ca 100644
--- a/chrome/browser/sync/sync_ui_util_mac.mm
+++ b/chrome/browser/sync/sync_ui_util_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -10,6 +10,8 @@
#include "base/logging.h"
#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/sync/sync_ui_util.h"
#include "chrome/common/pref_names.h"
#include "grit/chromium_strings.h"
@@ -25,7 +27,8 @@ namespace sync_ui_util {
void UpdateSyncItem(id syncItem, BOOL syncEnabled, Profile* profile) {
ProfileSyncService* syncService =
- profile->GetOriginalProfile()->GetProfileSyncService();
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ profile->GetOriginalProfile());
UpdateSyncItemForStatus(
syncItem,
syncEnabled,
diff --git a/chrome/browser/sync/test/integration/passwords_helper.cc b/chrome/browser/sync/test/integration/passwords_helper.cc
index f2cf8ab..7c550a2 100644
--- a/chrome/browser/sync/test/integration/passwords_helper.cc
+++ b/chrome/browser/sync/test/integration/passwords_helper.cc
@@ -11,6 +11,8 @@
#include "chrome/browser/password_manager/password_form_data.h"
#include "chrome/browser/password_manager/password_store.h"
#include "chrome/browser/password_manager/password_store_consumer.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -106,7 +108,8 @@ void RemoveLogins(PasswordStore* store) {
}
void SetPassphrase(int index, const std::string& passphrase) {
- test()->GetProfile(index)->GetProfileSyncService()->SetPassphrase(
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ test()->GetProfile(index))->SetPassphrase(
passphrase,
ProfileSyncService::EXPLICIT,
ProfileSyncService::USER_PROVIDED);
diff --git a/chrome/browser/sync/test/integration/sessions_helper.cc b/chrome/browser/sync/test/integration/sessions_helper.cc
index 7546f44..886dbee 100644
--- a/chrome/browser/sync/test/integration/sessions_helper.cc
+++ b/chrome/browser/sync/test/integration/sessions_helper.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -12,6 +12,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/glue/session_model_associator.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
@@ -50,8 +51,9 @@ void ScopedWindowMap::Reset(SessionWindowMap* windows) {
}
bool GetLocalSession(int index, const browser_sync::SyncedSession** session) {
- return test()->GetProfile(index)->GetProfileSyncService()->
- GetSessionModelAssociator()->GetLocalSession(session);
+ return ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ test()->GetProfile(index))->GetSessionModelAssociator()->GetLocalSession(
+ session);
}
bool ModelAssociatorHasTabWithUrl(int index, const GURL& url) {
@@ -134,8 +136,8 @@ bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls) {
return false;
}
if (!found) {
- test()->GetProfile(index)->GetProfileSyncService()->
- GetSessionModelAssociator()->
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ test()->GetProfile(index))->GetSessionModelAssociator()->
BlockUntilLocalChangeForTest(timeout_milli);
ui_test_utils::RunMessageLoop();
}
@@ -197,14 +199,16 @@ int GetNumWindows(int index) {
int GetNumForeignSessions(int index) {
SyncedSessionVector sessions;
- if (!test()->GetProfile(index)->GetProfileSyncService()->
+ if (!ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ test()->GetProfile(index))->
GetSessionModelAssociator()->GetAllForeignSessions(&sessions))
return 0;
return sessions.size();
}
bool GetSessionData(int index, SyncedSessionVector* sessions) {
- if (!test()->GetProfile(index)->GetProfileSyncService()->
+ if (!ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ test()->GetProfile(index))->
GetSessionModelAssociator()->GetAllForeignSessions(sessions))
return false;
SortSyncedSessions(sessions);
@@ -304,7 +308,8 @@ bool CheckForeignSessionsAgainst(
}
void DeleteForeignSession(int index, std::string session_tag) {
- test()->GetProfile(index)->GetProfileSyncService()->
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ test()->GetProfile(index))->
GetSessionModelAssociator()->DeleteForeignSession(session_tag);
}
diff --git a/chrome/browser/ui/webui/sessions_ui.cc b/chrome/browser/ui/webui/sessions_ui.cc
index 9e5665f..3de0f37 100644
--- a/chrome/browser/ui/webui/sessions_ui.cc
+++ b/chrome/browser/ui/webui/sessions_ui.cc
@@ -126,10 +126,10 @@ browser_sync::SessionModelAssociator* SessionsDOMHandler::GetModelAssociator() {
// We only want to get the model associator if there is one, and it is done
// syncing sessions.
Profile* profile = Profile::FromWebUI(web_ui());
- if (!profile->HasProfileSyncService())
+ ProfileSyncServiceFactory* f = ProfileSyncServiceFactory::GetInstance();
+ if (f->HasProfileSyncService(profile))
return NULL;
- ProfileSyncService* service(ProfileSyncServiceFactory::
- GetInstance()->GetForProfile(profile));
+ ProfileSyncService* service = f->GetForProfile(profile);
if (!service->ShouldPushChanges())
return NULL;
return service->GetSessionModelAssociator();
diff --git a/chrome/browser/ui/webui/sync_internals_ui.cc b/chrome/browser/ui/webui/sync_internals_ui.cc
index 5edb0ad..8fafa3f 100644
--- a/chrome/browser/ui/webui/sync_internals_ui.cc
+++ b/chrome/browser/ui/webui/sync_internals_ui.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -16,6 +16,7 @@
#include "chrome/browser/sync/js/js_controller.h"
#include "chrome/browser/sync/js/js_event_details.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/sync/util/weak_handle.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -68,7 +69,8 @@ namespace {
// Gets the ProfileSyncService of the underlying original profile.
// May return NULL (e.g., if sync is disabled on the command line).
ProfileSyncService* GetProfileSyncService(Profile* profile) {
- return profile->GetOriginalProfile()->GetProfileSyncService();
+ return ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ profile->GetOriginalProfile());
}
} // namespace
diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc
index fc984ba..90029ea 100644
--- a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc
@@ -11,6 +11,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/sync/sync_setup_flow.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser.h"
@@ -190,7 +191,8 @@ void SyncPromoHandler::ShowSetupUI() {
// StepWizardForShowSetupUI and ShowSetupUI.
// TODO(binji): Move this function back and fix the focus the right way.
ProfileSyncService* service =
- Profile::FromWebUI(web_ui())->GetProfileSyncService();
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ Profile::FromWebUI(web_ui()));
service->get_wizard().Step(SyncSetupWizard::GetLoginState());
}
diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc
index 1ec58e8..b638cdc 100644
--- a/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc
@@ -11,6 +11,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/sync/sync_setup_flow.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser.h"
@@ -182,7 +183,8 @@ void SyncPromoHandler2::Observe(int type,
void SyncPromoHandler2::StepWizardForShowSetupUI() {
ProfileSyncService* service =
- Profile::FromWebUI(web_ui_)->GetProfileSyncService();
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ Profile::FromWebUI(web_ui_));
service->get_wizard().Step(SyncSetupWizard::GetLoginState());
}
diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
index cf94b75..f3d56bb 100644
--- a/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
#include "chrome/browser/ui/webui/options/core_options_handler.h"
@@ -151,7 +152,8 @@ bool SyncPromoUI::ShouldShowSyncPromo(Profile* profile) {
// If the user is already signed into sync then don't show the promo.
ProfileSyncService* service =
- profile->GetOriginalProfile()->GetProfileSyncService();
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ profile->GetOriginalProfile());
if (!service || service->HasSyncSetupCompleted())
return false;
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index 5b4a9a6..a57d69d 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/protocol/service_constants.h"
#include "chrome/browser/sync/sync_setup_flow.h"
#include "chrome/browser/sync/util/oauth.h"
@@ -446,7 +447,9 @@ void SyncSetupHandler::ShowSetupDone(const string16& user) {
SyncPromoUI::SetUserSkippedSyncPromo(Profile::FromWebUI(web_ui()));
Profile* profile = Profile::FromWebUI(web_ui());
- ProfileSyncService* service = profile->GetProfileSyncService();
+ ProfileSyncService* service =
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ profile);
if (!service->HasSyncSetupCompleted()) {
FilePath profile_file_path = profile->GetPath();
ProfileMetrics::LogProfileSyncSignIn(profile_file_path);
@@ -561,7 +564,8 @@ void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) {
DCHECK(!flow_);
Profile* profile = Profile::FromWebUI(web_ui());
- ProfileSyncService* service = profile->GetProfileSyncService();
+ ProfileSyncService* service = ProfileSyncServiceFactory::GetInstance()->
+ GetForProfile(profile);
DCHECK(service);
service->ShowErrorUI();
@@ -589,7 +593,8 @@ void SyncSetupHandler::OpenSyncSetup() {
DCHECK(!flow_);
Profile* profile = Profile::FromWebUI(web_ui());
- ProfileSyncService* service = profile->GetProfileSyncService();
+ ProfileSyncService* service = ProfileSyncServiceFactory::GetInstance()->
+ GetForProfile(profile);
if (!service) {
// If there's no sync service, the user tried to manually invoke a syncSetup
// URL, but sync features are disabled. We need to close the overlay for
@@ -623,7 +628,8 @@ void SyncSetupHandler::OpenSyncSetup() {
bool SyncSetupHandler::FocusExistingWizard() {
Profile* profile = Profile::FromWebUI(web_ui());
- ProfileSyncService* service = profile->GetProfileSyncService();
+ ProfileSyncService* service = ProfileSyncServiceFactory::GetInstance()->
+ GetForProfile(profile);
if (!service)
return false;
diff --git a/chrome/test/base/profile_mock.h b/chrome/test/base/profile_mock.h
index 13582eb..0b54d38 100644
--- a/chrome/test/base/profile_mock.h
+++ b/chrome/test/base/profile_mock.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -21,7 +21,6 @@ class ProfileMock : public TestingProfile {
MOCK_METHOD1(GetWebDataService, WebDataService*(ServiceAccessType access));
MOCK_METHOD1(GetPasswordStore, PasswordStore* (ServiceAccessType access));
MOCK_METHOD0(GetTokenService, TokenService*());
- MOCK_METHOD0(GetProfileSyncService, ProfileSyncService*());
};
#endif // CHROME_TEST_BASE_PROFILE_MOCK_H_
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index c48b8c4..01304ef 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -712,10 +712,6 @@ HostZoomMap* TestingProfile::GetHostZoomMap() {
return NULL;
}
-bool TestingProfile::HasProfileSyncService() {
- return (profile_sync_service_.get() != NULL);
-}
-
std::wstring TestingProfile::GetName() {
return std::wstring();
}
@@ -794,17 +790,6 @@ TokenService* TestingProfile::GetTokenService() {
return token_service_.get();
}
-ProfileSyncService* TestingProfile::GetProfileSyncService() {
- if (!profile_sync_service_.get()) {
- // Use a NiceMock here since we are really using the mock as a
- // fake. Test cases that want to set expectations on a
- // ProfileSyncService should use the ProfileMock and have this
- // method return their own mock instance.
- profile_sync_service_.reset(new NiceMock<ProfileSyncServiceMock>());
- }
- return profile_sync_service_.get();
-}
-
ChromeBlobStorageContext* TestingProfile::GetBlobStorageContext() {
return NULL;
}
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index b9124c6..dbb4091 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -231,7 +231,6 @@ class TestingProfile : public Profile {
GetGeolocationPermissionContext() OVERRIDE;
virtual SpeechInputPreferences* GetSpeechInputPreferences() OVERRIDE;
virtual content::HostZoomMap* GetHostZoomMap() OVERRIDE;
- virtual bool HasProfileSyncService() OVERRIDE;
virtual std::wstring GetName();
virtual void SetName(const std::wstring& name) {}
virtual std::wstring GetID();
@@ -277,8 +276,6 @@ class TestingProfile : public Profile {
void BlockUntilHistoryProcessesPendingRequests();
virtual TokenService* GetTokenService() OVERRIDE;
- // Creates and initializes a profile sync service if the tests require one.
- virtual ProfileSyncService* GetProfileSyncService() OVERRIDE;
virtual ChromeBlobStorageContext* GetBlobStorageContext() OVERRIDE;
virtual ExtensionInfoMap* GetExtensionInfoMap() OVERRIDE;
virtual PromoCounter* GetInstantPromoCounter() OVERRIDE;