#include "chrome/browser/extensions/api/omnibox/omnibox_api.h"
#include <stddef.h>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/common/extensions/api/omnibox.h"
#include "chrome/common/extensions/api/omnibox/omnibox_handler.h"
#include "components/omnibox/browser/omnibox_input_watcher.h"
#include "components/omnibox/browser/omnibox_suggestions_watcher.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_service.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_prefs_factory.h"
#include "extensions/common/extension_id.h"
#include "ui/gfx/image/image.h"
namespace extensions {
omnibox;
SendSuggestions;
SetDefaultSuggestion;
namespace {
const char kSuggestionContent[] = …;
const char kCurrentTabDisposition[] = …;
const char kForegroundTabDisposition[] = …;
const char kBackgroundTabDisposition[] = …;
const char kOmniboxDefaultSuggestion[] = …;
std::optional<omnibox::SuggestResult> GetOmniboxDefaultSuggestion(
Profile* profile,
const ExtensionId& extension_id) { … }
bool SetOmniboxDefaultSuggestion(
Profile* profile,
const ExtensionId& extension_id,
const omnibox::DefaultSuggestResult& suggestion) { … }
std::string GetTemplateURLStringForExtension(const ExtensionId& extension_id) { … }
}
void ExtensionOmniboxEventRouter::OnInputStarted(
Profile* profile,
const ExtensionId& extension_id) { … }
bool ExtensionOmniboxEventRouter::OnInputChanged(
Profile* profile,
const ExtensionId& extension_id,
const std::string& input,
int suggest_id) { … }
void ExtensionOmniboxEventRouter::OnInputEntered(
content::WebContents* web_contents,
const ExtensionId& extension_id,
const std::string& input,
WindowOpenDisposition disposition) { … }
void ExtensionOmniboxEventRouter::OnInputCancelled(
Profile* profile,
const ExtensionId& extension_id) { … }
void ExtensionOmniboxEventRouter::OnDeleteSuggestion(
Profile* profile,
const ExtensionId& extension_id,
const std::string& suggestion_text) { … }
OmniboxAPI::OmniboxAPI(content::BrowserContext* context)
: … { … }
void OmniboxAPI::Shutdown() { … }
OmniboxAPI::~OmniboxAPI() { … }
static base::LazyInstance<BrowserContextKeyedAPIFactory<OmniboxAPI>>::
DestructorAtExit g_omnibox_api_factory = …;
BrowserContextKeyedAPIFactory<OmniboxAPI>* OmniboxAPI::GetFactoryInstance() { … }
OmniboxAPI* OmniboxAPI::Get(content::BrowserContext* context) { … }
void OmniboxAPI::OnExtensionLoaded(content::BrowserContext* browser_context,
const Extension* extension) { … }
void OmniboxAPI::OnExtensionUnloaded(content::BrowserContext* browser_context,
const Extension* extension,
UnloadedExtensionReason reason) { … }
gfx::Image OmniboxAPI::GetOmniboxIcon(const ExtensionId& extension_id) { … }
void OmniboxAPI::OnTemplateURLsLoaded() { … }
template <>
void BrowserContextKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() { … }
OmniboxSendSuggestionsFunction::OmniboxSendSuggestionsFunction() = default;
OmniboxSendSuggestionsFunction::~OmniboxSendSuggestionsFunction() = default;
ExtensionFunction::ResponseAction OmniboxSendSuggestionsFunction::Run() { … }
void OmniboxSendSuggestionsFunction::OnParsedDescriptionsAndStyles(
DescriptionAndStylesResult result) { … }
void OmniboxSendSuggestionsFunction::NotifySuggestionsReady() { … }
ExtensionFunction::ResponseAction OmniboxSetDefaultSuggestionFunction::Run() { … }
void OmniboxSetDefaultSuggestionFunction::OnParsedDescriptionAndStyles(
DescriptionAndStylesResult result) { … }
void OmniboxSetDefaultSuggestionFunction::SetDefaultSuggestion(
const omnibox::DefaultSuggestResult& suggestion) { … }
ACMatchClassifications StyleTypesToACMatchClassifications(
const omnibox::SuggestResult &suggestion) { … }
void ApplyDefaultSuggestionForExtensionKeyword(
Profile* profile,
const TemplateURL* keyword,
const std::u16string& remaining_input,
AutocompleteMatch* match) { … }
}