diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 20:09:13 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 20:09:13 +0000 |
commit | 5e61afb935ec49bda9c3a1ef33fc11eaae242beb (patch) | |
tree | 8f6ce2ee74bffaaf7680fceb6b65fdf9c6c11f2f | |
parent | b7df4e2be5517bc7914152609e957b77dbcfb26f (diff) | |
download | chromium_src-5e61afb935ec49bda9c3a1ef33fc11eaae242beb.zip chromium_src-5e61afb935ec49bda9c3a1ef33fc11eaae242beb.tar.gz chromium_src-5e61afb935ec49bda9c3a1ef33fc11eaae242beb.tar.bz2 |
Remove a bunch of GetProfileSyncService callers to use the new factory.
This is mostly everything except code under /sync or sync_internals (those require a little more time
as they have unit test implications). The ones here are quite simple but need several owner-approvals, and given the upcoming 18 branch I'd like
to get this landed without a cross-team monday crunch :)
TBR=jhawkins@chromium.org
TBR=mirandac@chromium.org
TBR=isherman@chromium.org
TBR=nkostylev@chromium.org
TBR=estade@chromium.org
BUG=93922
Review URL: http://codereview.chromium.org/9169096
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119482 0039d316-1c4b-4281-b951-d872f2087c98
23 files changed, 151 insertions, 97 deletions
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc index 5c14f7a..f291cf9 100644 --- a/chrome/browser/autofill/personal_data_manager.cc +++ b/chrome/browser/autofill/personal_data_manager.cc @@ -22,6 +22,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/webdata/web_data_service.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" @@ -190,7 +191,8 @@ void PersonalDataManager::OnStateChanged() { return; } - ProfileSyncService* sync_service = profile_->GetProfileSyncService(); + ProfileSyncService* sync_service = + ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); if (!sync_service) return; @@ -889,7 +891,8 @@ void PersonalDataManager::EmptyMigrationTrash() { return; } - ProfileSyncService* sync_service = profile_->GetProfileSyncService(); + ProfileSyncService* sync_service = + ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); if (!sync_service) return; diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index e1e8e46..b8e76e5 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -82,6 +82,8 @@ #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/sessions/restore_tab_helper.h" #include "chrome/browser/sessions/session_service_factory.h" +#include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" #include "chrome/browser/tab_contents/link_infobar_delegate.h" #include "chrome/browser/themes/theme_service.h" @@ -5115,7 +5117,8 @@ void TestingAutomationProvider::AwaitFullSyncCompletion( // Ensure that the profile sync service and sync backend host are initialized // before waiting for sync cycle completion. In cases where the browser is // restarted with sync enabled, these operations may still be in flight. - if (!browser->profile()->GetProfileSyncService()) { + if (ProfileSyncServiceFactory::GetInstance()->GetForProfile( + browser->profile()) == NULL) { reply.SendError("ProfileSyncService initialization failed."); return; } @@ -5156,7 +5159,8 @@ void TestingAutomationProvider::AwaitSyncRestart( reply.SendError("Not signed in to sync"); return; } - if (!browser->profile()->GetProfileSyncService()) { + if (ProfileSyncServiceFactory::GetInstance()->GetForProfile( + browser->profile()) == NULL) { reply.SendError("ProfileSyncService initialization failed."); return; } diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index fa9ffee..2e45e77 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -54,6 +54,7 @@ #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/token_service.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/ui/browser_init.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_paths.h" @@ -912,7 +913,8 @@ void LoginUtilsImpl::StartSignedInServices( initialized = true; // Pass the updated passphrase to the sync service for use in decrypting // data encrypted with the user's GAIA password. - ProfileSyncService* sync_service = user_profile->GetProfileSyncService(); + ProfileSyncService* sync_service = + ProfileSyncServiceFactory::GetInstance()->GetForProfile(user_profile); if (sync_service) sync_service->SetPassphrase(password_, false); } diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc index 4447ab9..75aa7db4 100644 --- a/chrome/browser/chromeos/login/screen_locker.cc +++ b/chrome/browser/chromeos/login/screen_locker.cc @@ -32,6 +32,7 @@ #include "chrome/browser/profiles/profile_manager.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/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_window.h" @@ -266,7 +267,8 @@ void ScreenLocker::OnLoginSuccess( Profile* profile = ProfileManager::GetDefaultProfile(); if (profile) { - ProfileSyncService* service = profile->GetProfileSyncService(); + ProfileSyncService* service( + ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); if (service && !service->HasSyncSetupCompleted()) { // If sync has failed somehow, try setting the sync passphrase here. service->SetPassphrase(password, false); diff --git a/chrome/browser/extensions/app_notify_channel_ui.cc b/chrome/browser/extensions/app_notify_channel_ui.cc index 5d030fa..2885266 100644 --- a/chrome/browser/extensions/app_notify_channel_ui.cc +++ b/chrome/browser/extensions/app_notify_channel_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. @@ -8,6 +8,7 @@ #include "chrome/browser/infobars/infobar_tab_helper.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_wizard.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" #include "chrome/browser/ui/browser.h" @@ -115,7 +116,8 @@ void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) { if (accepted) { StartObservingSync(); ProfileSyncService* service = - browser_->profile()->GetOriginalProfile()->GetProfileSyncService(); + ProfileSyncServiceFactory::GetInstance()->GetForProfile( + browser_->profile()->GetOriginalProfile()); service->ShowLoginDialog(); } else { delegate_->OnSyncSetupResult(false); @@ -124,7 +126,8 @@ void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) { void AppNotifyChannelUIImpl::OnStateChanged() { ProfileSyncService* sync_service = - browser_->profile()->GetProfileSyncService(); + ProfileSyncServiceFactory::GetInstance()->GetForProfile( + browser_->profile()->GetOriginalProfile()); bool wizard_visible = sync_service->WizardIsVisible(); // ProfileSyncService raises OnStateChanged many times. Even multiple // times before the wizard actually becomes visible for the first time. @@ -143,11 +146,13 @@ void AppNotifyChannelUIImpl::OnStateChanged() { void AppNotifyChannelUIImpl::StartObservingSync() { CHECK(!observing_sync_); observing_sync_ = true; - browser_->profile()->GetProfileSyncService()->AddObserver(this); + ProfileSyncServiceFactory::GetInstance()->GetForProfile( + browser_->profile()->GetOriginalProfile())->AddObserver(this); } void AppNotifyChannelUIImpl::StopObservingSync() { CHECK(observing_sync_); observing_sync_ = false; - browser_->profile()->GetProfileSyncService()->RemoveObserver(this); + ProfileSyncServiceFactory::GetInstance()->GetForProfile( + browser_->profile()->GetOriginalProfile())->RemoveObserver(this); } diff --git a/chrome/browser/extensions/extension_webstore_private_api.cc b/chrome/browser/extensions/extension_webstore_private_api.cc index 61ef38f..8f393a5 100644 --- a/chrome/browser/extensions/extension_webstore_private_api.cc +++ b/chrome/browser/extensions/extension_webstore_private_api.cc @@ -19,6 +19,7 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/signin/token_service.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" @@ -59,10 +60,12 @@ ProfileSyncService* test_sync_service = NULL; // Returns either the test sync service, or the real one from |profile|. ProfileSyncService* GetSyncService(Profile* profile) { + // TODO(webstore): It seems |test_sync_service| is not used anywhere. It + // should be removed. if (test_sync_service) return test_sync_service; else - return profile->GetProfileSyncService(); + return ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); } bool IsWebStoreURL(Profile* profile, const GURL& url) { @@ -554,4 +557,3 @@ bool GetWebGLStatusFunction::RunImpl() { } return true; } - diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc index a608514..9510fb3 100644 --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc @@ -24,6 +24,7 @@ #include "chrome/browser/profiles/profile_metrics.h" #include "chrome/browser/sessions/session_service_factory.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/browser_window.h" #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" @@ -828,8 +829,11 @@ void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) { BrowserList::CloseAllBrowsersWithProfile(profile); // Disable sync for doomed profile. - if (profile->HasProfileSyncService()) - profile->GetProfileSyncService()->DisableForUser(); + if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( + profile)) { + ProfileSyncServiceFactory::GetInstance()->GetForProfile( + profile)->DisableForUser(); + } } QueueProfileDirectoryForDeletion(profile_dir); diff --git a/chrome/browser/sync/sync_setup_wizard_unittest.cc b/chrome/browser/sync/sync_setup_wizard_unittest.cc index 90df4ab..46b7cb0 100644 --- a/chrome/browser/sync/sync_setup_wizard_unittest.cc +++ b/chrome/browser/sync/sync_setup_wizard_unittest.cc @@ -14,6 +14,7 @@ #include "chrome/browser/signin/signin_manager_fake.h" #include "chrome/browser/sync/profile_sync_components_factory_mock.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/ui/browser.h" #include "chrome/browser/ui/browser_list.h" @@ -90,17 +91,17 @@ class SigninManagerMock : public FakeSigninManager { // A PSS subtype to inject. class ProfileSyncServiceForWizardTest : public ProfileSyncService { public: - ProfileSyncServiceForWizardTest(Profile* profile, - ProfileSyncService::StartBehavior behavior) - : ProfileSyncService(NULL, profile, NULL, behavior), - user_cancelled_dialog_(false), - is_using_secondary_passphrase_(false), - encrypt_everything_(false) { - signin_ = &mock_signin_; - ResetTestStats(); + virtual ~ProfileSyncServiceForWizardTest() {} + + static ProfileKeyedService* BuildManual(Profile* profile) { + return new ProfileSyncServiceForWizardTest(profile, + ProfileSyncService::MANUAL_START); } - virtual ~ProfileSyncServiceForWizardTest() {} + static ProfileKeyedService* BuildAuto(Profile* profile) { + return new ProfileSyncServiceForWizardTest(profile, + ProfileSyncService::AUTO_START); + } virtual void OnUserChoseDatatypes( bool sync_everything, syncable::ModelTypeSet chosen_types) OVERRIDE { @@ -178,23 +179,17 @@ class ProfileSyncServiceForWizardTest : public ProfileSyncService { std::string passphrase_; private: - DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceForWizardTest); -}; - -class TestingProfileWithSyncService : public TestingProfile { - public: - explicit TestingProfileWithSyncService( - ProfileSyncService::StartBehavior behavior) { - sync_service_.reset(new ProfileSyncServiceForWizardTest( - this, behavior)); + ProfileSyncServiceForWizardTest(Profile* profile, + ProfileSyncService::StartBehavior behavior) + : ProfileSyncService(NULL, profile, NULL, behavior), + user_cancelled_dialog_(false), + is_using_secondary_passphrase_(false), + encrypt_everything_(false) { + signin_ = &mock_signin_; + ResetTestStats(); } - virtual ProfileSyncService* GetProfileSyncService() { - return sync_service_.get(); - } - private: - ProfileSyncComponentsFactoryMock factory_; - scoped_ptr<ProfileSyncService> sync_service_; + DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceForWizardTest); }; // TODO(jhawkins): Subclass Browser (specifically, ShowOptionsTab) and inject it @@ -207,8 +202,10 @@ class SyncSetupWizardTest : public BrowserWithTestWindowTest { flow_(NULL) {} virtual ~SyncSetupWizardTest() {} virtual TestingProfile* BuildProfile() { - return new TestingProfileWithSyncService( - ProfileSyncService::MANUAL_START); + TestingProfile* profile = new TestingProfile(); + ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(profile, + ProfileSyncServiceForWizardTest::BuildManual); + return profile; } virtual void SetUp() { set_profile(BuildProfile()); @@ -222,7 +219,7 @@ class SyncSetupWizardTest : public BrowserWithTestWindowTest { browser()->SetWindowForTesting(window()); BrowserList::SetLastActive(browser()); service_ = static_cast<ProfileSyncServiceForWizardTest*>( - profile()->GetProfileSyncService()); + ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile())); wizard_ = service_->GetWizard(); } @@ -614,10 +611,10 @@ TEST_F(SyncSetupWizardTest, NonFatalError) { class SyncSetupWizardCrosTest : public SyncSetupWizardTest { public: virtual TestingProfile* BuildProfile() { - TestingProfile* profile = - new TestingProfileWithSyncService(ProfileSyncService::AUTO_START); - profile->GetProfileSyncService()->signin()->SetAuthenticatedUsername( - kTestUser); + TestingProfile* profile = new TestingProfile(); + ProfileSyncServiceFactory* f = ProfileSyncServiceFactory::GetInstance(); + f->SetTestingFactory(profile, ProfileSyncServiceForWizardTest::BuildAuto); + f->GetForProfile(profile)->signin()->SetAuthenticatedUsername(kTestUser); return profile; } }; diff --git a/chrome/browser/ui/auto_login_prompter.cc b/chrome/browser/ui/auto_login_prompter.cc index 2af2638..252ca41 100644 --- a/chrome/browser/ui/auto_login_prompter.cc +++ b/chrome/browser/ui/auto_login_prompter.cc @@ -13,8 +13,10 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/signin_manager.h" +#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/token_service.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/ui/auto_login_info_bar_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" @@ -135,10 +137,13 @@ void AutoLoginPrompter::ShowInfoBarUIThread(const std::string& account, // In an incognito window, there may not be a profile sync service and/or // signin manager. - if (!profile->HasProfileSyncService()) + if (!ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( + profile)) { return; + } - SigninManager* signin_manager = profile->GetProfileSyncService()->signin(); + SigninManager* signin_manager = + SigninManagerFactory::GetInstance()->GetForProfile(profile); if (!signin_manager) return; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index aaedd81..055a0b8 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -88,6 +88,7 @@ #include "chrome/browser/sessions/tab_restore_service.h" #include "chrome/browser/sessions/tab_restore_service_factory.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/tab_closeable_state_watcher.h" #include "chrome/browser/tab_contents/background_contents.h" @@ -396,8 +397,10 @@ Browser::Browser(Type type, Profile* profile) TabRestoreServiceChanged(tab_restore_service_); } - if (profile_->GetProfileSyncService()) - profile_->GetProfileSyncService()->AddObserver(this); + ProfileSyncService* service = + ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); + if (service) + service->AddObserver(this); CreateInstantIfNecessary(); @@ -412,8 +415,10 @@ Browser::Browser(Type type, Profile* profile) } Browser::~Browser() { - if (profile_->GetProfileSyncService()) - profile_->GetProfileSyncService()->RemoveObserver(this); + ProfileSyncService* service = + ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); + if (service) + service->RemoveObserver(this); BrowserList::RemoveBrowser(this); @@ -4382,7 +4387,8 @@ void Browser::Observe(int type, // Browser, ProfileSyncServiceObserver implementation: void Browser::OnStateChanged() { - DCHECK(profile_->GetProfileSyncService()); + DCHECK(ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( + profile_)); // For unit tests, we don't have a window. if (!window_) return; @@ -5483,7 +5489,8 @@ void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { void Browser::ShowSyncSetup() { ProfileSyncService* service = - profile()->GetOriginalProfile()->GetProfileSyncService(); + ProfileSyncServiceFactory::GetInstance()->GetForProfile( + profile()->GetOriginalProfile()); if (service->HasSyncSetupCompleted()) ShowOptionsTab(chrome::kPersonalOptionsSubPage); else diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc index 8f87dfb..daf5916 100644 --- a/chrome/browser/ui/toolbar/wrench_menu_model.cc +++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc @@ -18,6 +18,8 @@ #include "chrome/browser/prefs/pref_service.h" #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/sync_global_error.h" #include "chrome/browser/sync/sync_ui_util.h" #include "chrome/browser/tabs/tab_strip_model.h" @@ -260,7 +262,8 @@ string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const { return l10n_util::GetStringUTF16(IDS_UPDATE_NOW); case IDC_SHOW_SYNC_SETUP: { ProfileSyncService* service = - browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService(); + ProfileSyncServiceFactory::GetInstance()->GetForProfile( + browser_->GetProfile()->GetOriginalProfile()); SyncGlobalError* error = service->sync_global_error(); if (error && error->HasCustomizedSyncMenuItem()) return error->MenuItemLabel(); @@ -296,7 +299,8 @@ bool WrenchMenuModel::GetIconForCommandId(int command_id, } case IDC_SHOW_SYNC_SETUP: { ProfileSyncService* service = - browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService(); + ProfileSyncServiceFactory::GetInstance()->GetForProfile( + browser_->GetProfile()->GetOriginalProfile()); SyncGlobalError* error = service->sync_global_error(); if (error && error->HasCustomizedSyncMenuItem()) { int icon_id = error->MenuItemIconResourceID(); @@ -323,7 +327,8 @@ void WrenchMenuModel::ExecuteCommand(int command_id) { if (command_id == IDC_SHOW_SYNC_SETUP) { ProfileSyncService* service = - browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService(); + ProfileSyncServiceFactory::GetInstance()->GetForProfile( + browser_->GetProfile()->GetOriginalProfile()); SyncGlobalError* error = service->sync_global_error(); if (error && error->HasCustomizedSyncMenuItem()) { error->ExecuteMenuItem(browser_); @@ -590,6 +595,6 @@ void WrenchMenuModel::UpdateZoomControls() { } string16 WrenchMenuModel::GetSyncMenuLabel() const { - return sync_ui_util::GetSyncMenuLabel( - browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); + return sync_ui_util::GetSyncMenuLabel(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(browser_->profile()->GetOriginalProfile())); } diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index df81afd..85edaa0 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.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. @@ -22,6 +22,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/themes/theme_service.h" #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" #include "chrome/browser/ui/browser.h" @@ -1255,8 +1256,8 @@ void BookmarkBarView::BookmarkNodeAddedImpl(BookmarkModel* model, } DCHECK(index >= 0 && index <= GetBookmarkButtonCount()); const BookmarkNode* node = parent->GetChild(index); - ProfileSyncService* sync_service = - browser_->profile()->GetProfileSyncService(); + ProfileSyncService* sync_service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(browser_->profile())); if (!throbbing_view_ && sync_service && sync_service->SetupInProgress()) StartThrobbing(node, true); AddChildViewAt(CreateBookmarkButton(node), index); diff --git a/chrome/browser/ui/webui/ntp/foreign_session_handler.cc b/chrome/browser/ui/webui/ntp/foreign_session_handler.cc index daa8a8d..f7c7317 100644 --- a/chrome/browser/ui/webui/ntp/foreign_session_handler.cc +++ b/chrome/browser/ui/webui/ntp/foreign_session_handler.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/profiles/profile.h" #include "chrome/browser/sessions/session_restore.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/url_constants.h" @@ -74,8 +75,8 @@ void ForeignSessionHandler::Observe( } SessionModelAssociator* ForeignSessionHandler::GetModelAssociator() { - ProfileSyncService* service = - Profile::FromWebUI(web_ui())->GetProfileSyncService(); + ProfileSyncService* service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); if (service == NULL) return NULL; diff --git a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc index 5a33bb2..aba9c8f 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc +++ b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.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. @@ -15,6 +15,8 @@ #include "chrome/browser/net/chrome_url_request_context.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/common/pref_names.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/web_ui.h" @@ -56,7 +58,8 @@ NewTabPageSyncHandler::MessageType } void NewTabPageSyncHandler::RegisterMessages() { - sync_service_ = Profile::FromWebUI(web_ui())->GetProfileSyncService(); + sync_service_ = ProfileSyncServiceFactory::GetInstance()->GetForProfile( + Profile::FromWebUI(web_ui())); DCHECK(sync_service_); // This shouldn't get called by an incognito NTP. DCHECK(!sync_service_->IsManaged()); // And neither if sync is managed. sync_service_->AddObserver(this); diff --git a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc index f429b79..8b95675 100644 --- a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc +++ b/chrome/browser/ui/webui/ntp/ntp_login_handler.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. @@ -20,6 +20,7 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_metrics.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/ui/browser.h" #include "chrome/browser/ui/browser_list.h" @@ -174,7 +175,8 @@ void NTPLoginHandler::HandleLoginMessageSeen(const ListValue* args) { } void NTPLoginHandler::HandleShowAdvancedLoginUI(const ListValue* args) { - Profile::FromWebUI(web_ui())->GetProfileSyncService()->ShowConfigure(false); + ProfileSyncServiceFactory::GetInstance()->GetForProfile( + Profile::FromWebUI(web_ui()))->ShowConfigure(false); } void NTPLoginHandler::UpdateLogin() { diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc index f8ed702..cb1def5 100644 --- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc +++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc @@ -20,6 +20,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/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" @@ -339,7 +340,7 @@ void NTPResourceCache::CreateNewTabHTML() { // Don't initiate the sync related message passing with the page if the sync // code is not present. - if (profile_->GetProfileSyncService()) + if (ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_)) localized_strings.SetString("syncispresent", "true"); else localized_strings.SetString("syncispresent", "false"); diff --git a/chrome/browser/ui/webui/options/options_sync_setup_handler.cc b/chrome/browser/ui/webui/options/options_sync_setup_handler.cc index 75f9166..af88e2c 100644 --- a/chrome/browser/ui/webui/options/options_sync_setup_handler.cc +++ b/chrome/browser/ui/webui/options/options_sync_setup_handler.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. @@ -6,6 +6,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/sync/profile_sync_service_factory.h" #include "content/public/browser/web_ui.h" OptionsSyncSetupHandler::OptionsSyncSetupHandler( @@ -16,8 +17,8 @@ OptionsSyncSetupHandler::~OptionsSyncSetupHandler() { } void OptionsSyncSetupHandler::StepWizardForShowSetupUI() { - ProfileSyncService* service = - Profile::FromWebUI(web_ui())->GetProfileSyncService(); + ProfileSyncService* service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); DCHECK(service); // We should bring up either a login or a configure flow based on the state of diff --git a/chrome/browser/ui/webui/options/personal_options_handler.cc b/chrome/browser/ui/webui/options/personal_options_handler.cc index 34b0ad1..9442a23 100644 --- a/chrome/browser/ui/webui/options/personal_options_handler.cc +++ b/chrome/browser/ui/webui/options/personal_options_handler.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. @@ -23,6 +23,7 @@ #include "chrome/browser/profiles/profile_info_util.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/sync_setup_flow.h" #include "chrome/browser/sync/sync_ui_util.h" #include "chrome/browser/themes/theme_service.h" @@ -65,8 +66,8 @@ PersonalOptionsHandler::PersonalOptionsHandler() { } PersonalOptionsHandler::~PersonalOptionsHandler() { - ProfileSyncService* sync_service = - Profile::FromWebUI(web_ui())->GetProfileSyncService(); + ProfileSyncService* sync_service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); if (sync_service) sync_service->RemoveObserver(this); } @@ -251,8 +252,8 @@ void PersonalOptionsHandler::Observe( void PersonalOptionsHandler::OnStateChanged() { string16 status_label; string16 link_label; - ProfileSyncService* service = - Profile::FromWebUI(web_ui())->GetProfileSyncService(); + ProfileSyncService* service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); DCHECK(service); bool managed = service->IsManaged(); bool sync_setup_completed = service->HasSyncSetupCompleted(); @@ -369,7 +370,8 @@ void PersonalOptionsHandler::Initialize() { content::NotificationService::AllSources()); ObserveThemeChanged(); - ProfileSyncService* sync_service = profile->GetProfileSyncService(); + ProfileSyncService* sync_service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(profile)); if (sync_service) { sync_service->AddObserver(this); OnStateChanged(); diff --git a/chrome/browser/ui/webui/options/stop_syncing_handler.cc b/chrome/browser/ui/webui/options/stop_syncing_handler.cc index ad04a45..7920df8 100644 --- a/chrome/browser/ui/webui/options/stop_syncing_handler.cc +++ b/chrome/browser/ui/webui/options/stop_syncing_handler.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/profiles/profile_manager.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/common/url_constants.h" #include "content/public/browser/web_ui.h" #include "grit/chromium_strings.h" @@ -45,8 +46,8 @@ void StopSyncingHandler::RegisterMessages() { } void StopSyncingHandler::StopSyncing(const ListValue* args){ - ProfileSyncService* service = - Profile::FromWebUI(web_ui())->GetProfileSyncService(); + ProfileSyncService* service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); if (service != NULL && ProfileSyncService::IsSyncEnabled()) { service->DisableForUser(); ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); diff --git a/chrome/browser/ui/webui/options2/browser_options_handler2.cc b/chrome/browser/ui/webui/options2/browser_options_handler2.cc index 1720519..7f02994 100644 --- a/chrome/browser/ui/webui/options2/browser_options_handler2.cc +++ b/chrome/browser/ui/webui/options2/browser_options_handler2.cc @@ -35,6 +35,7 @@ #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.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/sync/sync_ui_util.h" #include "chrome/browser/themes/theme_service.h" @@ -95,8 +96,8 @@ BrowserOptionsHandler::BrowserOptionsHandler() } BrowserOptionsHandler::~BrowserOptionsHandler() { - ProfileSyncService* sync_service = - Profile::FromWebUI(web_ui())->GetProfileSyncService(); + ProfileSyncService* sync_service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); if (sync_service) sync_service->RemoveObserver(this); @@ -280,8 +281,8 @@ void BrowserOptionsHandler::RegisterMessages() { void BrowserOptionsHandler::OnStateChanged() { string16 status_label; string16 link_label; - ProfileSyncService* service = - Profile::FromWebUI(web_ui())->GetProfileSyncService(); + ProfileSyncService* service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); DCHECK(service); bool managed = service->IsManaged(); bool sync_setup_completed = service->HasSyncSetupCompleted(); @@ -371,7 +372,8 @@ void BrowserOptionsHandler::OnStateChanged() { void BrowserOptionsHandler::Initialize() { Profile* profile = Profile::FromWebUI(web_ui()); - ProfileSyncService* sync_service = profile->GetProfileSyncService(); + ProfileSyncService* sync_service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); if (sync_service) { sync_service->AddObserver(this); OnStateChanged(); diff --git a/chrome/browser/ui/webui/options2/options_sync_setup_handler2.cc b/chrome/browser/ui/webui/options2/options_sync_setup_handler2.cc index 7f12258..3824ad5 100644 --- a/chrome/browser/ui/webui/options2/options_sync_setup_handler2.cc +++ b/chrome/browser/ui/webui/options2/options_sync_setup_handler2.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. @@ -6,6 +6,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/sync/profile_sync_service_factory.h" #include "content/public/browser/web_ui.h" namespace options2 { @@ -18,8 +19,8 @@ OptionsSyncSetupHandler::~OptionsSyncSetupHandler() { } void OptionsSyncSetupHandler::StepWizardForShowSetupUI() { - ProfileSyncService* service = - Profile::FromWebUI(web_ui())->GetProfileSyncService(); + ProfileSyncService* service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); DCHECK(service); // We should bring up either a login or a configure flow based on the state of @@ -36,8 +37,8 @@ void OptionsSyncSetupHandler::StepWizardForShowSetupUI() { } void OptionsSyncSetupHandler::ShowSetupUI() { - ProfileSyncService* service = - Profile::FromWebUI(web_ui())->GetProfileSyncService(); + ProfileSyncService* service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); DCHECK(service); // The user is trying to manually load a syncSetup URL. We should bring up diff --git a/chrome/browser/ui/webui/options2/stop_syncing_handler2.cc b/chrome/browser/ui/webui/options2/stop_syncing_handler2.cc index 3678535..3363f2c 100644 --- a/chrome/browser/ui/webui/options2/stop_syncing_handler2.cc +++ b/chrome/browser/ui/webui/options2/stop_syncing_handler2.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/profiles/profile_manager.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/common/url_constants.h" #include "content/public/browser/web_ui.h" #include "grit/chromium_strings.h" @@ -47,8 +48,8 @@ void StopSyncingHandler::RegisterMessages() { } void StopSyncingHandler::StopSyncing(const ListValue* args){ - ProfileSyncService* service = - Profile::FromWebUI(web_ui())->GetProfileSyncService(); + ProfileSyncService* service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); if (service != NULL && ProfileSyncService::IsSyncEnabled()) { service->DisableForUser(); ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); diff --git a/chrome/browser/ui/webui/sessions_ui.cc b/chrome/browser/ui/webui/sessions_ui.cc index bfaddf7..9e5665f 100644 --- a/chrome/browser/ui/webui/sessions_ui.cc +++ b/chrome/browser/ui/webui/sessions_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. @@ -13,6 +13,7 @@ #include "chrome/browser/sync/glue/session_model_associator.h" #include "chrome/browser/sync/glue/synced_session.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/ntp/new_tab_ui.h" @@ -127,7 +128,8 @@ browser_sync::SessionModelAssociator* SessionsDOMHandler::GetModelAssociator() { Profile* profile = Profile::FromWebUI(web_ui()); if (!profile->HasProfileSyncService()) return NULL; - ProfileSyncService* service = profile->GetProfileSyncService(); + ProfileSyncService* service(ProfileSyncServiceFactory:: + GetInstance()->GetForProfile(profile)); if (!service->ShouldPushChanges()) return NULL; return service->GetSessionModelAssociator(); |