maxbogue | 93150a5d | 2015-08-31 21:08:32 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
maxbogue | 455a57e3 | 2016-08-14 00:08:32 | [diff] [blame] | 5 | #include "components/sync/driver/sync_service.h" |
maxbogue | 93150a5d | 2015-08-31 21:08:32 | [diff] [blame] | 6 | |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 7 | namespace syncer { |
maxbogue | 93150a5d | 2015-08-31 21:08:32 | [diff] [blame] | 8 | |
tommycli | f3a1551e | 2016-06-21 18:11:23 | [diff] [blame] | 9 | SyncSetupInProgressHandle::SyncSetupInProgressHandle(base::Closure on_destroy) |
| 10 | : on_destroy_(on_destroy) {} |
| 11 | |
| 12 | SyncSetupInProgressHandle::~SyncSetupInProgressHandle() { |
| 13 | on_destroy_.Run(); |
| 14 | } |
| 15 | |
Marc Treib | db1e1a0f | 2018-07-07 15:30:48 | [diff] [blame] | 16 | bool SyncService::CanSyncStart() const { |
Marc Treib | 6a2be53 | 2018-07-16 18:30:15 | [diff] [blame] | 17 | return GetDisableReasons() == DISABLE_REASON_NONE; |
Marc Treib | db1e1a0f | 2018-07-07 15:30:48 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | bool SyncService::IsSyncAllowed() const { |
| 21 | return !HasDisableReason(DISABLE_REASON_PLATFORM_OVERRIDE) && |
| 22 | !HasDisableReason(DISABLE_REASON_ENTERPRISE_POLICY); |
| 23 | } |
| 24 | |
Marc Treib | 9470244 | 2018-07-19 09:04:43 | [diff] [blame] | 25 | bool SyncService::IsSyncActive() const { |
| 26 | State state = GetState(); |
| 27 | return state == State::CONFIGURING || state == State::ACTIVE; |
| 28 | } |
| 29 | |
Marc Treib | 2eac56fd | 2018-07-20 13:29:33 | [diff] [blame^] | 30 | bool SyncService::IsFirstSetupInProgress() const { |
| 31 | return !IsFirstSetupComplete() && IsSetupInProgress(); |
| 32 | } |
| 33 | |
Marc Treib | db1e1a0f | 2018-07-07 15:30:48 | [diff] [blame] | 34 | bool SyncService::HasUnrecoverableError() const { |
| 35 | return HasDisableReason(DISABLE_REASON_UNRECOVERABLE_ERROR); |
| 36 | } |
| 37 | |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 38 | } // namespace syncer |