Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors |
Angela Yoeurng | 2400626 | 2022-04-12 19:40:09 | [diff] [blame] | 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_SEARCH_ENGINES_TEMPLATE_URL_STARTER_PACK_DATA_H_ |
| 6 | #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_STARTER_PACK_DATA_H_ |
| 7 | |
Stephan Hartmann | aca38ff | 2022-04-13 20:09:49 | [diff] [blame] | 8 | #include <memory> |
Angela Yoeurng | 3fad185 | 2022-06-02 00:30:26 | [diff] [blame] | 9 | #include <string> |
Angela Yoeurng | 2400626 | 2022-04-12 19:40:09 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
Angela Yoeurng | 75ef818 | 2022-04-18 23:39:22 | [diff] [blame] | 12 | #include "components/search_engines/search_engine_type.h" |
| 13 | |
Angela Yoeurng | 2400626 | 2022-04-12 19:40:09 | [diff] [blame] | 14 | struct TemplateURLData; |
| 15 | |
| 16 | // The Starter Pack is a set of built-in search engines that allow the user to |
| 17 | // search various parts of Chrome from the Omnibox through keyword mode. Unlike |
| 18 | // prepopulated engines, starter pack scopes are not "search engines" that |
| 19 | // search the web. Instead, they use the built-in omnibox providers to provide |
| 20 | // suggestions. This file defines those search engines and util functions. |
| 21 | |
| 22 | namespace TemplateURLStarterPackData { |
| 23 | |
Angela Yoeurng | 638e240 | 2022-05-18 00:25:07 | [diff] [blame] | 24 | typedef enum { |
| 25 | kBookmarks = 1, |
| 26 | kHistory = 2, |
Angela Yoeurng | 19a6afa | 2022-06-09 16:32:44 | [diff] [blame] | 27 | kTabs = 3, |
Angela Yoeurng | e6c2ed3d | 2024-08-29 22:26:21 | [diff] [blame] | 28 | kGemini = 4, |
Orin Jaworski | 769e4e9 | 2025-03-04 17:11:04 | [diff] [blame] | 29 | kPage = 5, |
Angela Yoeurng | 638e240 | 2022-05-18 00:25:07 | [diff] [blame] | 30 | |
| 31 | kMaxStarterPackID |
| 32 | } StarterPackID; |
| 33 | |
Angela Yoeurng | 2400626 | 2022-04-12 19:40:09 | [diff] [blame] | 34 | struct StarterPackEngine { |
| 35 | int name_message_id; |
| 36 | int keyword_message_id; |
| 37 | const char* const favicon_url; |
| 38 | const char* const search_url; |
Angela Yoeurng | 3fad185 | 2022-06-02 00:30:26 | [diff] [blame] | 39 | const char* const destination_url; |
Angela Yoeurng | 638e240 | 2022-05-18 00:25:07 | [diff] [blame] | 40 | const StarterPackID id; |
Angela Yoeurng | 75ef818 | 2022-04-18 23:39:22 | [diff] [blame] | 41 | const SearchEngineType type; |
Angela Yoeurng | 2400626 | 2022-04-12 19:40:09 | [diff] [blame] | 42 | }; |
| 43 | |
Angela Yoeurng | 2400626 | 2022-04-12 19:40:09 | [diff] [blame] | 44 | extern const int kCurrentDataVersion; |
Angela Yoeurng | d164d89d | 2022-07-27 01:25:43 | [diff] [blame] | 45 | extern const int kFirstCompatibleDataVersion; |
Angela Yoeurng | 2400626 | 2022-04-12 19:40:09 | [diff] [blame] | 46 | |
Angela Yoeurng | d164d89d | 2022-07-27 01:25:43 | [diff] [blame] | 47 | // Exposed for testing purposes |
Angela Yoeurng | 10424ca | 2022-05-19 01:46:46 | [diff] [blame] | 48 | extern const StarterPackEngine bookmarks; |
| 49 | extern const StarterPackEngine history; |
Angela Yoeurng | 19a6afa | 2022-06-09 16:32:44 | [diff] [blame] | 50 | extern const StarterPackEngine tabs; |
Angela Yoeurng | e6c2ed3d | 2024-08-29 22:26:21 | [diff] [blame] | 51 | extern const StarterPackEngine Gemini; |
Orin Jaworski | 769e4e9 | 2025-03-04 17:11:04 | [diff] [blame] | 52 | extern const StarterPackEngine page; |
Angela Yoeurng | 10424ca | 2022-05-19 01:46:46 | [diff] [blame] | 53 | |
Angela Yoeurng | 2400626 | 2022-04-12 19:40:09 | [diff] [blame] | 54 | // Returns the current version of the starterpack data, so callers can know when |
| 55 | // they need to re-merge. |
| 56 | int GetDataVersion(); |
| 57 | |
Angela Yoeurng | d164d89d | 2022-07-27 01:25:43 | [diff] [blame] | 58 | // Returns the first compatible data version to the current data. Any starter |
| 59 | // pack data version before this will be force updated regardless of user edits. |
| 60 | int GetFirstCompatibleDataVersion(); |
| 61 | |
Angela Yoeurng | 2400626 | 2022-04-12 19:40:09 | [diff] [blame] | 62 | // Returns a vector of all starter pack engines, in TemplateURLData format. |
| 63 | std::vector<std::unique_ptr<TemplateURLData>> GetStarterPackEngines(); |
| 64 | |
Angela Yoeurng | 3fad185 | 2022-06-02 00:30:26 | [diff] [blame] | 65 | // Returns the destination url for the starter pack engine associated with a |
| 66 | // given starter pack id. |
| 67 | std::u16string GetDestinationUrlForStarterPackID(int id); |
| 68 | |
Angela Yoeurng | 2400626 | 2022-04-12 19:40:09 | [diff] [blame] | 69 | } // namespace TemplateURLStarterPackData |
| 70 | |
| 71 | #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_STARTER_PACK_DATA_H_ |