OLD | NEW |
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" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 // Always create the GCMProfileService instance such that we can listen to | 101 // Always create the GCMProfileService instance such that we can listen to |
102 // the profile notifications and purge the GCM store when the profile is | 102 // the profile notifications and purge the GCM store when the profile is |
103 // being signed out. | 103 // being signed out. |
104 gcm::GCMProfileServiceFactory::GetForProfile(profile); | 104 gcm::GCMProfileServiceFactory::GetForProfile(profile); |
105 | 105 |
106 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup | 106 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup |
107 // once http://crbug.com/171406 has been fixed. | 107 // once http://crbug.com/171406 has been fixed. |
108 AboutSigninInternalsFactory::GetForProfile(profile); | 108 AboutSigninInternalsFactory::GetForProfile(profile); |
109 | 109 |
110 const GURL sync_service_url = | 110 const GURL sync_service_url = ProfileSyncService::GetSyncServiceURL( |
111 ProfileSyncService::GetSyncServiceURL(*CommandLine::ForCurrentProcess()); | 111 *base::CommandLine::ForCurrentProcess()); |
112 | 112 |
113 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper( | 113 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper( |
114 new SupervisedUserSigninManagerWrapper(profile, signin)); | 114 new SupervisedUserSigninManagerWrapper(profile, signin)); |
115 std::string account_id = signin_wrapper->GetAccountIdToUse(); | 115 std::string account_id = signin_wrapper->GetAccountIdToUse(); |
116 OAuth2TokenService::ScopeSet scope_set; | 116 OAuth2TokenService::ScopeSet scope_set; |
117 scope_set.insert(signin_wrapper->GetSyncScopeToUse()); | 117 scope_set.insert(signin_wrapper->GetSyncScopeToUse()); |
118 ProfileOAuth2TokenService* token_service = | 118 ProfileOAuth2TokenService* token_service = |
119 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 119 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
120 net::URLRequestContextGetter* url_request_context_getter = | 120 net::URLRequestContextGetter* url_request_context_getter = |
121 profile->GetRequestContext(); | 121 profile->GetRequestContext(); |
122 | 122 |
123 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync | 123 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync |
124 // is set up and *not* a browser restart for a manual-start platform (where | 124 // is set up and *not* a browser restart for a manual-start platform (where |
125 // sync has already been set up, and should be able to start without user | 125 // sync has already been set up, and should be able to start without user |
126 // intervention). We can get rid of the browser_default eventually, but | 126 // intervention). We can get rid of the browser_default eventually, but |
127 // need to take care that ProfileSyncService doesn't get tripped up between | 127 // need to take care that ProfileSyncService doesn't get tripped up between |
128 // those two cases. Bug 88109. | 128 // those two cases. Bug 88109. |
129 browser_sync::ProfileSyncServiceStartBehavior behavior = | 129 browser_sync::ProfileSyncServiceStartBehavior behavior = |
130 browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START | 130 browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START |
131 : browser_sync::MANUAL_START; | 131 : browser_sync::MANUAL_START; |
132 ProfileSyncService* pss = new ProfileSyncService( | 132 ProfileSyncService* pss = new ProfileSyncService( |
133 scoped_ptr<ProfileSyncComponentsFactory>( | 133 scoped_ptr<ProfileSyncComponentsFactory>( |
134 new ProfileSyncComponentsFactoryImpl( | 134 new ProfileSyncComponentsFactoryImpl( |
135 profile, | 135 profile, base::CommandLine::ForCurrentProcess(), sync_service_url, |
136 CommandLine::ForCurrentProcess(), | 136 token_service, url_request_context_getter)), |
137 sync_service_url, | 137 profile, signin_wrapper.Pass(), token_service, behavior); |
138 token_service, | |
139 url_request_context_getter)), | |
140 profile, | |
141 signin_wrapper.Pass(), | |
142 token_service, | |
143 behavior); | |
144 | 138 |
145 pss->factory()->RegisterDataTypes(pss); | 139 pss->factory()->RegisterDataTypes(pss); |
146 pss->Initialize(); | 140 pss->Initialize(); |
147 return pss; | 141 return pss; |
148 } | 142 } |
149 | 143 |
150 // static | 144 // static |
151 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 145 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { |
152 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 146 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; |
153 } | 147 } |
OLD | NEW |