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> |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 } | 624 } |
625 } | 625 } |
626 | 626 |
627 void ProfileSyncService::DisableForUser() { | 627 void ProfileSyncService::DisableForUser() { |
628 // Clear prefs (including SyncSetupHasCompleted) before shutting down so | 628 // Clear prefs (including SyncSetupHasCompleted) before shutting down so |
629 // PSS clients don't think we're set up while we're shutting down. | 629 // PSS clients don't think we're set up while we're shutting down. |
630 sync_prefs_.ClearPreferences(); | 630 sync_prefs_.ClearPreferences(); |
631 invalidator_storage_.Clear(); | 631 invalidator_storage_.Clear(); |
632 ClearUnrecoverableError(); | 632 ClearUnrecoverableError(); |
633 ShutdownImpl(true); | 633 ShutdownImpl(true); |
634 | |
635 // TODO(atwilson): Don't call SignOut() on *any* platform - move this into | |
636 // the UI layer if needed (sync activity should never result in the user | |
637 // being logged out of all chrome services). | |
638 if (!auto_start_enabled_ && !signin_->GetAuthenticatedUsername().empty()) | |
639 signin_->SignOut(); | |
640 | |
641 NotifyObservers(); | 634 NotifyObservers(); |
642 } | 635 } |
643 | 636 |
644 bool ProfileSyncService::HasSyncSetupCompleted() const { | 637 bool ProfileSyncService::HasSyncSetupCompleted() const { |
645 return sync_prefs_.HasSyncSetupCompleted(); | 638 return sync_prefs_.HasSyncSetupCompleted(); |
646 } | 639 } |
647 | 640 |
648 void ProfileSyncService::SetSyncSetupCompleted() { | 641 void ProfileSyncService::SetSyncSetupCompleted() { |
649 sync_prefs_.SetSyncSetupCompleted(); | 642 sync_prefs_.SetSyncSetupCompleted(); |
650 } | 643 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 true); | 924 true); |
932 } | 925 } |
933 | 926 |
934 current_experiments_ = experiments; | 927 current_experiments_ = experiments; |
935 } | 928 } |
936 | 929 |
937 void ProfileSyncService::UpdateAuthErrorState(const AuthError& error) { | 930 void ProfileSyncService::UpdateAuthErrorState(const AuthError& error) { |
938 is_auth_in_progress_ = false; | 931 is_auth_in_progress_ = false; |
939 last_auth_error_ = error; | 932 last_auth_error_ = error; |
940 | 933 |
941 // Fan the notification out to interested UI-thread components. | 934 // Fan the notification out to interested UI-thread components. Notify the |
942 NotifyObservers(); | 935 // SigninGlobalError first so it reflects the latest auth state before we |
| 936 // notify observers. |
943 if (signin()) | 937 if (signin()) |
944 signin()->signin_global_error()->AuthStatusChanged(); | 938 signin()->signin_global_error()->AuthStatusChanged(); |
| 939 NotifyObservers(); |
945 } | 940 } |
946 | 941 |
947 namespace { | 942 namespace { |
948 | 943 |
949 AuthError ConnectionStatusToAuthError( | 944 AuthError ConnectionStatusToAuthError( |
950 syncer::ConnectionStatus status) { | 945 syncer::ConnectionStatus status) { |
951 switch (status) { | 946 switch (status) { |
952 case syncer::CONNECTION_OK: | 947 case syncer::CONNECTION_OK: |
953 return AuthError::None(); | 948 return AuthError::None(); |
954 break; | 949 break; |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 1955 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
1961 ProfileSyncService* old_this = this; | 1956 ProfileSyncService* old_this = this; |
1962 this->~ProfileSyncService(); | 1957 this->~ProfileSyncService(); |
1963 new(old_this) ProfileSyncService( | 1958 new(old_this) ProfileSyncService( |
1964 new ProfileSyncComponentsFactoryImpl(profile, | 1959 new ProfileSyncComponentsFactoryImpl(profile, |
1965 CommandLine::ForCurrentProcess()), | 1960 CommandLine::ForCurrentProcess()), |
1966 profile, | 1961 profile, |
1967 signin, | 1962 signin, |
1968 behavior); | 1963 behavior); |
1969 } | 1964 } |
OLD | NEW |