Upload upstream chromium 73.0.3683.0
[platform/framework/web/chromium-efl.git] / components / sync_preferences / pref_model_associator_client.h
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.
4
5 #ifndef COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_CLIENT_H_
6 #define COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_CLIENT_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11 #include "base/values.h"
12
13 namespace sync_preferences {
14
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 {
19  public:
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;
24
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;
29
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;
38
39  protected:
40   PrefModelAssociatorClient() {}
41   virtual ~PrefModelAssociatorClient() {}
42
43  private:
44   DISALLOW_COPY_AND_ASSIGN(PrefModelAssociatorClient);
45 };
46
47 }  // namespace sync_preferences
48
49 #endif  // COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_CLIENT_H_