chromium/ios/chrome/browser/bookmarks/ui_bundled/home/synced_bookmarks_bridge.mm

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "ios/chrome/browser/bookmarks/ui_bundled/home/synced_bookmarks_bridge.h"

#import "base/memory/weak_ptr.h"
#import "components/signin/public/identity_manager/identity_manager.h"
#import "components/sync/service/sync_service.h"
#import "ios/chrome/browser/shared/model/profile/profile_ios.h"
#import "ios/chrome/browser/signin/model/identity_manager_factory.h"
#import "ios/chrome/browser/sync/model/sync_service_factory.h"

namespace sync_bookmarks {

#pragma mark - SyncedBookmarksObserverBridge

SyncedBookmarksObserverBridge::SyncedBookmarksObserverBridge(
    id<SyncObserverModelBridge> delegate,
    ChromeBrowserState* browserState)
    : SyncObserverBridge(delegate,
                         SyncServiceFactory::GetForBrowserState(browserState)),
      identity_manager_(
          IdentityManagerFactory::GetForBrowserState(browserState)),
      browser_state_(browserState->AsWeakPtr()) {}

SyncedBookmarksObserverBridge::~SyncedBookmarksObserverBridge() {}

#pragma mark - Signin and syncing status

bool SyncedBookmarksObserverBridge::IsPerformingInitialSync() {
  CHECK(browser_state_.get());
  syncer::SyncService* sync_service =
      SyncServiceFactory::GetForBrowserState(browser_state_.get());

  return sync_service->GetTypesWithPendingDownloadForInitialSync().Has(
      syncer::BOOKMARKS);
}

}  // namespace sync_bookmarks