template_url_data_util.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2016 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_SEARCH_ENGINES_TEMPLATE_URL_DATA_UTIL_H_
  5. #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_UTIL_H_
  6. #include <memory>
  7. #include <base/values.h>
  8. namespace TemplateURLPrepopulateData {
  9. struct PrepopulatedEngine;
  10. }
  11. namespace TemplateURLStarterPackData {
  12. struct StarterPackEngine;
  13. }
  14. struct TemplateURLData;
  15. // Deserializes a TemplateURLData from |dict|.
  16. std::unique_ptr<TemplateURLData> TemplateURLDataFromDictionary(
  17. const base::Value::Dict& dict);
  18. // Serializes a TemplateURLData to |dict|.
  19. std::unique_ptr<base::DictionaryValue> TemplateURLDataToDictionary(
  20. const TemplateURLData& turl_data);
  21. // Create TemplateURLData structure from PrepopulatedEngine structure.
  22. std::unique_ptr<TemplateURLData> TemplateURLDataFromPrepopulatedEngine(
  23. const TemplateURLPrepopulateData::PrepopulatedEngine& engine);
  24. // Deserializes a TemplateURLData from |dict| as stored in
  25. // kSearchProviderOverrides pref. The field names in |dict| differ from those
  26. // used in the To/FromDictionary functions above for historical reasons.
  27. // TODO(a-v-y) Migrate to single TemplateURLData serialization format.
  28. std::unique_ptr<TemplateURLData> TemplateURLDataFromOverrideDictionary(
  29. const base::Value& engine);
  30. // Creates a TemplateURLData structure from a StarterPackEngine struct.
  31. std::unique_ptr<TemplateURLData> TemplateURLDataFromStarterPackEngine(
  32. const TemplateURLStarterPackData::StarterPackEngine& engine);
  33. #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_UTIL_H_