pref_model_associator_client.h 1.9 KB

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