chromium/chrome/browser/ui/webui/searchbox/realbox_handler.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/webui/searchbox/realbox_handler.h"

#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
#include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/predictors/autocomplete_action_predictor.h"
#include "chrome/browser/predictors/autocomplete_action_predictor_factory.h"
#include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service.h"
#include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/bookmarks/bookmark_stats.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/omnibox/omnibox_pedal_implementations.h"
#include "chrome/browser/ui/search/omnibox_utils.h"
#include "chrome/browser/ui/webui/metrics_reporter/metrics_reporter.h"
#include "chrome/browser/ui/webui/searchbox/lens_searchbox_client.h"
#include "chrome/grit/new_tab_page_resources.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/navigation_metrics/navigation_metrics.h"
#include "components/omnibox/browser/autocomplete_classifier.h"
#include "components/omnibox/browser/autocomplete_controller_emitter.h"
#include "components/omnibox/browser/autocomplete_input.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/autocomplete_match_type.h"
#include "components/omnibox/browser/autocomplete_result.h"
#include "components/omnibox/browser/omnibox_client.h"
#include "components/omnibox/browser/omnibox_controller.h"
#include "components/omnibox/browser/omnibox_edit_model.h"
#include "components/omnibox/browser/omnibox_event_global_tracker.h"
#include "components/omnibox/browser/omnibox_log.h"
#include "components/omnibox/browser/omnibox_prefs.h"
#include "components/omnibox/browser/omnibox_view.h"
#include "components/omnibox/browser/search_suggestion_parser.h"
#include "components/omnibox/browser/suggestion_answer.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/prefs/pref_service.h"
#include "components/profile_metrics/browser_profile_type.h"
#include "components/search_engines/template_url_service.h"
#include "components/sessions/content/session_tab_helper.h"
#include "components/strings/grit/components_strings.h"
#include "net/cookies/cookie_util.h"
#include "third_party/metrics_proto/omnibox_focus_type.pb.h"
#include "third_party/omnibox_proto/types.pb.h"
#include "ui/base/webui/resource_path.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/base/window_open_disposition_utils.h"

namespace {
// TODO(crbug.com/40263573): Consider inheriting from `ChromeOmniboxClient`
//  to avoid reimplementation of methods like `OnBookmarkLaunched`.
class RealboxOmniboxClient final : public OmniboxClient {};

RealboxOmniboxClient::RealboxOmniboxClient(
    Profile* profile,
    content::WebContents* web_contents,
    LensSearchboxClient* lens_searchbox_client)
    :{}

RealboxOmniboxClient::~RealboxOmniboxClient() = default;

std::unique_ptr<AutocompleteProviderClient>
RealboxOmniboxClient::CreateAutocompleteProviderClient() {}

const GURL& RealboxOmniboxClient::GetURL() const {}

bool RealboxOmniboxClient::IsPasteAndGoEnabled() const {}

SessionID RealboxOmniboxClient::GetSessionID() const {}

PrefService* RealboxOmniboxClient::GetPrefs() {}

bookmarks::BookmarkModel* RealboxOmniboxClient::GetBookmarkModel() {}

AutocompleteControllerEmitter*
RealboxOmniboxClient::GetAutocompleteControllerEmitter() {}

TemplateURLService* RealboxOmniboxClient::GetTemplateURLService() {}

const AutocompleteSchemeClassifier& RealboxOmniboxClient::GetSchemeClassifier()
    const {}

AutocompleteClassifier* RealboxOmniboxClient::GetAutocompleteClassifier() {}

bool RealboxOmniboxClient::ShouldDefaultTypedNavigationsToHttps() const {}

int RealboxOmniboxClient::GetHttpsPortForTesting() const {}

bool RealboxOmniboxClient::IsUsingFakeHttpsForHttpsUpgradeTesting() const {}

gfx::Image RealboxOmniboxClient::GetSizedIcon(
    const gfx::VectorIcon& vector_icon_type,
    SkColor vector_icon_color) const {}

std::u16string RealboxOmniboxClient::GetFormattedFullURL() const {}

std::u16string RealboxOmniboxClient::GetURLForDisplay() const {}

GURL RealboxOmniboxClient::GetNavigationEntryURL() const {}

metrics::OmniboxEventProto::PageClassification
RealboxOmniboxClient::GetPageClassification(bool is_prefetch) {}

security_state::SecurityLevel RealboxOmniboxClient::GetSecurityLevel() const {}

net::CertStatus RealboxOmniboxClient::GetCertStatus() const {}

const gfx::VectorIcon& RealboxOmniboxClient::GetVectorIcon() const {}

gfx::Image RealboxOmniboxClient::GetFaviconForPageUrl(
    const GURL& page_url,
    FaviconFetchedCallback on_favicon_fetched) {}

std::optional<lens::proto::LensOverlayInteractionResponse>
    RealboxOmniboxClient::GetLensOverlayInteractionResponse() const {}

void RealboxOmniboxClient::OnBookmarkLaunched() {}

void RealboxOmniboxClient::OnURLOpenedFromOmnibox(OmniboxLog* log) {}

void RealboxOmniboxClient::OnAutocompleteAccept(
    const GURL& destination_url,
    TemplateURLRef::PostContent* post_content,
    WindowOpenDisposition disposition,
    ui::PageTransition transition,
    AutocompleteMatchType::Type match_type,
    base::TimeTicks match_selection_timestamp,
    bool destination_url_entered_without_scheme,
    bool destination_url_entered_with_http_scheme,
    const std::u16string& text,
    const AutocompleteMatch& match,
    const AutocompleteMatch& alternative_nav_match,
    IDNA2008DeviationCharacter deviation_char_in_hostname) {}

base::WeakPtr<OmniboxClient> RealboxOmniboxClient::AsWeakPtr() {}

}  // namespace

RealboxHandler::RealboxHandler(
    mojo::PendingReceiver<searchbox::mojom::PageHandler> pending_page_handler,
    Profile* profile,
    content::WebContents* web_contents,
    MetricsReporter* metrics_reporter,
    LensSearchboxClient* lens_searchbox_client,
    OmniboxController* omnibox_controller)
    :{}

RealboxHandler::~RealboxHandler() = default;

bool RealboxHandler::IsRemoteBound() const {}

void RealboxHandler::AddObserver(OmniboxWebUIPopupChangeObserver* observer) {}

void RealboxHandler::RemoveObserver(OmniboxWebUIPopupChangeObserver* observer) {}

bool RealboxHandler::HasObserver(
    const OmniboxWebUIPopupChangeObserver* observer) const {}

void RealboxHandler::SetPage(
    mojo::PendingRemote<searchbox::mojom::Page> pending_page) {}

void RealboxHandler::OnFocusChanged(bool focused) {}

void RealboxHandler::QueryAutocomplete(const std::u16string& input,
                                       bool prevent_inline_autocomplete) {}

void RealboxHandler::StopAutocomplete(bool clear_result) {}

void RealboxHandler::OpenAutocompleteMatch(uint8_t line,
                                           const GURL& url,
                                           bool are_matches_showing,
                                           uint8_t mouse_button,
                                           bool alt_key,
                                           bool ctrl_key,
                                           bool meta_key,
                                           bool shift_key) {}

void RealboxHandler::OnNavigationLikely(
    uint8_t line,
    const GURL& url,
    omnibox::mojom::NavigationPredictor navigation_predictor) {}

void RealboxHandler::OnThumbnailRemoved() {}

void RealboxHandler::PopupElementSizeChanged(const gfx::Size& size) {}

void RealboxHandler::DeleteAutocompleteMatch(uint8_t line, const GURL& url) {}

void RealboxHandler::ToggleSuggestionGroupIdVisibility(
    int32_t suggestion_group_id) {}

void RealboxHandler::ExecuteAction(uint8_t line,
                                   uint8_t action_index,
                                   const GURL& url,
                                   base::TimeTicks match_selection_timestamp,
                                   uint8_t mouse_button,
                                   bool alt_key,
                                   bool ctrl_key,
                                   bool meta_key,
                                   bool shift_key) {}

searchbox::mojom::SelectionLineState ConvertLineState(
    OmniboxPopupSelection::LineState state) {}

void RealboxHandler::SetInputText(const std::string& input_text) {}

void RealboxHandler::SetThumbnail(const std::string& thumbnail_url) {}

void RealboxHandler::UpdateSelection(OmniboxPopupSelection old_selection,
                                     OmniboxPopupSelection selection) {}

void RealboxHandler::SetLensSearchboxClientForTesting(
    LensSearchboxClient* lens_searchbox_client) {}

OmniboxEditModel* RealboxHandler::edit_model() const {}

const AutocompleteMatch* RealboxHandler::GetMatchWithUrl(size_t index,
                                                         const GURL& url) {}