template_url_starter_pack_data.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2022 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_STARTER_PACK_DATA_H_
  5. #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_STARTER_PACK_DATA_H_
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "components/search_engines/search_engine_type.h"
  10. struct TemplateURLData;
  11. // The Starter Pack is a set of built-in search engines that allow the user to
  12. // search various parts of Chrome from the Omnibox through keyword mode. Unlike
  13. // prepopulated engines, starter pack scopes are not "search engines" that
  14. // search the web. Instead, they use the built-in omnibox providers to provide
  15. // suggestions. This file defines those search engines and util functions.
  16. namespace TemplateURLStarterPackData {
  17. typedef enum {
  18. kBookmarks = 1,
  19. kHistory = 2,
  20. kTabs = 3,
  21. kMaxStarterPackID
  22. } StarterPackID;
  23. struct StarterPackEngine {
  24. int name_message_id;
  25. int keyword_message_id;
  26. const char* const favicon_url;
  27. const char* const search_url;
  28. const char* const destination_url;
  29. const StarterPackID id;
  30. const SearchEngineType type;
  31. };
  32. extern const int kCurrentDataVersion;
  33. extern const int kFirstCompatibleDataVersion;
  34. // Exposed for testing purposes
  35. extern const StarterPackEngine bookmarks;
  36. extern const StarterPackEngine history;
  37. extern const StarterPackEngine tabs;
  38. // Returns the current version of the starterpack data, so callers can know when
  39. // they need to re-merge.
  40. int GetDataVersion();
  41. // Returns the first compatible data version to the current data. Any starter
  42. // pack data version before this will be force updated regardless of user edits.
  43. int GetFirstCompatibleDataVersion();
  44. // Returns a vector of all starter pack engines, in TemplateURLData format.
  45. std::vector<std::unique_ptr<TemplateURLData>> GetStarterPackEngines();
  46. // Returns the destination url for the starter pack engine associated with a
  47. // given starter pack id.
  48. std::u16string GetDestinationUrlForStarterPackID(int id);
  49. } // namespace TemplateURLStarterPackData
  50. #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_STARTER_PACK_DATA_H_