1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/search_engines/template_url_starter_pack_data.h"
#include "base/strings/utf_string_conversions.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/search_engines/search_engine_type.h"
#include "components/search_engines/template_url_data.h"
#include "components/search_engines/template_url_data_util.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
namespace TemplateURLStarterPackData {
// Update this whenever a change is made to any starter pack data.
const int kCurrentDataVersion = 12;
// Only update this if there's an incompatible change that requires force
// updating the user's starter pack data. This will overwrite any of the
// user's changes to the starter pack entries.
const int kFirstCompatibleDataVersion = 10;
const StarterPackEngine bookmarks = {
.name_message_id = IDS_SEARCH_ENGINES_STARTER_PACK_BOOKMARKS_NAME,
.keyword_message_id = IDS_SEARCH_ENGINES_STARTER_PACK_BOOKMARKS_KEYWORD,
.favicon_url = nullptr,
.search_url = "chrome://bookmarks/?q={searchTerms}",
.destination_url = "chrome://bookmarks",
.id = StarterPackID::kBookmarks,
.type = SEARCH_ENGINE_STARTER_PACK_BOOKMARKS,
};
const StarterPackEngine history = {
.name_message_id = IDS_SEARCH_ENGINES_STARTER_PACK_HISTORY_NAME,
.keyword_message_id = IDS_SEARCH_ENGINES_STARTER_PACK_HISTORY_KEYWORD,
.favicon_url = nullptr,
.search_url = "chrome://history/?q={searchTerms}",
.destination_url = "chrome://history",
.id = StarterPackID::kHistory,
.type = SEARCH_ENGINE_STARTER_PACK_HISTORY,
};
const StarterPackEngine tabs = {
.name_message_id = IDS_SEARCH_ENGINES_STARTER_PACK_TABS_NAME,
.keyword_message_id = IDS_SEARCH_ENGINES_STARTER_PACK_TABS_KEYWORD,
.favicon_url = nullptr,
// This search_url is a placeholder URL to make templateURL happy.
// chrome://tabs does not currently exist and the tab search engine will
// only provide suggestions from the OpenTabProvider.
.search_url = "chrome://tabs/?q={searchTerms}",
.destination_url = "http://support.google.com/chrome/?p=tab_search",
.id = StarterPackID::kTabs,
.type = SEARCH_ENGINE_STARTER_PACK_TABS,
};
const StarterPackEngine Gemini = {
.name_message_id = IDS_SEARCH_ENGINES_STARTER_PACK_GEMINI_NAME,
.keyword_message_id = IDS_SEARCH_ENGINES_STARTER_PACK_GEMINI_KEYWORD,
.favicon_url = nullptr,
.search_url = "https://gemini.google.com/app?q={searchTerms}",
.destination_url = "https://gemini.google.com",
.id = StarterPackID::kGemini,
.type = SEARCH_ENGINE_STARTER_PACK_GEMINI,
};
const StarterPackEngine page = {
.name_message_id = IDS_SEARCH_ENGINES_STARTER_PACK_PAGE_NAME,
.keyword_message_id = IDS_SEARCH_ENGINES_STARTER_PACK_PAGE_KEYWORD,
.favicon_url = nullptr,
.search_url = "chrome://page/?q={searchTerms}",
.destination_url = "chrome://page",
.id = StarterPackID::kPage,
.type = SEARCH_ENGINE_STARTER_PACK_PAGE,
};
const StarterPackEngine* engines[] = {
&bookmarks, &history, &tabs, &Gemini, &page,
};
int GetDataVersion() {
return kCurrentDataVersion;
}
int GetFirstCompatibleDataVersion() {
return kFirstCompatibleDataVersion;
}
std::vector<std::unique_ptr<TemplateURLData>> GetStarterPackEngines() {
std::vector<std::unique_ptr<TemplateURLData>> t_urls;
for (auto* engine : engines) {
t_urls.push_back(TemplateURLDataFromStarterPackEngine(*engine));
}
return t_urls;
}
std::u16string GetDestinationUrlForStarterPackID(int id) {
for (auto* engine : engines) {
if (engine->id == id) {
return base::UTF8ToUTF16(engine->destination_url);
}
}
return u"";
}
} // namespace TemplateURLStarterPackData
|