blob: eabb3af6092195434a5cb9ceb546507d9cf5145d [file] [log] [blame]
// 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.
#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 {
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);
// The pref service used to persist the custom link data.
PrefService* prefs_;
} // namespace ntp_tiles