Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: chrome/browser/sync/profile_sync_service_factory.cc

Issue 162443004: sync: final pieces to sync deferred initialization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/profile_sync_service_factory.h" 5 #include "chrome/browser/sync/profile_sync_service_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/autofill/personal_data_manager_factory.h" 10 #include "chrome/browser/autofill/personal_data_manager_factory.h"
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/defaults.h" 12 #include "chrome/browser/defaults.h"
13 #include "chrome/browser/history/history_service_factory.h" 13 #include "chrome/browser/history/history_service_factory.h"
14 #include "chrome/browser/invalidation/invalidation_service_factory.h" 14 #include "chrome/browser/invalidation/invalidation_service_factory.h"
15 #include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h" 15 #include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h"
16 #include "chrome/browser/password_manager/password_store_factory.h" 16 #include "chrome/browser/password_manager/password_store_factory.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/search_engines/template_url_service_factory.h" 19 #include "chrome/browser/search_engines/template_url_service_factory.h"
20 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 20 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
21 #include "chrome/browser/sessions/tab_restore_service_factory.h" 21 #include "chrome/browser/sessions/tab_restore_service_factory.h"
22 #include "chrome/browser/signin/about_signin_internals_factory.h" 22 #include "chrome/browser/signin/about_signin_internals_factory.h"
23 #include "chrome/browser/signin/profile_oauth2_token_service.h" 23 #include "chrome/browser/signin/profile_oauth2_token_service.h"
24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
25 #include "chrome/browser/signin/signin_manager.h" 25 #include "chrome/browser/signin/signin_manager.h"
26 #include "chrome/browser/signin/signin_manager_factory.h" 26 #include "chrome/browser/signin/signin_manager_factory.h"
27 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" 27 #include "chrome/browser/sync/profile_sync_components_factory_impl.h"
28 #include "chrome/browser/sync/profile_sync_service.h" 28 #include "chrome/browser/sync/profile_sync_service.h"
29 #include "chrome/browser/sync/startup_controller.h"
29 #include "chrome/browser/themes/theme_service_factory.h" 30 #include "chrome/browser/themes/theme_service_factory.h"
30 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 31 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
31 #include "chrome/browser/webdata/web_data_service_factory.h" 32 #include "chrome/browser/webdata/web_data_service_factory.h"
32 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
33 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 34 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
34 #include "extensions/browser/extension_system_provider.h" 35 #include "extensions/browser/extension_system_provider.h"
35 #include "extensions/browser/extensions_browser_client.h" 36 #include "extensions/browser/extensions_browser_client.h"
36 37
37 // static 38 // static
38 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { 39 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // DependsOn(FaviconServiceFactory::GetInstance()); 83 // DependsOn(FaviconServiceFactory::GetInstance());
83 } 84 }
84 85
85 ProfileSyncServiceFactory::~ProfileSyncServiceFactory() { 86 ProfileSyncServiceFactory::~ProfileSyncServiceFactory() {
86 } 87 }
87 88
88 BrowserContextKeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor( 89 BrowserContextKeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor(
89 content::BrowserContext* context) const { 90 content::BrowserContext* context) const {
90 Profile* profile = static_cast<Profile*>(context); 91 Profile* profile = static_cast<Profile*>(context);
91 92
92 ProfileSyncService::StartBehavior behavior =
93 browser_defaults::kSyncAutoStarts ? ProfileSyncService::AUTO_START
94 : ProfileSyncService::MANUAL_START;
95
96 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); 93 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile);
97 94
98 // Automatically load the GCMProfileService if the enabled state has been 95 // Automatically load the GCMProfileService if the enabled state has been
99 // explicitly set. 96 // explicitly set.
100 const base::Value* gcm_enabled_value = 97 const base::Value* gcm_enabled_value =
101 profile->GetPrefs()->GetUserPrefValue(prefs::kGCMChannelEnabled); 98 profile->GetPrefs()->GetUserPrefValue(prefs::kGCMChannelEnabled);
102 bool gcm_enabled = false; 99 bool gcm_enabled = false;
103 if (gcm_enabled_value && 100 if (gcm_enabled_value &&
104 gcm_enabled_value->GetAsBoolean(&gcm_enabled) && 101 gcm_enabled_value->GetAsBoolean(&gcm_enabled) &&
105 gcm_enabled) { 102 gcm_enabled) {
106 gcm::GCMProfileServiceFactory::GetForProfile(profile); 103 gcm::GCMProfileServiceFactory::GetForProfile(profile);
107 } 104 }
108 105
109 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup 106 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup
110 // once http://crbug.com/171406 has been fixed. 107 // once http://crbug.com/171406 has been fixed.
111 AboutSigninInternalsFactory::GetForProfile(profile); 108 AboutSigninInternalsFactory::GetForProfile(profile);
112 109
113 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync 110 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync
114 // is set up and *not* a browser restart for a manual-start platform (where 111 // is set up and *not* a browser restart for a manual-start platform (where
115 // sync has already been set up, and should be able to start without user 112 // sync has already been set up, and should be able to start without user
116 // intervention). We can get rid of the browser_default eventually, but 113 // intervention). We can get rid of the browser_default eventually, but
117 // need to take care that ProfileSyncService doesn't get tripped up between 114 // need to take care that ProfileSyncService doesn't get tripped up between
118 // those two cases. Bug 88109. 115 // those two cases. Bug 88109.
116 browser_sync::ProfileSyncServiceStartBehavior behavior =
117 browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START
118 : browser_sync::MANUAL_START;
119 ProfileSyncService* pss = new ProfileSyncService( 119 ProfileSyncService* pss = new ProfileSyncService(
120 new ProfileSyncComponentsFactoryImpl(profile, 120 new ProfileSyncComponentsFactoryImpl(profile,
121 CommandLine::ForCurrentProcess()), 121 CommandLine::ForCurrentProcess()),
122 profile, 122 profile,
123 new ManagedUserSigninManagerWrapper(signin), 123 new ManagedUserSigninManagerWrapper(signin),
124 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), 124 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
125 behavior); 125 behavior);
126 126
127 pss->factory()->RegisterDataTypes(pss); 127 pss->factory()->RegisterDataTypes(pss);
128 pss->Initialize(); 128 pss->Initialize();
129 return pss; 129 return pss;
130 } 130 }
131 131
132 // static 132 // static
133 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { 133 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) {
134 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; 134 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL;
135 } 135 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | chrome/browser/sync/profile_sync_service_mock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698