#include "components/omnibox/browser/actions/omnibox_action_in_suggest.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/utf_string_conversions.h"
#include "components/omnibox/browser/actions/omnibox_action_concepts.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "components/omnibox/browser/actions/omnibox_action_factory_android.h"
#include "url/android/gurl_android.h"
#endif
namespace {
enum class ActionInSuggestUmaType { … };
constexpr const char* ToUmaUsageHistogramName(
omnibox::ActionInfo::ActionType type) { … }
constexpr ActionInSuggestUmaType ToUmaActionType(
omnibox::ActionInfo::ActionType action_type) { … }
constexpr int ToActionHint(omnibox::ActionInfo::ActionType action_type) { … }
constexpr int ToActionContents(omnibox::ActionInfo::ActionType action_type) { … }
}
OmniboxActionInSuggest::OmniboxActionInSuggest(
omnibox::ActionInfo action_info,
std::optional<TemplateURLRef::SearchTermsArgs> search_terms_args)
: … { … }
OmniboxActionInSuggest::~OmniboxActionInSuggest() = default;
#if BUILDFLAG(IS_ANDROID)
base::android::ScopedJavaLocalRef<jobject>
OmniboxActionInSuggest::GetOrCreateJavaObject(JNIEnv* env) const {
if (!j_omnibox_action_) {
j_omnibox_action_.Reset(BuildOmniboxActionInSuggest(
env, reinterpret_cast<intptr_t>(this), strings_.hint,
strings_.accessibility_hint, action_info.action_type(),
action_info.action_uri()));
}
return base::android::ScopedJavaLocalRef<jobject>(j_omnibox_action_);
}
#endif
void OmniboxActionInSuggest::RecordActionShown(size_t position,
bool used) const { … }
void OmniboxActionInSuggest::Execute(ExecutionContext& context) const { … }
OmniboxActionId OmniboxActionInSuggest::ActionId() const { … }
const OmniboxActionInSuggest* OmniboxActionInSuggest::FromAction(
const OmniboxAction* action) { … }
OmniboxActionInSuggest* OmniboxActionInSuggest::FromAction(
OmniboxAction* action) { … }
void OmniboxActionInSuggest::RecordShownAndUsedMetrics(
omnibox::ActionInfo::ActionType type,
bool used) { … }
omnibox::ActionInfo::ActionType OmniboxActionInSuggest::Type() const { … }