Commit 229b9496 authored by Roger Yang's avatar Roger Yang Committed by mergify[bot]
Browse files

Issue #24301: Add Bookmarks to the search engine menu

parent 666c839e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,8 +33,8 @@ messaging:
      type: string
      description: What should be displayed when a control message is selected.
      enum:
        - show-next-message
        - show-none
        - show-next-message
    styles:
      type: json
      description: "A map of styles to configure message appearance.\n"
+8 −1
Original line number Diff line number Diff line
@@ -199,12 +199,18 @@ class Core(

    val applicationSearchEngines: List<SearchEngine> by lazyMonitored {
        listOf(
            createApplicationSearchEngine(
                id = BOOKMARKS_SEARCH_ENGINE_ID,
                name = context.getString(R.string.library_bookmarks),
                url = "",
                icon = getDrawable(context, R.drawable.ic_bookmarks_search)?.toBitmap()!!,
            ),
            createApplicationSearchEngine(
                id = HISTORY_SEARCH_ENGINE_ID,
                name = context.getString(R.string.library_history),
                url = "",
                icon = getDrawable(context, R.drawable.ic_history_search)?.toBitmap()!!,
            )
            ),
        )
    }

@@ -514,6 +520,7 @@ class Core(
        const val HISTORY_METADATA_MAX_AGE_IN_MS = 14 * 24 * 60 * 60 * 1000 // 14 days
        private const val CONTILE_MAX_CACHE_AGE = 60L // 60 minutes
        const val HISTORY_SEARCH_ENGINE_ID = "history_search_engine_id"
        const val BOOKMARKS_SEARCH_ENGINE_ID = "bookmarks_search_engine_id"

        // Maximum number of suggestions returned from the history search engine source.
        const val METADATA_HISTORY_SUGGESTION_LIMIT = 100
+4 −0
Original line number Diff line number Diff line
@@ -201,6 +201,10 @@ class SearchDialogController(
            searchEngine.type == SearchEngine.Type.APPLICATION && searchEngine.id == Core.HISTORY_SEARCH_ENGINE_ID -> {
                fragmentStore.dispatch(SearchFragmentAction.SearchHistoryEngineSelected(searchEngine))
            }
            searchEngine.type == SearchEngine.Type.APPLICATION
                && searchEngine.id == Core.BOOKMARKS_SEARCH_ENGINE_ID -> {
                fragmentStore.dispatch(SearchFragmentAction.SearchBookmarksEngineSelected(searchEngine))
            }
            searchEngine == store.state.search.selectedOrDefaultSearchEngine -> {
                fragmentStore.dispatch(SearchFragmentAction.SearchDefaultEngineSelected(searchEngine, settings))
            }
+21 −0
Original line number Diff line number Diff line
@@ -56,6 +56,11 @@ sealed class SearchEngineSource {
     * Search engine for history
     */
    data class History(override val searchEngine: SearchEngine) : SearchEngineSource()

    /**
     * Search engine for bookmarks
     */
    data class Bookmarks(override val searchEngine: SearchEngine) : SearchEngineSource()
}

/**
@@ -170,6 +175,11 @@ sealed class SearchFragmentAction : Action {
     */
    data class SearchHistoryEngineSelected(val engine: SearchEngine) : SearchFragmentAction()

    /**
     * Action when bookmarks search engine is selected.
     */
    data class SearchBookmarksEngineSelected(val engine: SearchEngine) : SearchFragmentAction()

    /**
     * Action when search engine picker is selected.
     */
@@ -250,6 +260,17 @@ private fun searchStateReducer(state: SearchFragmentState, action: SearchFragmen
                showSyncedTabsSuggestions = false,
                showSessionSuggestions = false,
            )
        is SearchFragmentAction.SearchBookmarksEngineSelected ->
            state.copy(
                searchEngineSource = SearchEngineSource.Bookmarks(action.engine),
                showSearchSuggestions = false,
                showSearchShortcuts = false,
                showClipboardSuggestions = false,
                showHistorySuggestions = false,
                showBookmarkSuggestions = true,
                showSyncedTabsSuggestions = false,
                showSessionSuggestions = false,
            )
        is SearchFragmentAction.ShowSearchShortcutEnginePicker ->
            state.copy(showSearchShortcuts = action.show && state.areShortcutsAvailable)
        is SearchFragmentAction.UpdateQuery ->
+1 −0
Original line number Diff line number Diff line
@@ -284,6 +284,7 @@ class AwesomeBarView(
                state.searchEngineSource.searchEngine
            )
            is SearchEngineSource.History -> emptyList()
            is SearchEngineSource.Bookmarks -> emptyList()
            is SearchEngineSource.None -> emptyList()
        }
    }
Loading