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.
5 #ifndef COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_CLIENT_H_
6 #define COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_CLIENT_H_
10 #include "base/macros.h"
11 #include "base/values.h"
13 namespace sync_preferences {
15 // This class allows the embedder to configure the PrefModelAssociator to
16 // have a different behaviour when receiving preference synchronisations
17 // events from the server.
18 class PrefModelAssociatorClient {
20 // Returns true if the preference named |pref_name| is a list preference
21 // whose server value is merged with local value during synchronisation.
22 virtual bool IsMergeableListPreference(
23 const std::string& pref_name) const = 0;
25 // Returns true if the preference named |pref_name| is a dictionary preference
26 // whose server value is merged with local value during synchronisation.
27 virtual bool IsMergeableDictionaryPreference(
28 const std::string& pref_name) const = 0;
30 // Returns the merged value if the client wants to apply a custom merging
31 // strategy to the preference named |pref_name| with local value |local_value|
32 // and server-provided value |server_value|. Otherwise, returns |nullptr| and
33 // the server's value will be chosen.
34 virtual std::unique_ptr<base::Value> MaybeMergePreferenceValues(
35 const std::string& pref_name,
36 const base::Value& local_value,
37 const base::Value& server_value) const = 0;
40 PrefModelAssociatorClient() {}
41 virtual ~PrefModelAssociatorClient() {}
44 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociatorClient);
47 } // namespace sync_preferences
49 #endif // COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_CLIENT_H_