summaryrefslogtreecommitdiffstats
path: root/components/sync_driver/sync_client.h
blob: 9db65bf2c3d6a56945340a2436711091ad503ac1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_
#define COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_

#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "components/sync_driver/profile_sync_components_factory.h"
#include "sync/internal_api/public/base/model_type.h"

namespace autofill {
class AutofillWebDataService;
class AutocompleteSyncableService;
class PersonalDataManager;
}  // namespace autofill

namespace bookmarks {
class BookmarkModel;
}  // namespace bookmarks

namespace history {
class HistoryService;
}  // namespace history

namespace password_manager {
class PasswordStore;
}  // namespace password_manager

class PrefService;

namespace sync_driver {

// Interface for clients of the Sync API to plumb through necessary dependent
// components. This interface is purely for abstracting dependencies, and
// should not contain any non-trivial functional logic.
//
// Note: on some platforms, getters might return nullptr. Callers are expected
// to handle these scenarios gracefully.
// TODO(zea): crbug.com/512768 Remove the ProfileSyncComponentsFactory
// dependency once everything uses SyncClient instead, then have the SyncClient
// include a GetSyncApiComponentsFactory getter.
class SyncClient : public ProfileSyncComponentsFactory {
 public:
  SyncClient();

  // Returns the current profile's preference service.
  virtual PrefService* GetPrefService() = 0;

  // DataType specific service getters.
  virtual bookmarks::BookmarkModel* GetBookmarkModel() = 0;
  virtual history::HistoryService* GetHistoryService() = 0;
  virtual scoped_refptr<password_manager::PasswordStore> GetPasswordStore() = 0;
  virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0;
  virtual scoped_refptr<autofill::AutofillWebDataService>
  GetWebDataService() = 0;

 protected:
  ~SyncClient() override;

 private:
  DISALLOW_COPY_AND_ASSIGN(SyncClient);
};

}  // namespace sync_driver

#endif  // COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_