refactor(3): VideoDownloader.Browser library - tabs/find/search-engine/zoom/bookmark-history stores extracted from App (66 GREEN)
This commit is contained in:
parent
6df9f81b4a
commit
e8ec1350b3
20 changed files with 63 additions and 31 deletions
34
VideoDownloader.Browser/SearchEngine.cs
Normal file
34
VideoDownloader.Browser/SearchEngine.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
namespace VideoDownloader.Browser;
|
||||
|
||||
/// <summary>검색엔진 정의. QueryTemplate 의 {0} 이 URL 인코딩된 검색어로 치환된다.</summary>
|
||||
public sealed record SearchEngine(string Name, string Keyword, string QueryTemplate);
|
||||
|
||||
/// <summary>기본 프리셋 엔진. Keyword 는 주소창에서 `<키워드> <검색어>` 형태로 즉시 전환에 쓰인다.</summary>
|
||||
public static class SearchEngines
|
||||
{
|
||||
public static readonly IReadOnlyList<SearchEngine> Presets = new[]
|
||||
{
|
||||
new SearchEngine("Google", "g", "https://www.google.com/search?q={0}"),
|
||||
new SearchEngine("Bing", "b", "https://www.bing.com/search?q={0}"),
|
||||
new SearchEngine("DuckDuckGo", "d", "https://duckduckgo.com/?q={0}"),
|
||||
new SearchEngine("Naver", "n", "https://search.naver.com/search.naver?query={0}"),
|
||||
new SearchEngine("YouTube", "yt", "https://www.youtube.com/results?search_query={0}"),
|
||||
};
|
||||
|
||||
public static SearchEngine? FindByName(string? name, IEnumerable<SearchEngine>? extra = null)
|
||||
{
|
||||
var pool = extra != null ? Presets.Concat(extra) : Presets;
|
||||
return pool.FirstOrDefault(e =>
|
||||
string.Equals(e.Name, name, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public static SearchEngine? FindByKeyword(string? keyword, IEnumerable<SearchEngine>? extra = null)
|
||||
{
|
||||
var pool = extra != null ? Presets.Concat(extra) : Presets;
|
||||
return pool.FirstOrDefault(e =>
|
||||
string.Equals(e.Keyword, keyword, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>주소창 입력에 대한 네비게이션 의도. IsUrl=false 면 Target 은 검색 결과 URL.</summary>
|
||||
public sealed record NavigationIntent(bool IsUrl, string Target, string? EngineName = null);
|
||||
Loading…
Add table
Add a link
Reference in a new issue