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" | |
19 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
20 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
21 #include "base/string16.h" | 20 #include "base/string16.h" |
22 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
23 #include "base/threading/thread_restrictions.h" | 22 #include "base/threading/thread_restrictions.h" |
23 #if defined(OS_WIN) | |
24 #include "base/win/windows_version.h" | |
25 #endif | |
24 #include "chrome/browser/about_flags.h" | 26 #include "chrome/browser/about_flags.h" |
25 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
26 #include "chrome/browser/defaults.h" | 28 #include "chrome/browser/defaults.h" |
27 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 29 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
28 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/browser/profiles/profile_manager.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 #if defined(OS_WIN) | |
38 #include "chrome/browser/sync/credential_cache_win.h" | |
39 #endif | |
34 #include "chrome/browser/sync/glue/change_processor.h" | 40 #include "chrome/browser/sync/glue/change_processor.h" |
35 #include "chrome/browser/sync/glue/chrome_encryptor.h" | 41 #include "chrome/browser/sync/glue/chrome_encryptor.h" |
36 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" | 42 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" |
37 #include "chrome/browser/sync/glue/data_type_controller.h" | 43 #include "chrome/browser/sync/glue/data_type_controller.h" |
38 #include "chrome/browser/sync/glue/session_data_type_controller.h" | 44 #include "chrome/browser/sync/glue/session_data_type_controller.h" |
39 #include "chrome/browser/sync/glue/session_model_associator.h" | 45 #include "chrome/browser/sync/glue/session_model_associator.h" |
40 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" | 46 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" |
41 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | 47 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" |
42 #include "chrome/browser/sync/sync_global_error.h" | 48 #include "chrome/browser/sync/sync_global_error.h" |
43 #include "chrome/browser/sync/user_selectable_sync_type.h" | 49 #include "chrome/browser/sync/user_selectable_sync_type.h" |
44 #include "chrome/browser/ui/browser.h" | 50 #include "chrome/browser/ui/browser.h" |
45 #include "chrome/browser/ui/browser_list.h" | 51 #include "chrome/browser/ui/browser_list.h" |
46 #include "chrome/browser/ui/browser_window.h" | 52 #include "chrome/browser/ui/browser_window.h" |
47 #include "chrome/browser/ui/global_error_service.h" | 53 #include "chrome/browser/ui/global_error_service.h" |
48 #include "chrome/browser/ui/global_error_service_factory.h" | 54 #include "chrome/browser/ui/global_error_service_factory.h" |
49 #include "chrome/common/chrome_notification_types.h" | 55 #include "chrome/common/chrome_notification_types.h" |
56 #include "chrome/common/chrome_paths_internal.h" | |
50 #include "chrome/common/chrome_switches.h" | 57 #include "chrome/common/chrome_switches.h" |
51 #include "chrome/common/chrome_version_info.h" | 58 #include "chrome/common/chrome_version_info.h" |
52 #include "chrome/common/net/gaia/gaia_constants.h" | 59 #include "chrome/common/net/gaia/gaia_constants.h" |
53 #include "chrome/common/time_format.h" | 60 #include "chrome/common/time_format.h" |
54 #include "chrome/common/url_constants.h" | 61 #include "chrome/common/url_constants.h" |
62 #include "content/public/browser/browser_thread.h" | |
55 #include "content/public/browser/notification_details.h" | 63 #include "content/public/browser/notification_details.h" |
56 #include "content/public/browser/notification_source.h" | 64 #include "content/public/browser/notification_source.h" |
57 #include "grit/generated_resources.h" | 65 #include "grit/generated_resources.h" |
58 #include "net/cookies/cookie_monster.h" | 66 #include "net/cookies/cookie_monster.h" |
59 #include "sync/api/sync_error.h" | 67 #include "sync/api/sync_error.h" |
60 #include "sync/internal_api/public/configure_reason.h" | 68 #include "sync/internal_api/public/configure_reason.h" |
61 #include "sync/internal_api/public/util/experiments.h" | 69 #include "sync/internal_api/public/util/experiments.h" |
62 #include "sync/js/js_arg_list.h" | 70 #include "sync/js/js_arg_list.h" |
63 #include "sync/js/js_event_details.h" | 71 #include "sync/js/js_event_details.h" |
64 #include "sync/util/cryptographer.h" | 72 #include "sync/util/cryptographer.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 signin_(signin_manager), | 135 signin_(signin_manager), |
128 unrecoverable_error_reason_(ERROR_REASON_UNSET), | 136 unrecoverable_error_reason_(ERROR_REASON_UNSET), |
129 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 137 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
130 expect_sync_configuration_aborted_(false), | 138 expect_sync_configuration_aborted_(false), |
131 encrypted_types_(csync::Cryptographer::SensitiveTypes()), | 139 encrypted_types_(csync::Cryptographer::SensitiveTypes()), |
132 encrypt_everything_(false), | 140 encrypt_everything_(false), |
133 encryption_pending_(false), | 141 encryption_pending_(false), |
134 auto_start_enabled_(start_behavior == AUTO_START), | 142 auto_start_enabled_(start_behavior == AUTO_START), |
135 failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 143 failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
136 configure_status_(DataTypeManager::UNKNOWN), | 144 configure_status_(DataTypeManager::UNKNOWN), |
137 setup_in_progress_(false) { | 145 setup_in_progress_(false), |
146 setting_up_with_cached_credentials_(false) { | |
138 #if defined(OS_ANDROID) | 147 #if defined(OS_ANDROID) |
139 chrome::VersionInfo version_info; | 148 chrome::VersionInfo version_info; |
140 if (version_info.IsOfficialBuild()) { | 149 if (version_info.IsOfficialBuild()) { |
141 sync_service_url_ = GURL(kSyncServerUrl); | 150 sync_service_url_ = GURL(kSyncServerUrl); |
142 } | 151 } |
143 #else | 152 #else |
144 // By default, dev, canary, and unbranded Chromium users will go to the | 153 // By default, dev, canary, and unbranded Chromium users will go to the |
145 // development servers. Development servers have more features than standard | 154 // development servers. Development servers have more features than standard |
146 // sync servers. Users with officially-branded Chrome stable and beta builds | 155 // sync servers. Users with officially-branded Chrome stable and beta builds |
147 // will go to the standard sync servers. | 156 // will go to the standard sync servers. |
(...skipping 15 matching lines...) Expand all Loading... | |
163 | 172 |
164 bool ProfileSyncService::IsSyncEnabledAndLoggedIn() { | 173 bool ProfileSyncService::IsSyncEnabledAndLoggedIn() { |
165 // Exit if sync is disabled. | 174 // Exit if sync is disabled. |
166 if (IsManaged() || sync_prefs_.IsStartSuppressed()) | 175 if (IsManaged() || sync_prefs_.IsStartSuppressed()) |
167 return false; | 176 return false; |
168 | 177 |
169 // Sync is logged in if there is a non-empty authenticated username. | 178 // Sync is logged in if there is a non-empty authenticated username. |
170 return !signin_->GetAuthenticatedUsername().empty(); | 179 return !signin_->GetAuthenticatedUsername().empty(); |
171 } | 180 } |
172 | 181 |
182 #if defined (OS_WIN) | |
183 | |
184 bool ProfileSyncService::ShouldSigninUsingCachedCredentials() { | |
185 // Makes sure that we are running on Windows 8, that the current profile is | |
186 // the default profile directory, that sync is not disabled by policy, that | |
187 // startup is not suppressed, that setup is not already in progress, that no | |
188 // user is already signed in, and that we are not already trying to auto-start | |
189 // sync. | |
190 return | |
191 base::win::GetVersion() >= base::win::VERSION_WIN8 && | |
192 csync::CredentialCache::IsDefaultProfileDir(profile()->GetPath()) && | |
193 !IsManaged() && | |
194 !sync_prefs_.IsStartSuppressed() && | |
195 !setup_in_progress_ && | |
196 signin_->GetAuthenticatedUsername().empty() && | |
197 !setting_up_with_cached_credentials_; | |
198 } | |
199 | |
200 #endif // OS_WIN | |
201 | |
173 bool ProfileSyncService::IsSyncTokenAvailable() { | 202 bool ProfileSyncService::IsSyncTokenAvailable() { |
174 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 203 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
175 if (!token_service) | 204 if (!token_service) |
176 return false; | 205 return false; |
177 return token_service->HasTokenForService(GaiaConstants::kSyncService); | 206 return token_service->HasTokenForService(GaiaConstants::kSyncService); |
178 } | 207 } |
179 | 208 |
180 void ProfileSyncService::Initialize() { | 209 void ProfileSyncService::Initialize() { |
181 InitSettings(); | 210 InitSettings(); |
182 | 211 |
(...skipping 14 matching lines...) Expand all Loading... | |
197 | 226 |
198 if (!HasSyncSetupCompleted() || signin_->GetAuthenticatedUsername().empty()) { | 227 if (!HasSyncSetupCompleted() || signin_->GetAuthenticatedUsername().empty()) { |
199 // Clean up in case of previous crash / setup abort / signout. | 228 // Clean up in case of previous crash / setup abort / signout. |
200 DisableForUser(); | 229 DisableForUser(); |
201 } | 230 } |
202 | 231 |
203 TryStart(); | 232 TryStart(); |
204 } | 233 } |
205 | 234 |
206 void ProfileSyncService::TryStart() { | 235 void ProfileSyncService::TryStart() { |
236 #if defined(OS_WIN) | |
237 if (ShouldSigninUsingCachedCredentials()) { | |
Andrew T Wilson (Slow)
2012/06/26 23:26:13
What happens if the user is already logged in to a
Raghu Simha
2012/06/27 00:17:04
No. In such cases, signin_->GetAuthenticatedUserna
| |
238 TryLoadingCachedCredentials(); | |
239 return; | |
240 } | |
241 #endif // OS_WIN | |
207 if (!IsSyncEnabledAndLoggedIn()) | 242 if (!IsSyncEnabledAndLoggedIn()) |
208 return; | 243 return; |
209 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 244 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
210 if (!token_service) | 245 if (!token_service) |
211 return; | 246 return; |
212 // Don't start the backend if the token service hasn't finished loading tokens | 247 // Don't start the backend if the token service hasn't finished loading tokens |
213 // yet (if the backend is started before the sync token has been loaded, | 248 // yet (if the backend is started before the sync token has been loaded, |
214 // GetCredentials() will return bogus credentials). On auto_start platforms | 249 // GetCredentials() will return bogus credentials). On auto_start platforms |
215 // (like ChromeOS) we don't start sync until tokens are loaded, because the | 250 // (like ChromeOS) we don't start sync until tokens are loaded, because the |
216 // user can be "signed in" on those platforms long before the tokens get | 251 // user can be "signed in" on those platforms long before the tokens get |
217 // loaded, and we don't want to generate spurious auth errors. | 252 // loaded, and we don't want to generate spurious auth errors. |
218 if (IsSyncTokenAvailable() || | 253 if (IsSyncTokenAvailable() || |
219 (!auto_start_enabled_ && token_service->TokensLoadedFromDB())) { | 254 (!auto_start_enabled_ && token_service->TokensLoadedFromDB())) { |
220 if (HasSyncSetupCompleted() || auto_start_enabled_) { | 255 if (HasSyncSetupCompleted() || auto_start_enabled_) { |
221 // If sync setup has completed we always start the backend. | 256 // If sync setup has completed we always start the backend. |
222 // If autostart is enabled, but we haven't completed sync setup, we try to | 257 // If autostart is enabled, but we haven't completed sync setup, we try to |
223 // start sync anyway, since it's possible we crashed/shutdown after | 258 // start sync anyway, since it's possible we crashed/shutdown after |
224 // logging in but before the backend finished initializing the last time. | 259 // logging in but before the backend finished initializing the last time. |
225 // Note that if we haven't finished setting up sync, backend bring up will | 260 // Note that if we haven't finished setting up sync, backend bring up will |
226 // be done by the wizard. | 261 // be done by the wizard. |
227 StartUp(); | 262 StartUp(); |
228 } | 263 } |
229 } | 264 } |
230 } | 265 } |
231 | 266 |
267 #if defined(OS_WIN) | |
268 | |
269 void ProfileSyncService::TryLoadingCachedCredentials() { | |
270 scoped_refptr<csync::CredentialCache> credentials = | |
271 new csync::CredentialCache(profile_->GetPath()); | |
272 content::BrowserThread::PostTaskAndReply( | |
273 content::BrowserThread::FILE, | |
274 FROM_HERE, | |
275 base::Bind(&csync::CredentialCache::LoadCredentialsFromAlternateProfile, | |
276 credentials), | |
277 base::Bind(&ProfileSyncService::OnLoadedCachedCredentials, | |
278 weak_factory_.GetWeakPtr(), | |
279 credentials)); | |
Roger Tawa OOO till Jul 10th
2012/06/27 21:23:28
why not bind the path directly instead of creating
Raghu Simha
2012/07/19 06:57:07
We now use a CredentialCacheService to do this.
| |
280 } | |
281 | |
282 void ProfileSyncService::OnLoadedCachedCredentials( | |
283 scoped_refptr<csync::CredentialCache> credentials) { | |
284 DCHECK(credentials.get() != NULL); | |
285 if (!credentials->authenticated_username().empty() && | |
286 !credentials->sid().empty() && | |
287 !credentials->lsid().empty() && | |
288 !credentials->encryption_bootstrap_token().empty()) { | |
289 setting_up_with_cached_credentials_ = true; | |
290 SetSetupInProgress(true); | |
291 sync_prefs_.SetEncryptionBootstrapToken( | |
292 credentials->encryption_bootstrap_token()); | |
293 signin_->StartSignInWithCachedCredentials(credentials); | |
294 } | |
295 credentials.release(); | |
296 } | |
297 | |
298 #endif // OS_WIN | |
299 | |
232 void ProfileSyncService::StartSyncingWithServer() { | 300 void ProfileSyncService::StartSyncingWithServer() { |
233 if (backend_.get()) | 301 if (backend_.get()) |
234 backend_->StartSyncingWithServer(); | 302 backend_->StartSyncingWithServer(); |
235 } | 303 } |
236 | 304 |
237 void ProfileSyncService::RegisterAuthNotifications() { | 305 void ProfileSyncService::RegisterAuthNotifications() { |
238 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 306 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
239 registrar_.Add(this, | 307 registrar_.Add(this, |
240 chrome::NOTIFICATION_TOKEN_AVAILABLE, | 308 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
241 content::Source<TokenService>(token_service)); | 309 content::Source<TokenService>(token_service)); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 DCHECK(encrypted_types.Has(syncable::PASSWORDS)); | 436 DCHECK(encrypted_types.Has(syncable::PASSWORDS)); |
369 return !Intersection(preferred_types, encrypted_types).Empty(); | 437 return !Intersection(preferred_types, encrypted_types).Empty(); |
370 } | 438 } |
371 | 439 |
372 void ProfileSyncService::OnSyncConfigureDone( | 440 void ProfileSyncService::OnSyncConfigureDone( |
373 DataTypeManager::ConfigureResult result) { | 441 DataTypeManager::ConfigureResult result) { |
374 if (failed_datatypes_handler_.UpdateFailedDatatypes(result.failed_data_types, | 442 if (failed_datatypes_handler_.UpdateFailedDatatypes(result.failed_data_types, |
375 FailedDatatypesHandler::STARTUP)) { | 443 FailedDatatypesHandler::STARTUP)) { |
376 ReconfigureDatatypeManager(); | 444 ReconfigureDatatypeManager(); |
377 } | 445 } |
446 | |
447 // If we were trying to bootstrap sync using cached credentials, this | |
448 // signifies the end of a successful auto-start. Set the flag to false and | |
449 // mark sync setup as complete. | |
450 if (setting_up_with_cached_credentials_) { | |
451 setting_up_with_cached_credentials_ = false; | |
452 SetSyncSetupCompleted(); | |
453 NotifyObservers(); | |
454 } | |
378 } | 455 } |
379 | 456 |
380 void ProfileSyncService::OnSyncConfigureRetry() { | 457 void ProfileSyncService::OnSyncConfigureRetry() { |
381 // In platforms with auto start we would just wait for the | 458 // In platforms with auto start we would just wait for the |
382 // configure to finish. In other platforms we would throw | 459 // configure to finish. In other platforms we would throw |
383 // an unrecoverable error. The reason we do this is so that | 460 // an unrecoverable error. The reason we do this is so that |
384 // the login dialog would show an error and the user would have | 461 // the login dialog would show an error and the user would have |
385 // to relogin. | 462 // to relogin. |
386 // Also if backend has been initialized(the user is authenticated | 463 // Also if backend has been initialized(the user is authenticated |
387 // and nigori is downloaded) we would simply wait rather than going into | 464 // and nigori is downloaded) we would simply wait rather than going into |
388 // unrecoverable error, even if the platform has auto start disabled. | 465 // unrecoverable error, even if the platform has auto start disabled. |
389 // Note: In those scenarios the UI does not wait for the configuration | 466 // Note: In those scenarios the UI does not wait for the configuration |
390 // to finish. | 467 // to finish. |
391 if (!auto_start_enabled_ && !backend_initialized_) { | 468 if (!auto_start_enabled_ && !backend_initialized_) { |
392 OnInternalUnrecoverableError(FROM_HERE, | 469 OnInternalUnrecoverableError(FROM_HERE, |
393 "Configure failed to download.", | 470 "Configure failed to download.", |
394 true, | 471 true, |
395 ERROR_REASON_CONFIGURATION_RETRY); | 472 ERROR_REASON_CONFIGURATION_RETRY); |
396 } | 473 } |
397 | 474 |
398 NotifyObservers(); | 475 NotifyObservers(); |
399 } | 476 } |
400 | 477 |
401 | |
402 void ProfileSyncService::StartUp() { | 478 void ProfileSyncService::StartUp() { |
403 // Don't start up multiple times. | 479 // Don't start up multiple times. |
404 if (backend_.get()) { | 480 if (backend_.get()) { |
405 DVLOG(1) << "Skipping bringing up backend host."; | 481 DVLOG(1) << "Skipping bringing up backend host."; |
406 return; | 482 return; |
407 } | 483 } |
408 | 484 |
409 DCHECK(IsSyncEnabledAndLoggedIn()); | 485 DCHECK(IsSyncEnabledAndLoggedIn()); |
410 | 486 |
411 last_synced_time_ = sync_prefs_.GetLastSyncedTime(); | 487 last_synced_time_ = sync_prefs_.GetLastSyncedTime(); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 return; | 733 return; |
658 } | 734 } |
659 | 735 |
660 backend_initialized_ = true; | 736 backend_initialized_ = true; |
661 | 737 |
662 sync_js_controller_.AttachJsBackend(js_backend); | 738 sync_js_controller_.AttachJsBackend(js_backend); |
663 | 739 |
664 // If we have a cached passphrase use it to decrypt/encrypt data now that the | 740 // If we have a cached passphrase use it to decrypt/encrypt data now that the |
665 // backend is initialized. We want to call this before notifying observers in | 741 // backend is initialized. We want to call this before notifying observers in |
666 // case this operation affects the "passphrase required" status. | 742 // case this operation affects the "passphrase required" status. |
667 ConsumeCachedPassphraseIfPossible(); | 743 // Note: On Windows 8, if we are signing in using sync credentials cached by |
744 // the alternate Metro / Desktop profile, there is no passphrase to consume, | |
745 // since we only store the encryption bootstrap token for sync. | |
746 if (!setting_up_with_cached_credentials_) | |
Andrew T Wilson (Slow)
2012/06/26 23:26:13
Don't need this check since ConsumeCachedPassphras
Raghu Simha
2012/07/19 06:57:07
Removed.
| |
747 ConsumeCachedPassphraseIfPossible(); | |
668 | 748 |
669 // The very first time the backend initializes is effectively the first time | 749 // The very first time the backend initializes is effectively the first time |
670 // we can say we successfully "synced". last_synced_time_ will only be null | 750 // we can say we successfully "synced". last_synced_time_ will only be null |
671 // in this case, because the pref wasn't restored on StartUp. | 751 // in this case, because the pref wasn't restored on StartUp. |
672 if (last_synced_time_.is_null()) { | 752 if (last_synced_time_.is_null()) { |
673 UpdateLastSyncedTime(); | 753 UpdateLastSyncedTime(); |
674 } | 754 } |
675 NotifyObservers(); | 755 NotifyObservers(); |
676 | 756 |
677 if (auto_start_enabled_ && !FirstSetupInProgress()) { | 757 if (auto_start_enabled_ && !FirstSetupInProgress()) { |
678 // Backend is initialized but we're not in sync setup, so this must be an | 758 // Backend is initialized but we're not in sync setup, so this must be an |
679 // autostart - mark our sync setup as completed and we'll start syncing | 759 // autostart - mark our sync setup as completed and we'll start syncing |
680 // below. | 760 // below. |
681 SetSyncSetupCompleted(); | 761 SetSyncSetupCompleted(); |
682 NotifyObservers(); | 762 NotifyObservers(); |
683 } | 763 } |
684 | 764 |
685 if (HasSyncSetupCompleted()) { | 765 // Configure the DTM if we are in the middle of an auto-start, or if we are |
766 // bootstrapping sync using cached sync credentials on Windows 8. | |
767 if (HasSyncSetupCompleted() || setting_up_with_cached_credentials_) { | |
Andrew T Wilson (Slow)
2012/06/26 23:26:13
Seems like it'd be better to just set HasSyncSetup
Raghu Simha
2012/06/27 00:17:04
This is an excellent point. I believe I'm going to
| |
686 ConfigureDataTypeManager(); | 768 ConfigureDataTypeManager(); |
687 } else { | 769 } else { |
688 DCHECK(FirstSetupInProgress()); | 770 DCHECK(FirstSetupInProgress()); |
689 } | 771 } |
690 } | 772 } |
691 | 773 |
692 void ProfileSyncService::OnSyncCycleCompleted() { | 774 void ProfileSyncService::OnSyncCycleCompleted() { |
693 UpdateLastSyncedTime(); | 775 UpdateLastSyncedTime(); |
694 if (GetSessionModelAssociator()) { | 776 if (GetSessionModelAssociator()) { |
695 // Trigger garbage collection of old sessions now that we've downloaded | 777 // Trigger garbage collection of old sessions now that we've downloaded |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1459 } else { | 1541 } else { |
1460 StartSyncingWithServer(); | 1542 StartSyncingWithServer(); |
1461 } | 1543 } |
1462 | 1544 |
1463 break; | 1545 break; |
1464 } | 1546 } |
1465 case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: { | 1547 case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: { |
1466 const GoogleServiceSigninSuccessDetails* successful = | 1548 const GoogleServiceSigninSuccessDetails* successful = |
1467 content::Details<const GoogleServiceSigninSuccessDetails>( | 1549 content::Details<const GoogleServiceSigninSuccessDetails>( |
1468 details).ptr(); | 1550 details).ptr(); |
1469 DCHECK(!successful->password.empty()); | 1551 // The only time the password field is allowed to be empty is when we are |
1470 if (!sync_prefs_.IsStartSuppressed()) { | 1552 // bootstrapping sync from cached credentials. |
1553 DCHECK(setting_up_with_cached_credentials_ || | |
1554 !successful->password.empty()); | |
Andrew T Wilson (Slow)
2012/06/26 23:26:13
This is kind of ugly, as it means that people outs
Raghu Simha
2012/06/27 00:17:04
Agreed. Coming up.
Raghu Simha
2012/07/19 06:57:07
Concerns addressed in new design, I hope :)
| |
1555 | |
1556 // Do not use the password as a cached passphrase if sync is suppressed. | |
1557 // Also, if we are starting up sync using cached credentials, do not try | |
1558 // to use the gaia password as an implicit passphrase, since passwords are | |
1559 // not persisted in the sync cache, and the password field will be empty. | |
1560 if (!sync_prefs_.IsStartSuppressed() && | |
1561 !setting_up_with_cached_credentials_) { | |
1471 cached_passphrase_ = successful->password; | 1562 cached_passphrase_ = successful->password; |
1472 // Try to consume the passphrase we just cached. If the sync backend | 1563 // Try to consume the passphrase we just cached. If the sync backend |
1473 // is not running yet, the passphrase will remain cached until the | 1564 // is not running yet, the passphrase will remain cached until the |
1474 // backend starts up. | 1565 // backend starts up. |
1475 ConsumeCachedPassphraseIfPossible(); | 1566 ConsumeCachedPassphraseIfPossible(); |
1476 } | 1567 } |
1477 #if defined(OS_CHROMEOS) | 1568 #if defined(OS_CHROMEOS) |
1478 RefreshSpareBootstrapToken(successful->password); | 1569 RefreshSpareBootstrapToken(successful->password); |
1479 #endif | 1570 #endif |
1480 if (!sync_initialized() || | 1571 if (!sync_initialized() || |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1652 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. | 1743 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. |
1653 ProfileSyncService* old_this = this; | 1744 ProfileSyncService* old_this = this; |
1654 this->~ProfileSyncService(); | 1745 this->~ProfileSyncService(); |
1655 new(old_this) ProfileSyncService( | 1746 new(old_this) ProfileSyncService( |
1656 new ProfileSyncComponentsFactoryImpl(profile, | 1747 new ProfileSyncComponentsFactoryImpl(profile, |
1657 CommandLine::ForCurrentProcess()), | 1748 CommandLine::ForCurrentProcess()), |
1658 profile, | 1749 profile, |
1659 signin, | 1750 signin, |
1660 behavior); | 1751 behavior); |
1661 } | 1752 } |
OLD | NEW |