blob: eabb3af6092195434a5cb9ceb546507d9cf5145d (
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
|
// Copyright 2018 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_NTP_TILES_CUSTOM_LINKS_STORE_H_
#define COMPONENTS_NTP_TILES_CUSTOM_LINKS_STORE_H_
#include <vector>
#include "components/ntp_tiles/custom_links_manager.h"
class PrefService;
namespace user_prefs {
class PrefRegistrySyncable;
} // namespace user_prefs
namespace ntp_tiles {
// A helper class for reading and writing custom links to the profile's
// preference file. All virtual functions are for testing.
class CustomLinksStore {
public:
explicit CustomLinksStore(PrefService* prefs);
// Virtual for testing.
virtual ~CustomLinksStore();
// Retrieves the custom link data from the profile's preferences and returns
// them as a list of |Link|s. If there is a problem with retrieval, the pref
// value is cleared and an empty list is returned.
// Virtual for testing.
virtual std::vector<CustomLinksManager::Link> RetrieveLinks();
// Stores the provided |links| to the profile's preferences.
// Virtual for testing.
virtual void StoreLinks(const std::vector<CustomLinksManager::Link>& links);
// Clears any custom link data from the profile's preferences.
// Virtual for testing.
virtual void ClearLinks();
// Register CustomLinksStore related prefs in the Profile prefs.
static void RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* user_prefs);
private:
// The pref service used to persist the custom link data.
PrefService* prefs_;
DISALLOW_COPY_AND_ASSIGN(CustomLinksStore);
};
} // namespace ntp_tiles
#endif // COMPONENTS_NTP_TILES_CUSTOM_LINKS_STORE_H_
|