Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 14655009: Client changes for disabled dasher account (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix small things based on feedback Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 for (int i = 0; i < kRelevantTokenServicesCount; ++i) { 118 for (int i = 0; i < kRelevantTokenServicesCount; ++i) {
119 if (service == kRelevantTokenServices[i]) 119 if (service == kRelevantTokenServices[i])
120 return true; 120 return true;
121 } 121 }
122 return false; 122 return false;
123 } 123 }
124 124
125 bool ShouldShowActionOnUI( 125 bool ShouldShowActionOnUI(
126 const syncer::SyncProtocolError& error) { 126 const syncer::SyncProtocolError& error) {
127 return (error.action != syncer::UNKNOWN_ACTION && 127 return (error.action != syncer::UNKNOWN_ACTION &&
128 error.action != syncer::DISABLE_SYNC_ON_CLIENT); 128 error.action != syncer::DISABLE_SYNC_ON_CLIENT &&
129 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT);
129 } 130 }
130 131
131 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory, 132 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory,
132 Profile* profile, 133 Profile* profile,
133 SigninManagerBase* signin_manager, 134 SigninManagerBase* signin_manager,
134 StartBehavior start_behavior) 135 StartBehavior start_behavior)
135 : last_auth_error_(AuthError::AuthErrorNone()), 136 : last_auth_error_(AuthError::AuthErrorNone()),
136 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), 137 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED),
137 factory_(factory), 138 factory_(factory),
138 profile_(profile), 139 profile_(profile),
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 doomed_backend->Shutdown(sync_disabled); 668 doomed_backend->Shutdown(sync_disabled);
668 669
669 doomed_backend.reset(); 670 doomed_backend.reset();
670 } 671 }
671 base::TimeDelta shutdown_time = base::Time::Now() - shutdown_start_time; 672 base::TimeDelta shutdown_time = base::Time::Now() - shutdown_start_time;
672 UMA_HISTOGRAM_TIMES("Sync.Shutdown.BackendDestroyedTime", shutdown_time); 673 UMA_HISTOGRAM_TIMES("Sync.Shutdown.BackendDestroyedTime", shutdown_time);
673 674
674 weak_factory_.InvalidateWeakPtrs(); 675 weak_factory_.InvalidateWeakPtrs();
675 676
676 // Clear various flags. 677 // Clear various flags.
678 start_up_time_ = base::Time();
677 expect_sync_configuration_aborted_ = false; 679 expect_sync_configuration_aborted_ = false;
678 is_auth_in_progress_ = false; 680 is_auth_in_progress_ = false;
679 backend_initialized_ = false; 681 backend_initialized_ = false;
680 // NULL if we're called from Shutdown(). 682 // NULL if we're called from Shutdown().
681 if (invalidator_registrar_) 683 if (invalidator_registrar_)
682 UpdateInvalidatorRegistrarState(); 684 UpdateInvalidatorRegistrarState();
683 cached_passphrase_.clear(); 685 cached_passphrase_.clear();
684 encryption_pending_ = false; 686 encryption_pending_ = false;
685 encrypt_everything_ = false; 687 encrypt_everything_ = false;
686 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes(); 688 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes();
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 } 1162 }
1161 // Trigger an unrecoverable error to stop syncing. 1163 // Trigger an unrecoverable error to stop syncing.
1162 OnInternalUnrecoverableError(FROM_HERE, 1164 OnInternalUnrecoverableError(FROM_HERE,
1163 last_actionable_error_.error_description, 1165 last_actionable_error_.error_description,
1164 true, 1166 true,
1165 ERROR_REASON_ACTIONABLE_ERROR); 1167 ERROR_REASON_ACTIONABLE_ERROR);
1166 break; 1168 break;
1167 case syncer::DISABLE_SYNC_ON_CLIENT: 1169 case syncer::DISABLE_SYNC_ON_CLIENT:
1168 OnStopSyncingPermanently(); 1170 OnStopSyncingPermanently();
1169 break; 1171 break;
1172 case syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT:
1173 // Sync disabled by domain admin. we should stop syncing until
1174 // user signs out and signs in again.
1175 sync_prefs_.SetSyncDisabledByAdmin(true);
1176 DisableForUser();
1177 break;
1170 default: 1178 default:
1171 NOTREACHED(); 1179 NOTREACHED();
1172 } 1180 }
1173 NotifyObservers(); 1181 NotifyObservers();
1174 } 1182 }
1175 1183
1176 void ProfileSyncService::OnConfigureBlocked() { 1184 void ProfileSyncService::OnConfigureBlocked() {
1177 NotifyObservers(); 1185 NotifyObservers();
1178 } 1186 }
1179 1187
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 break; 1924 break;
1917 } 1925 }
1918 case chrome::NOTIFICATION_TOKENS_CLEARED: { 1926 case chrome::NOTIFICATION_TOKENS_CLEARED: {
1919 // GetCredentials() will generate invalid credentials to cause the backend 1927 // GetCredentials() will generate invalid credentials to cause the backend
1920 // to generate an auth error. 1928 // to generate an auth error.
1921 if (backend_) 1929 if (backend_)
1922 backend_->UpdateCredentials(GetCredentials()); 1930 backend_->UpdateCredentials(GetCredentials());
1923 break; 1931 break;
1924 } 1932 }
1925 case chrome::NOTIFICATION_GOOGLE_SIGNED_OUT: 1933 case chrome::NOTIFICATION_GOOGLE_SIGNED_OUT:
1926 // Disable sync if the user is signed out. 1934 // Disable sync if the user is signed out. Clear DisabledByAdmin flag so
1935 // when next time user signs in sync can try to connect to server again.
1936 sync_prefs_.SetSyncDisabledByAdmin(false);
Andrew T Wilson (Slow) 2013/05/14 12:34:01 As I mentioned previously, on ChromeOS the user ne
1927 DisableForUser(); 1937 DisableForUser();
1928 break; 1938 break;
1929 default: { 1939 default: {
1930 NOTREACHED(); 1940 NOTREACHED();
1931 } 1941 }
1932 } 1942 }
1933 } 1943 }
1934 1944
1935 void ProfileSyncService::AddObserver(Observer* observer) { 1945 void ProfileSyncService::AddObserver(Observer* observer) {
1936 observers_.AddObserver(observer); 1946 observers_.AddObserver(observer);
(...skipping 16 matching lines...) Expand all
1953 } 1963 }
1954 1964
1955 // static 1965 // static
1956 bool ProfileSyncService::IsSyncEnabled() { 1966 bool ProfileSyncService::IsSyncEnabled() {
1957 // We have switches::kEnableSync just in case we need to change back to 1967 // We have switches::kEnableSync just in case we need to change back to
1958 // sync-disabled-by-default on a platform. 1968 // sync-disabled-by-default on a platform.
1959 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync); 1969 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync);
1960 } 1970 }
1961 1971
1962 bool ProfileSyncService::IsManaged() const { 1972 bool ProfileSyncService::IsManaged() const {
1963 return sync_prefs_.IsManaged(); 1973 return sync_prefs_.IsManaged() || sync_prefs_.IsSyncDisabledByAdmin();
1964 } 1974 }
1965 1975
1966 bool ProfileSyncService::ShouldPushChanges() { 1976 bool ProfileSyncService::ShouldPushChanges() {
1967 // True only after all bootstrapping has succeeded: the sync backend 1977 // True only after all bootstrapping has succeeded: the sync backend
1968 // is initialized, all enabled data types are consistent with one 1978 // is initialized, all enabled data types are consistent with one
1969 // another, and no unrecoverable error has transpired. 1979 // another, and no unrecoverable error has transpired.
1970 if (HasUnrecoverableError()) 1980 if (HasUnrecoverableError())
1971 return false; 1981 return false;
1972 1982
1973 if (!data_type_manager_) 1983 if (!data_type_manager_)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 2068 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
2059 ProfileSyncService* old_this = this; 2069 ProfileSyncService* old_this = this;
2060 this->~ProfileSyncService(); 2070 this->~ProfileSyncService();
2061 new(old_this) ProfileSyncService( 2071 new(old_this) ProfileSyncService(
2062 new ProfileSyncComponentsFactoryImpl(profile, 2072 new ProfileSyncComponentsFactoryImpl(profile,
2063 CommandLine::ForCurrentProcess()), 2073 CommandLine::ForCurrentProcess()),
2064 profile, 2074 profile,
2065 signin, 2075 signin,
2066 behavior); 2076 behavior);
2067 } 2077 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698