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 16 matching lines...) Expand all Loading... |
27 #include "chrome/browser/sync/startup_controller.h" | 27 #include "chrome/browser/sync/startup_controller.h" |
28 #include "chrome/browser/themes/theme_service_factory.h" | 28 #include "chrome/browser/themes/theme_service_factory.h" |
29 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 29 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
30 #include "chrome/browser/webdata/web_data_service_factory.h" | 30 #include "chrome/browser/webdata/web_data_service_factory.h" |
31 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
32 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 32 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
33 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 33 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
34 #include "components/signin/core/browser/signin_manager.h" | 34 #include "components/signin/core/browser/signin_manager.h" |
35 #include "extensions/browser/extension_system_provider.h" | 35 #include "extensions/browser/extension_system_provider.h" |
36 #include "extensions/browser/extensions_browser_client.h" | 36 #include "extensions/browser/extensions_browser_client.h" |
| 37 #include "url/gurl.h" |
37 | 38 |
38 // static | 39 // static |
39 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { | 40 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { |
40 return Singleton<ProfileSyncServiceFactory>::get(); | 41 return Singleton<ProfileSyncServiceFactory>::get(); |
41 } | 42 } |
42 | 43 |
43 // static | 44 // static |
44 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( | 45 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( |
45 Profile* profile) { | 46 Profile* profile) { |
46 if (!ProfileSyncService::IsSyncEnabled()) | 47 if (!ProfileSyncService::IsSyncEnabled()) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 95 |
95 // Always create the GCMProfileService instance such that we can listen to | 96 // Always create the GCMProfileService instance such that we can listen to |
96 // the profile notifications and purge the GCM store when the profile is | 97 // the profile notifications and purge the GCM store when the profile is |
97 // being signed out. | 98 // being signed out. |
98 gcm::GCMProfileServiceFactory::GetForProfile(profile); | 99 gcm::GCMProfileServiceFactory::GetForProfile(profile); |
99 | 100 |
100 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup | 101 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup |
101 // once http://crbug.com/171406 has been fixed. | 102 // once http://crbug.com/171406 has been fixed. |
102 AboutSigninInternalsFactory::GetForProfile(profile); | 103 AboutSigninInternalsFactory::GetForProfile(profile); |
103 | 104 |
| 105 const GURL sync_service_url = |
| 106 ProfileSyncService::GetSyncServiceURL(*CommandLine::ForCurrentProcess()); |
| 107 |
| 108 scoped_ptr<ManagedUserSigninManagerWrapper> signin_wrapper( |
| 109 new ManagedUserSigninManagerWrapper(profile, signin)); |
| 110 std::string account_id = signin_wrapper->GetAccountIdToUse(); |
| 111 OAuth2TokenService::ScopeSet scope_set; |
| 112 scope_set.insert(signin_wrapper->GetSyncScopeToUse()); |
| 113 ProfileOAuth2TokenService* token_service = |
| 114 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 115 net::URLRequestContextGetter* url_request_context_getter = |
| 116 profile->GetRequestContext(); |
| 117 |
104 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync | 118 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync |
105 // is set up and *not* a browser restart for a manual-start platform (where | 119 // is set up and *not* a browser restart for a manual-start platform (where |
106 // sync has already been set up, and should be able to start without user | 120 // sync has already been set up, and should be able to start without user |
107 // intervention). We can get rid of the browser_default eventually, but | 121 // intervention). We can get rid of the browser_default eventually, but |
108 // need to take care that ProfileSyncService doesn't get tripped up between | 122 // need to take care that ProfileSyncService doesn't get tripped up between |
109 // those two cases. Bug 88109. | 123 // those two cases. Bug 88109. |
110 browser_sync::ProfileSyncServiceStartBehavior behavior = | 124 browser_sync::ProfileSyncServiceStartBehavior behavior = |
111 browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START | 125 browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START |
112 : browser_sync::MANUAL_START; | 126 : browser_sync::MANUAL_START; |
113 ProfileSyncService* pss = new ProfileSyncService( | 127 ProfileSyncService* pss = new ProfileSyncService( |
114 new ProfileSyncComponentsFactoryImpl(profile, | 128 new ProfileSyncComponentsFactoryImpl(profile, |
115 CommandLine::ForCurrentProcess()), | 129 CommandLine::ForCurrentProcess(), |
| 130 sync_service_url, |
| 131 account_id, |
| 132 scope_set, |
| 133 token_service, |
| 134 url_request_context_getter), |
116 profile, | 135 profile, |
117 new ManagedUserSigninManagerWrapper(profile, signin), | 136 signin_wrapper.Pass(), |
118 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 137 token_service, |
119 behavior); | 138 behavior); |
120 | 139 |
121 pss->factory()->RegisterDataTypes(pss); | 140 pss->factory()->RegisterDataTypes(pss); |
122 pss->Initialize(); | 141 pss->Initialize(); |
123 return pss; | 142 return pss; |
124 } | 143 } |
125 | 144 |
126 // static | 145 // static |
127 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 146 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { |
128 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 147 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; |
129 } | 148 } |
OLD | NEW |