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.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
21 #include "base/string16.h" | 21 #include "base/string16.h" |
22 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
23 #include "base/threading/thread_restrictions.h" | 23 #include "base/threading/thread_restrictions.h" |
24 #if defined(OS_WIN) | |
25 #include "base/win/windows_version.h" | |
26 #endif | |
24 #include "chrome/browser/about_flags.h" | 27 #include "chrome/browser/about_flags.h" |
25 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
26 #include "chrome/browser/defaults.h" | 29 #include "chrome/browser/defaults.h" |
27 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 30 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
28 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/signin/signin_manager.h" | 32 #include "chrome/browser/signin/signin_manager.h" |
30 #include "chrome/browser/signin/signin_manager_factory.h" | 33 #include "chrome/browser/signin/signin_manager_factory.h" |
31 #include "chrome/browser/signin/token_service.h" | 34 #include "chrome/browser/signin/token_service.h" |
32 #include "chrome/browser/signin/token_service_factory.h" | 35 #include "chrome/browser/signin/token_service_factory.h" |
33 #include "chrome/browser/sync/backend_migrator.h" | 36 #include "chrome/browser/sync/backend_migrator.h" |
37 #include "chrome/browser/sync/credential_cache_service_factory_win.h" | |
38 #include "chrome/browser/sync/credential_cache_service_win.h" | |
34 #include "chrome/browser/sync/glue/change_processor.h" | 39 #include "chrome/browser/sync/glue/change_processor.h" |
35 #include "chrome/browser/sync/glue/chrome_encryptor.h" | 40 #include "chrome/browser/sync/glue/chrome_encryptor.h" |
36 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" | 41 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" |
37 #include "chrome/browser/sync/glue/data_type_controller.h" | 42 #include "chrome/browser/sync/glue/data_type_controller.h" |
38 #include "chrome/browser/sync/glue/session_data_type_controller.h" | 43 #include "chrome/browser/sync/glue/session_data_type_controller.h" |
39 #include "chrome/browser/sync/glue/session_model_associator.h" | 44 #include "chrome/browser/sync/glue/session_model_associator.h" |
40 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" | 45 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" |
41 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | 46 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" |
42 #include "chrome/browser/sync/sync_global_error.h" | 47 #include "chrome/browser/sync/sync_global_error.h" |
43 #include "chrome/browser/sync/user_selectable_sync_type.h" | 48 #include "chrome/browser/sync/user_selectable_sync_type.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
62 #include "sync/internal_api/public/util/sync_string_conversions.h" | 67 #include "sync/internal_api/public/util/sync_string_conversions.h" |
63 #include "sync/js/js_arg_list.h" | 68 #include "sync/js/js_arg_list.h" |
64 #include "sync/js/js_event_details.h" | 69 #include "sync/js/js_event_details.h" |
65 #include "sync/util/cryptographer.h" | 70 #include "sync/util/cryptographer.h" |
66 #include "ui/base/l10n/l10n_util.h" | 71 #include "ui/base/l10n/l10n_util.h" |
67 | 72 |
68 using browser_sync::ChangeProcessor; | 73 using browser_sync::ChangeProcessor; |
69 using browser_sync::DataTypeController; | 74 using browser_sync::DataTypeController; |
70 using browser_sync::DataTypeManager; | 75 using browser_sync::DataTypeManager; |
71 using browser_sync::SyncBackendHost; | 76 using browser_sync::SyncBackendHost; |
77 using syncer::CredentialCacheService; | |
78 using syncer::CredentialCacheServiceFactory; | |
72 using syncer::ModelType; | 79 using syncer::ModelType; |
73 using syncer::ModelTypeSet; | 80 using syncer::ModelTypeSet; |
74 using syncer::JsBackend; | 81 using syncer::JsBackend; |
75 using syncer::JsController; | 82 using syncer::JsController; |
76 using syncer::JsEventDetails; | 83 using syncer::JsEventDetails; |
77 using syncer::JsEventHandler; | 84 using syncer::JsEventHandler; |
78 using syncer::ModelSafeRoutingInfo; | 85 using syncer::ModelSafeRoutingInfo; |
79 using syncer::SyncCredentials; | 86 using syncer::SyncCredentials; |
80 using syncer::SyncProtocolError; | 87 using syncer::SyncProtocolError; |
81 using syncer::WeakHandle; | 88 using syncer::WeakHandle; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 signin_(signin_manager), | 139 signin_(signin_manager), |
133 unrecoverable_error_reason_(ERROR_REASON_UNSET), | 140 unrecoverable_error_reason_(ERROR_REASON_UNSET), |
134 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 141 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
135 expect_sync_configuration_aborted_(false), | 142 expect_sync_configuration_aborted_(false), |
136 encrypted_types_(syncer::Cryptographer::SensitiveTypes()), | 143 encrypted_types_(syncer::Cryptographer::SensitiveTypes()), |
137 encrypt_everything_(false), | 144 encrypt_everything_(false), |
138 encryption_pending_(false), | 145 encryption_pending_(false), |
139 auto_start_enabled_(start_behavior == AUTO_START), | 146 auto_start_enabled_(start_behavior == AUTO_START), |
140 failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 147 failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
141 configure_status_(DataTypeManager::UNKNOWN), | 148 configure_status_(DataTypeManager::UNKNOWN), |
142 setup_in_progress_(false) { | 149 setup_in_progress_(false), |
150 credential_cache_service_(NULL) { | |
143 #if defined(OS_ANDROID) | 151 #if defined(OS_ANDROID) |
144 chrome::VersionInfo version_info; | 152 chrome::VersionInfo version_info; |
145 if (version_info.IsOfficialBuild()) { | 153 if (version_info.IsOfficialBuild()) { |
146 sync_service_url_ = GURL(kSyncServerUrl); | 154 sync_service_url_ = GURL(kSyncServerUrl); |
147 } | 155 } |
148 #else | 156 #else |
149 // By default, dev, canary, and unbranded Chromium users will go to the | 157 // By default, dev, canary, and unbranded Chromium users will go to the |
150 // development servers. Development servers have more features than standard | 158 // development servers. Development servers have more features than standard |
151 // sync servers. Users with officially-branded Chrome stable and beta builds | 159 // sync servers. Users with officially-branded Chrome stable and beta builds |
152 // will go to the standard sync servers. | 160 // will go to the standard sync servers. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 return; | 206 return; |
199 } | 207 } |
200 | 208 |
201 RegisterAuthNotifications(); | 209 RegisterAuthNotifications(); |
202 | 210 |
203 if (!HasSyncSetupCompleted() || signin_->GetAuthenticatedUsername().empty()) { | 211 if (!HasSyncSetupCompleted() || signin_->GetAuthenticatedUsername().empty()) { |
204 // Clean up in case of previous crash / setup abort / signout. | 212 // Clean up in case of previous crash / setup abort / signout. |
205 DisableForUser(); | 213 DisableForUser(); |
206 } | 214 } |
207 | 215 |
216 #if defined(OS_WIN) | |
217 // Initialize the CredentialCacheService for the default profile on Windows 8. | |
218 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && | |
Andrew T Wilson (Slow)
2012/07/24 18:00:33
I guess I still don't understand why PSS needs to
Raghu Simha
2012/07/24 20:45:04
I see what you mean. I originally coupled PSS and
| |
219 CredentialCacheService::IsDefaultProfileDir(profile()->GetPath()) && | |
220 !sync_prefs_.IsStartSuppressed()) { | |
221 credential_cache_service_ = | |
222 CredentialCacheServiceFactory::GetInstance()->GetForProfile(profile_); | |
223 } | |
224 #endif // OS_WIN | |
225 | |
208 TryStart(); | 226 TryStart(); |
209 } | 227 } |
210 | 228 |
211 void ProfileSyncService::TryStart() { | 229 void ProfileSyncService::TryStart() { |
212 if (!IsSyncEnabledAndLoggedIn()) | 230 if (!IsSyncEnabledAndLoggedIn()) { |
231 #if defined(OS_WIN) | |
232 if (credential_cache_service_) | |
233 credential_cache_service_->LookForCachedCredentialsInAlternateProfile(); | |
234 #endif // OS_WIN | |
213 return; | 235 return; |
236 } | |
237 | |
214 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 238 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
215 if (!token_service) | 239 if (!token_service) |
216 return; | 240 return; |
217 // Don't start the backend if the token service hasn't finished loading tokens | 241 // Don't start the backend if the token service hasn't finished loading tokens |
218 // yet (if the backend is started before the sync token has been loaded, | 242 // yet (if the backend is started before the sync token has been loaded, |
219 // GetCredentials() will return bogus credentials). On auto_start platforms | 243 // GetCredentials() will return bogus credentials). On auto_start platforms |
220 // (like ChromeOS) we don't start sync until tokens are loaded, because the | 244 // (like ChromeOS) we don't start sync until tokens are loaded, because the |
221 // user can be "signed in" on those platforms long before the tokens get | 245 // user can be "signed in" on those platforms long before the tokens get |
222 // loaded, and we don't want to generate spurious auth errors. | 246 // loaded, and we don't want to generate spurious auth errors. |
223 if (IsSyncTokenAvailable() || | 247 if (IsSyncTokenAvailable() || |
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1763 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. | 1787 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. |
1764 ProfileSyncService* old_this = this; | 1788 ProfileSyncService* old_this = this; |
1765 this->~ProfileSyncService(); | 1789 this->~ProfileSyncService(); |
1766 new(old_this) ProfileSyncService( | 1790 new(old_this) ProfileSyncService( |
1767 new ProfileSyncComponentsFactoryImpl(profile, | 1791 new ProfileSyncComponentsFactoryImpl(profile, |
1768 CommandLine::ForCurrentProcess()), | 1792 CommandLine::ForCurrentProcess()), |
1769 profile, | 1793 profile, |
1770 signin, | 1794 signin, |
1771 behavior); | 1795 behavior); |
1772 } | 1796 } |
OLD | NEW |