Commit d439db58 authored by Tommy C. Li's avatar Tommy C. Li Committed by Commit Bot

Omnibox: Suggestion Transparency - Provide explanation for matches.

This CL surfaces the "Why this suggestion" text in the bubble for
removing suggestions.

Suggestions that can be removed now have a "More Info / Remove..."
context menu entry. Suggestions that cannot be removed have a
"More info..." context menu entry.

Both bring up a bubble.

This won't be the final UX treatment, but gets the capability in there
for further refinement.

Bug: 929477
Change-Id: I2dc9a5fea920653ead8ff9efea41fb77f91ff919
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1575872
Commit-Queue: Tommy Li <tommycli@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652870}
parent b4ee7db0
......@@ -446,9 +446,16 @@ void OmniboxResultView::ShowContextMenuForViewImpl(
}
// ui::SimpleMenuModel::Delegate overrides:
bool OmniboxResultView::IsCommandIdEnabled(int command_id) const {
bool OmniboxResultView::IsItemForCommandIdDynamic(int command_id) const {
DCHECK_EQ(COMMAND_REMOVE_SUGGESTION, command_id);
return match_.SupportsDeletion();
return true;
}
base::string16 OmniboxResultView::GetLabelForCommandId(int command_id) const {
DCHECK_EQ(COMMAND_REMOVE_SUGGESTION, command_id);
// TODO(tommycli): Replace this with the real translated string from UX.
return base::ASCIIToUTF16(match_.SupportsDeletion() ? "More info / Remove..."
: "More info...");
}
void OmniboxResultView::ExecuteCommand(int command_id, int event_flags) {
......
......@@ -105,7 +105,8 @@ class OmniboxResultView : public views::View,
ui::MenuSourceType source_type) override;
// ui::SimpleMenuModel::Delegate overrides:
bool IsCommandIdEnabled(int command_id) const override;
bool IsItemForCommandIdDynamic(int command_id) const override;
base::string16 GetLabelForCommandId(int command_id) const override;
void ExecuteCommand(int command_id, int event_flags) override;
private:
......
......@@ -32,24 +32,48 @@ class RemoveSuggestionBubbleDialogDelegateView
std::make_unique<views::BoxLayout>(views::BoxLayout::kVertical));
layout_manager->set_cross_axis_alignment(
views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
// TODO(tommycli): Replace this with the real spacing from UX.
layout_manager->set_between_child_spacing(16);
// TODO(tommycli): Replace this with the real translated string from UX.
AddChildView(new views::Label(
base::ASCIIToUTF16("Remove suggestion from history?")));
views::Label* why_this_suggestion_label =
new views::Label(match.GetWhyThisSuggestionText());
why_this_suggestion_label->SetMultiLine(true);
why_this_suggestion_label->SetHorizontalAlignment(
gfx::HorizontalAlignment::ALIGN_LEFT);
AddChildView(why_this_suggestion_label);
AddChildView(new views::Label(base::ASCIIToUTF16(
match.SupportsDeletion() ? "Remove suggestion from history?"
: "This match cannot be removed.")));
}
// views::DialogDelegateView:
int GetDialogButtons() const override {
int buttons = ui::DIALOG_BUTTON_CANCEL;
if (match_.SupportsDeletion())
buttons |= ui::DIALOG_BUTTON_OK;
return buttons;
}
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override {
// TODO(tommycli): Replace this with the real translated string from UX.
if (button == ui::DIALOG_BUTTON_OK)
return base::ASCIIToUTF16("Remove");
return l10n_util::GetStringUTF16(IDS_CANCEL);
return l10n_util::GetStringUTF16(match_.SupportsDeletion() ? IDS_CANCEL
: IDS_CLOSE);
}
bool Accept() override {
DCHECK(match_.SupportsDeletion());
std::move(remove_closure_).Run();
return true;
}
// views::View:
gfx::Size CalculatePreferredSize() const override {
// TODO(tommycli): Replace with the real width from UX.
return gfx::Size(500, GetHeightForWidth(500));
}
// views::WidgetDelegate:
ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_WINDOW; }
base::string16 GetWindowTitle() const override { return match_.contents; }
......
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