#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include <algorithm>
#include <map>
#include <memory>
#include <utility>
#include "base/containers/adapters.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/i18n/rtl.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/apps/link_capturing/link_capturing_features.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/extensions/api/omnibox/omnibox_api.h"
#include "chrome/browser/extensions/extension_ui_util.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/browser/sharing_hub/sharing_hub_features.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/translate/translate_service.h"
#include "chrome/browser/ui/autofill/payments/local_card_migration_bubble_controller_impl.h"
#include "chrome/browser/ui/autofill/payments/save_card_bubble_controller_impl.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/browser_window/public/browser_window_features.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/lens/lens_overlay_entry_point_controller.h"
#include "chrome/browser/ui/omnibox/chrome_omnibox_client.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "chrome/browser/ui/side_search/side_search_utils.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/location_bar/content_setting_image_view.h"
#include "chrome/browser/ui/views/location_bar/intent_chip_button.h"
#include "chrome/browser/ui/views/location_bar/location_bar_layout.h"
#include "chrome/browser/ui/views/location_bar/location_icon_view.h"
#include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
#include "chrome/browser/ui/views/location_bar/star_view.h"
#include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
#include "chrome/browser/ui/views/page_action/page_action_icon_container.h"
#include "chrome/browser/ui/views/page_action/page_action_icon_controller.h"
#include "chrome/browser/ui/views/page_action/page_action_icon_params.h"
#include "chrome/browser/ui/views/page_info/page_info_bubble_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h"
#include "chrome/browser/ui/views/permissions/chip/permission_chip_view.h"
#include "chrome/browser/ui/views/permissions/chip/permission_dashboard_view.h"
#include "chrome/browser/ui/views/sharing_hub/sharing_hub_icon_view.h"
#include "chrome/browser/ui/views/toolbar/pinned_toolbar_actions_container.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/features.h"
#include "components/dom_distiller/core/dom_distiller_features.h"
#include "components/favicon/content/content_favicon_driver.h"
#include "components/lens/lens_features.h"
#include "components/omnibox/browser/location_bar_model.h"
#include "components/omnibox/browser/omnibox_edit_model.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/browser/omnibox_popup_view.h"
#include "components/omnibox/browser/vector_icons.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/performance_manager/public/features.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_request_manager.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_service.h"
#include "components/security_state/content/security_state_tab_helper.h"
#include "components/security_state/core/security_state.h"
#include "components/sharing_message/features.h"
#include "components/strings/grit/components_strings.h"
#include "components/translate/core/browser/language_state.h"
#include "components/variations/variations_associated_data.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_features.h"
#include "content/public/common/url_constants.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/feature_switch.h"
#include "services/device/public/cpp/device_features.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/metrics_proto/omnibox_event.pb.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/virtual_keyboard_controller.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_features.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/paint_recorder.h"
#include "ui/events/event.h"
#include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/scoped_canvas.h"
#include "ui/gfx/text_utils.h"
#include "ui/gfx/vector_icon_types.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/button_drag_utils.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/focus_ring.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/label.h"
#include "ui/views/style/typography.h"
#include "ui/views/style/typography_provider.h"
#include "ui/views/view.h"
#include "ui/views/view_utils.h"
#include "ui/views/widget/widget.h"
#if BUILDFLAG(IS_MAC)
#include "chrome/browser/web_applications/os_integration/mac/app_shim_registry.h"
#include "chrome/browser/web_applications/web_app_tab_helper.h"
#endif
namespace {
int IncrementalMinimumWidth(const views::View* view) { … }
bool OmniboxPrefixRichAutocompletionEnabled() { … }
constexpr int kIntentChipIntraItemPadding = …;
constexpr int kContentSettingIntraItemPadding = …;
}
WebContents;
OmniboxEventProto;
View;
LocationBarView::LocationBarView(Browser* browser,
Profile* profile,
CommandUpdater* command_updater,
Delegate* delegate,
bool is_popup_mode)
: … { … }
LocationBarView::~LocationBarView() = default;
void LocationBarView::Init() { … }
bool LocationBarView::IsInitialized() const { … }
int LocationBarView::GetBorderRadius() const { … }
std::unique_ptr<views::Background> LocationBarView::CreateRoundRectBackground(
SkColor background_color,
SkColor stroke_color,
SkBlendMode blend_mode,
bool antialias,
bool should_border_scale) const { … }
gfx::Point LocationBarView::GetOmniboxViewOrigin() const { … }
void LocationBarView::SetImePrefixAutocompletion(const std::u16string& text) { … }
std::u16string LocationBarView::GetImePrefixAutocompletion() const { … }
void LocationBarView::SetImeInlineAutocompletion(const std::u16string& text) { … }
std::u16string LocationBarView::GetImeInlineAutocompletion() const { … }
void LocationBarView::SetOmniboxAdditionalText(const std::u16string& text) { … }
std::u16string LocationBarView::GetOmniboxAdditionalText() const { … }
void LocationBarView::SetOmniboxAdjacentText(views::Label* label,
const std::u16string& text) { … }
void LocationBarView::SelectAll() { … }
void LocationBarView::FocusLocation(bool is_user_initiated) { … }
void LocationBarView::Revert() { … }
OmniboxView* LocationBarView::GetOmniboxView() { … }
void LocationBarView::AddedToWidget() { … }
void LocationBarView::RemovedFromWidget() { … }
void LocationBarView::OnWillChangeFocus(views::View* before, views::View* now) { … }
void LocationBarView::OnDidChangeFocus(views::View* before, views::View* now) { … }
bool LocationBarView::HasFocus() const { … }
gfx::Size LocationBarView::GetMinimumSize() const { … }
gfx::Size LocationBarView::CalculatePreferredSize(
const views::SizeBounds& available_size) const { … }
void LocationBarView::OnKeywordFaviconFetched(const gfx::Image& icon) { … }
void LocationBarView::Layout(PassKey) { … }
void LocationBarView::OnThemeChanged() { … }
void LocationBarView::ChildPreferredSizeChanged(views::View* child) { … }
bool LocationBarView::HasSecurityStateChanged() { … }
void LocationBarView::Update(WebContents* contents) { … }
void LocationBarView::ResetTabState(WebContents* contents) { … }
bool LocationBarView::ActivateFirstInactiveBubbleForAccessibility() { … }
ChipController* LocationBarView::GetChipController() { … }
void LocationBarView::UpdateWithoutTabRestore() { … }
LocationBarModel* LocationBarView::GetLocationBarModel() { … }
WebContents* LocationBarView::GetWebContents() { … }
SkColor LocationBarView::GetIconLabelBubbleSurroundingForegroundColor() const { … }
SkAlpha LocationBarView::GetIconLabelBubbleSeparatorAlpha() const { … }
SkColor LocationBarView::GetIconLabelBubbleBackgroundColor() const { … }
bool LocationBarView::ShouldHideContentSettingImage() { … }
content::WebContents* LocationBarView::GetContentSettingWebContents() { … }
ContentSettingBubbleModelDelegate*
LocationBarView::GetContentSettingBubbleModelDelegate() { … }
#if BUILDFLAG(OS_LEVEL_GEOLOCATION_PERMISSION_SUPPORTED)
void LocationBarView::OnSystemPermissionUpdated(
device::LocationSystemPermissionStatus new_status) {
UpdateContentSettingsIcons();
}
#endif
WebContents* LocationBarView::GetWebContentsForPageActionIconView() { … }
bool LocationBarView::ShouldHidePageActionIcons() const { … }
bool LocationBarView::ShouldHidePageActionIcon(
PageActionIconView* icon_view) const { … }
bool LocationBarView::IsVirtualKeyboardVisible(views::Widget* widget) { … }
int LocationBarView::GetAvailableTextHeight() { … }
int LocationBarView::GetAvailableDecorationTextHeight() { … }
int LocationBarView::GetMinimumLeadingWidth() const { … }
int LocationBarView::GetMinimumTrailingWidth() const { … }
gfx::Rect LocationBarView::GetLocalBoundsWithoutEndcaps() const { … }
void LocationBarView::RefreshBackground() { … }
bool LocationBarView::RefreshContentSettingViews() { … }
void LocationBarView::RefreshPageActionIconViews() { … }
void LocationBarView::RefreshClearAllButtonIcon() { … }
bool LocationBarView::ShouldShowKeywordBubble() const { … }
OmniboxPopupView* LocationBarView::GetOmniboxPopupView() { … }
const OmniboxPopupView* LocationBarView::GetOmniboxPopupView() const { … }
void LocationBarView::OnPageInfoBubbleClosed(
views::Widget::ClosedReason closed_reason,
bool reload_prompt) { … }
void LocationBarView::FocusSearch() { … }
void LocationBarView::UpdateContentSettingsIcons() { … }
void LocationBarView::SaveStateToContents(WebContents* contents) { … }
LocationBarTesting* LocationBarView::GetLocationBarForTesting() { … }
bool LocationBarView::TestContentSettingImagePressed(size_t index) { … }
bool LocationBarView::IsContentSettingBubbleShowing(size_t index) { … }
void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { … }
bool LocationBarView::GetNeedsNotificationWhenVisibleBoundsChange() const { … }
void LocationBarView::OnVisibleBoundsChanged() { … }
void LocationBarView::OnFocus() { … }
void LocationBarView::OnPaintBorder(gfx::Canvas* canvas) { … }
bool LocationBarView::OnMousePressed(const ui::MouseEvent& event) { … }
bool LocationBarView::OnMouseDragged(const ui::MouseEvent& event) { … }
void LocationBarView::OnMouseReleased(const ui::MouseEvent& event) { … }
void LocationBarView::OnMouseMoved(const ui::MouseEvent& event) { … }
void LocationBarView::OnMouseExited(const ui::MouseEvent& event) { … }
void LocationBarView::ShowContextMenu(const gfx::Point& p,
ui::MenuSourceType source_type) { … }
void LocationBarView::WriteDragDataForView(views::View* sender,
const gfx::Point& press_pt,
OSExchangeData* data) { … }
int LocationBarView::GetDragOperationsForView(views::View* sender,
const gfx::Point& p) { … }
bool LocationBarView::CanStartDragForView(View* sender,
const gfx::Point& press_pt,
const gfx::Point& p) { … }
void LocationBarView::AnimationProgressed(const gfx::Animation* animation) { … }
void LocationBarView::AnimationEnded(const gfx::Animation* animation) { … }
void LocationBarView::AnimationCanceled(const gfx::Animation* animation) { … }
void LocationBarView::OnChildViewRemoved(View* observed_view, View* child) { … }
void LocationBarView::OnChanged() { … }
void LocationBarView::OnPopupVisibilityChanged() { … }
const LocationBarModel* LocationBarView::GetLocationBarModel() const { … }
void LocationBarView::OnOmniboxFocused() { … }
void LocationBarView::OnOmniboxBlurred() { … }
void LocationBarView::OnOmniboxHovered(bool is_hovering) { … }
void LocationBarView::OnTouchUiChanged() { … }
bool LocationBarView::ShouldChipOverrideLocationIcon() { … }
bool LocationBarView::IsEditingOrEmpty() const { … }
void LocationBarView::OnLocationIconPressed(const ui::MouseEvent& event) { … }
void LocationBarView::OnLocationIconDragged(const ui::MouseEvent& event) { … }
SkColor LocationBarView::GetSecurityChipColor(
security_state::SecurityLevel security_level) const { … }
bool LocationBarView::ShowPageInfoDialog() { … }
void LocationBarView::RecordPageInfoMetrics() { … }
ui::ImageModel LocationBarView::GetLocationIcon(
LocationIconView::Delegate::IconFetchedCallback on_icon_fetched) const { … }
void LocationBarView::UpdateChipVisibility() { … }
ui::MouseEvent LocationBarView::AdjustMouseEventLocationForOmniboxView(
const ui::MouseEvent& event) const { … }
bool LocationBarView::GetPopupMode() const { … }
#if BUILDFLAG(IS_MAC)
void LocationBarView::OnAppShimChanged(const webapps::AppId& app_id) {
WebContents* web_contents = GetWebContents();
if (!web_contents) {
return;
}
if (const webapps::AppId* id =
web_app::WebAppTabHelper::GetAppId(web_contents);
id && *id == app_id) {
UpdateContentSettingsIcons();
}
}
#endif
BEGIN_METADATA(…)