Commit a7127544 authored by manukh's avatar manukh Committed by Chromium LUCI CQ

[omnibox] [rich-autocompletion] Show context menu on right click.

Rich autocompletion added the |omnibox_additional_text_view_| label
adjacent to the |omnibox_view_| in the LocationBarView. When the
|omnibox_view_| displays a suggestion's contents, the label (if visible)
displays its description and vice versa. The LocationBarView directs
mouse button events from |omnibox_additional_text_view_| to
|omnibox_view_| so that, e.g., clicking the former will focus the
latter.

Specifically, the LocationBarView already directs the OnMousePressed,
OnMouseDragged, and OnMouseReleased events. This CL also adds
ShowContextMenu to be directed.

Bug: 1150010, 1062446
Change-Id: I639177a65abdb70e2c34322fb5217827b02c142e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586766Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836856}
parent 0bc8e453
...@@ -194,6 +194,11 @@ void LocationBarView::Init() { ...@@ -194,6 +194,11 @@ void LocationBarView::Init() {
is_popup_mode_, this, font_list); is_popup_mode_, this, font_list);
omnibox_view->Init(); omnibox_view->Init();
omnibox_view_ = AddChildView(std::move(omnibox_view)); omnibox_view_ = AddChildView(std::move(omnibox_view));
// LocationBarView directs mouse button events from
// |omnibox_additional_text_view_| to |omnibox_view_| so that e.g., clicking
// the former will focus the latter. In order to receive |ShowContextMenu()|
// requests, LocationBarView must have a context menu controller.
set_context_menu_controller(omnibox_view_->context_menu_controller());
// Initiate the Omnibox additional-text label. // Initiate the Omnibox additional-text label.
if (OmniboxFieldTrial::RichAutocompletionShowAdditionalText()) { if (OmniboxFieldTrial::RichAutocompletionShowAdditionalText()) {
...@@ -1099,6 +1104,11 @@ void LocationBarView::OnMouseExited(const ui::MouseEvent& event) { ...@@ -1099,6 +1104,11 @@ void LocationBarView::OnMouseExited(const ui::MouseEvent& event) {
OnOmniboxHovered(false); OnOmniboxHovered(false);
} }
void LocationBarView::ShowContextMenu(const gfx::Point& p,
ui::MenuSourceType source_type) {
omnibox_view_->ShowContextMenu(p, source_type);
}
void LocationBarView::WriteDragDataForView(views::View* sender, void LocationBarView::WriteDragDataForView(views::View* sender,
const gfx::Point& press_pt, const gfx::Point& press_pt,
OSExchangeData* data) { OSExchangeData* data) {
......
...@@ -301,13 +301,16 @@ class LocationBarView : public LocationBar, ...@@ -301,13 +301,16 @@ class LocationBarView : public LocationBar,
void OnVisibleBoundsChanged() override; void OnVisibleBoundsChanged() override;
void OnFocus() override; void OnFocus() override;
void OnPaintBorder(gfx::Canvas* canvas) override; void OnPaintBorder(gfx::Canvas* canvas) override;
// LocationBarView directs mouse button events from OmniboxAdditionalTextView // LocationBarView directs mouse button events from
// to OmniboxView so that e.g., clicking the former will focus the latter. // |omnibox_additional_text_view_| to |omnibox_view_| so that e.g., clicking
// the former will focus the latter.
bool OnMousePressed(const ui::MouseEvent& event) override; bool OnMousePressed(const ui::MouseEvent& event) override;
bool OnMouseDragged(const ui::MouseEvent& event) override; bool OnMouseDragged(const ui::MouseEvent& event) override;
void OnMouseReleased(const ui::MouseEvent& event) override; void OnMouseReleased(const ui::MouseEvent& event) override;
void OnMouseMoved(const ui::MouseEvent& event) override; void OnMouseMoved(const ui::MouseEvent& event) override;
void OnMouseExited(const ui::MouseEvent& event) override; void OnMouseExited(const ui::MouseEvent& event) override;
void ShowContextMenu(const gfx::Point& p,
ui::MenuSourceType source_type) override;
// views::DragController: // views::DragController:
void WriteDragDataForView(View* sender, void WriteDragDataForView(View* sender,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment