#include "chrome/browser/ui/omnibox/chrome_omnibox_client.h"
#include <stddef.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.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 "base/trace_event/typed_macros.h"
#include "chrome/app/chrome_command_ids.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/autocomplete/shortcuts_backend_factory.h"
#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/extensions/api/omnibox/omnibox_api.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/feedback/public/feedback_source.h"
#include "chrome/browser/feedback/show_feedback_page.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/predictors/autocomplete_action_predictor.h"
#include "chrome/browser/predictors/autocomplete_action_predictor_factory.h"
#include "chrome/browser/predictors/loading_predictor.h"
#include "chrome/browser/predictors/loading_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/preloading/prerender/prerender_manager.h"
#include "chrome/browser/preloading/prerender/prerender_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ssl/typed_navigation_upgrade_throttle.h"
#include "chrome/browser/ui/bookmarks/bookmark_stats.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/omnibox/chrome_omnibox_navigation_observer.h"
#include "chrome/browser/ui/omnibox/omnibox_tab_helper.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/favicon/content/content_favicon_driver.h"
#include "components/favicon/core/favicon_service.h"
#include "components/omnibox/browser/autocomplete_controller_emitter.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/autocomplete_result.h"
#include "components/omnibox/browser/base_search_provider.h"
#include "components/omnibox/browser/location_bar_model.h"
#include "components/omnibox/browser/search_provider.h"
#include "components/omnibox/browser/shortcuts_backend.h"
#include "components/omnibox/common/omnibox_features.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 "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
#include "extensions/buildflags/buildflags.h"
#include "extensions/common/constants.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icon_types.h"
#include "url/gurl.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/browser/ui/extensions/settings_api_bubble_helpers.h"
#endif
AutocompleteActionPredictor;
ChromeOmniboxClient::ChromeOmniboxClient(LocationBar* location_bar,
Browser* browser,
Profile* profile)
: … { … }
ChromeOmniboxClient::~ChromeOmniboxClient() { … }
std::unique_ptr<AutocompleteProviderClient>
ChromeOmniboxClient::CreateAutocompleteProviderClient() { … }
bool ChromeOmniboxClient::CurrentPageExists() const { … }
const GURL& ChromeOmniboxClient::GetURL() const { … }
const std::u16string& ChromeOmniboxClient::GetTitle() const { … }
gfx::Image ChromeOmniboxClient::GetFavicon() const { … }
ukm::SourceId ChromeOmniboxClient::GetUKMSourceId() const { … }
bool ChromeOmniboxClient::IsLoading() const { … }
bool ChromeOmniboxClient::IsPasteAndGoEnabled() const { … }
bool ChromeOmniboxClient::IsDefaultSearchProviderEnabled() const { … }
SessionID ChromeOmniboxClient::GetSessionID() const { … }
PrefService* ChromeOmniboxClient::GetPrefs() { … }
bookmarks::BookmarkModel* ChromeOmniboxClient::GetBookmarkModel() { … }
AutocompleteControllerEmitter*
ChromeOmniboxClient::GetAutocompleteControllerEmitter() { … }
TemplateURLService* ChromeOmniboxClient::GetTemplateURLService() { … }
const AutocompleteSchemeClassifier& ChromeOmniboxClient::GetSchemeClassifier()
const { … }
AutocompleteClassifier* ChromeOmniboxClient::GetAutocompleteClassifier() { … }
bool ChromeOmniboxClient::ShouldDefaultTypedNavigationsToHttps() const { … }
int ChromeOmniboxClient::GetHttpsPortForTesting() const { … }
bool ChromeOmniboxClient::IsUsingFakeHttpsForHttpsUpgradeTesting() const { … }
gfx::Image ChromeOmniboxClient::GetIconIfExtensionMatch(
const AutocompleteMatch& match) const { … }
gfx::Image ChromeOmniboxClient::GetSizedIcon(
const gfx::VectorIcon& vector_icon_type,
SkColor vector_icon_color) const { … }
gfx::Image ChromeOmniboxClient::GetSizedIcon(const gfx::Image& icon) const { … }
std::u16string ChromeOmniboxClient::GetFormattedFullURL() const { … }
std::u16string ChromeOmniboxClient::GetURLForDisplay() const { … }
GURL ChromeOmniboxClient::GetNavigationEntryURL() const { … }
metrics::OmniboxEventProto::PageClassification
ChromeOmniboxClient::GetPageClassification(bool is_prefetch) { … }
security_state::SecurityLevel ChromeOmniboxClient::GetSecurityLevel() const { … }
net::CertStatus ChromeOmniboxClient::GetCertStatus() const { … }
const gfx::VectorIcon& ChromeOmniboxClient::GetVectorIcon() const { … }
bool ChromeOmniboxClient::ProcessExtensionKeyword(
const std::u16string& text,
const TemplateURL* template_url,
const AutocompleteMatch& match,
WindowOpenDisposition disposition) { … }
void ChromeOmniboxClient::OnInputStateChanged() { … }
void ChromeOmniboxClient::OnFocusChanged(OmniboxFocusState state,
OmniboxFocusChangeReason reason) { … }
void ChromeOmniboxClient::OnResultChanged(
const AutocompleteResult& result,
bool default_match_changed,
bool should_preload,
const BitmapFetchedCallback& on_bitmap_fetched) { … }
gfx::Image ChromeOmniboxClient::GetFaviconForPageUrl(
const GURL& page_url,
FaviconFetchedCallback on_favicon_fetched) { … }
gfx::Image ChromeOmniboxClient::GetFaviconForDefaultSearchProvider(
FaviconFetchedCallback on_favicon_fetched) { … }
gfx::Image ChromeOmniboxClient::GetFaviconForKeywordSearchProvider(
const TemplateURL* template_url,
FaviconFetchedCallback on_favicon_fetched) { … }
void ChromeOmniboxClient::OnTextChanged(const AutocompleteMatch& current_match,
bool user_input_in_progress,
const std::u16string& user_text,
const AutocompleteResult& result,
bool has_focus) { … }
void ChromeOmniboxClient::OnRevert() { … }
void ChromeOmniboxClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { … }
void ChromeOmniboxClient::OnBookmarkLaunched() { … }
void ChromeOmniboxClient::DiscardNonCommittedNavigations() { … }
void ChromeOmniboxClient::FocusWebContents() { … }
void ChromeOmniboxClient::OnNavigationLikely(
size_t index,
const AutocompleteMatch& match,
omnibox::mojom::NavigationPredictor navigation_predictor) { … }
void ChromeOmniboxClient::ShowFeedbackPage(const std::u16string& input_text,
const GURL& destination_url) { … }
void ChromeOmniboxClient::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) { … }
void ChromeOmniboxClient::OnInputInProgress(bool in_progress) { … }
void ChromeOmniboxClient::OnPopupVisibilityChanged() { … }
void ChromeOmniboxClient::OpenIphLink(GURL gurl) { … }
base::WeakPtr<OmniboxClient> ChromeOmniboxClient::AsWeakPtr() { … }
void ChromeOmniboxClient::DoPrerender(const AutocompleteMatch& match) { … }
void ChromeOmniboxClient::DoPreconnect(const AutocompleteMatch& match) { … }
void ChromeOmniboxClient::OnBitmapFetched(const BitmapFetchedCallback& callback,
int result_index,
const SkBitmap& bitmap) { … }
void ChromeOmniboxClient::OnSuccessfulNavigation(
Profile* profile,
const std::u16string& text,
const AutocompleteMatch& match) { … }