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

[omnibox] Suggestion Transparency: Update Remove dialog with UX strings

UX provided some final strings for the Remove dialog, and this CL adds
those strings.

This CL also updates the RemoveSuggestionBubbleDialogDelegateView by
giving the buttons translated text, providing a translated title,
and reordering some labels.

It also plumbs in TemplateURLService to fetch the shortname of the
default search provider.

Bug: 929477
Change-Id: I56d38c006faa51f921b5a054ae5443b3d1656acd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1610503
Commit-Queue: Tommy Li <tommycli@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarmanuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659710}
parent 9d51b857
...@@ -4918,9 +4918,15 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -4918,9 +4918,15 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_OMNIBOX_WHY_THIS_SUGGESTION" desc="The title of a menu entry and bubble that explains why this suggestion appears in the omnibox popup."> <message name="IDS_OMNIBOX_WHY_THIS_SUGGESTION" desc="The title of a menu entry and bubble that explains why this suggestion appears in the omnibox popup.">
Why this suggestion? Why this suggestion?
</message> </message>
<message name="IDS_OMNIBOX_REMOVE_SUGGESTION" desc="The title of a menu entry and bubble used to delete omnibox suggestions."> <message name="IDS_OMNIBOX_REMOVE_SUGGESTION" desc="The text of a context menu entry to delete an omnibox suggestion.">
Remove suggestion Remove suggestion
</message> </message>
<message name="IDS_OMNIBOX_REMOVE_SUGGESTION_BUBBLE_TITLE" desc="The title of a bubble to delete an omnibox suggestion.">
Remove suggestion?
</message>
<message name="IDS_OMNIBOX_REMOVE_SUGGESTION_BUBBLE_DESCRIPTION" desc="The description of a bubble to delete an omnibox suggestion.">
This page will also be removed from your history and <ph name="SEARCH_ENGINE">$1<ex>Google</ex></ph> activity.
</message>
<!-- NTP --> <!-- NTP -->
<message name="IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT" desc="The text displayed in the fakebox (on the New Tab page) when it is empty, and Google is the default search engine."> <message name="IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT" desc="The text displayed in the fakebox (on the New Tab page) when it is empty, and Google is the default search engine.">
......
4f7bd70a3a0304338ef3af278686c8cd75162ee9
\ No newline at end of file
4f7bd70a3a0304338ef3af278686c8cd75162ee9
\ No newline at end of file
...@@ -476,7 +476,11 @@ void OmniboxResultView::ExecuteCommand(int command_id, int event_flags) { ...@@ -476,7 +476,11 @@ void OmniboxResultView::ExecuteCommand(int command_id, int event_flags) {
popup_contents_view_->model()->result().match_at(model_index_); popup_contents_view_->model()->result().match_at(model_index_);
if (command_id == IDS_OMNIBOX_REMOVE_SUGGESTION) { if (command_id == IDS_OMNIBOX_REMOVE_SUGGESTION) {
ShowRemoveSuggestion(this, raw_match, TemplateURLService* template_url_service = popup_contents_view_->model()
->edit_model()
->client()
->GetTemplateURLService();
ShowRemoveSuggestion(template_url_service, this, raw_match,
base::BindOnce(&OmniboxResultView::RemoveSuggestion, base::BindOnce(&OmniboxResultView::RemoveSuggestion,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} else if (command_id == IDS_OMNIBOX_WHY_THIS_SUGGESTION) { } else if (command_id == IDS_OMNIBOX_WHY_THIS_SUGGESTION) {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/omnibox/browser/autocomplete_match.h" #include "components/omnibox/browser/autocomplete_match.h"
#include "components/search_engines/template_url_service.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h" #include "ui/views/bubble/bubble_dialog_delegate_view.h"
...@@ -21,49 +22,64 @@ namespace { ...@@ -21,49 +22,64 @@ namespace {
class RemoveSuggestionBubbleDialogDelegateView class RemoveSuggestionBubbleDialogDelegateView
: public views::BubbleDialogDelegateView { : public views::BubbleDialogDelegateView {
public: public:
RemoveSuggestionBubbleDialogDelegateView(views::View* anchor_view, RemoveSuggestionBubbleDialogDelegateView(
const AutocompleteMatch& match, TemplateURLService* template_url_service,
base::OnceClosure remove_closure) views::View* anchor_view,
const AutocompleteMatch& match,
base::OnceClosure remove_closure)
: views::BubbleDialogDelegateView(anchor_view, : views::BubbleDialogDelegateView(anchor_view,
views::BubbleBorder::TOP_LEFT), views::BubbleBorder::TOP_LEFT),
match_(match), match_(match),
remove_closure_(std::move(remove_closure)) { remove_closure_(std::move(remove_closure)) {
DCHECK(template_url_service);
DCHECK(match_.SupportsDeletion());
auto* layout_manager = SetLayoutManager( auto* layout_manager = SetLayoutManager(
std::make_unique<views::BoxLayout>(views::BoxLayout::kVertical)); std::make_unique<views::BoxLayout>(views::BoxLayout::kVertical));
layout_manager->set_cross_axis_alignment( layout_manager->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kStart); views::BoxLayout::CrossAxisAlignment::kStart);
// TODO(tommycli): Replace this with the real spacing from UX. // TODO(tommycli): Replace this with the real spacing from UX.
layout_manager->set_between_child_spacing(16); layout_manager->set_between_child_spacing(16);
// TODO(tommycli): Replace this with the real translated string from UX.
views::Label* why_this_suggestion_label = // Get the Search Provider name associated with this match.
new views::Label(match.GetWhyThisSuggestionText()); base::string16 search_provider_short_name;
why_this_suggestion_label->SetMultiLine(true); const TemplateURL* template_url =
why_this_suggestion_label->SetHorizontalAlignment( match.GetTemplateURL(template_url_service, false);
// If the match has no associated Search Provider, get the default one,
// although this may still fail if it's forbidden by policy.
if (!template_url) {
template_url = template_url_service->GetDefaultSearchProvider();
}
if (template_url) {
search_provider_short_name =
template_url->AdjustedShortNameForLocaleDirection();
}
views::Label* description_label =
new views::Label(l10n_util::GetStringFUTF16(
IDS_OMNIBOX_REMOVE_SUGGESTION_BUBBLE_DESCRIPTION,
search_provider_short_name));
description_label->SetMultiLine(true);
description_label->SetHorizontalAlignment(
gfx::HorizontalAlignment::ALIGN_LEFT); gfx::HorizontalAlignment::ALIGN_LEFT);
AddChildView(why_this_suggestion_label); AddChildView(description_label);
AddChildView(new views::Label(base::ASCIIToUTF16( // TODO(tommycli): Indent and set a smaller font per UX suggestions.
match.SupportsDeletion() ? "Remove suggestion from history?" views::Label* url_label = new views::Label(match.contents);
: "This match cannot be removed."))); url_label->SetMultiLine(true);
url_label->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
AddChildView(url_label);
} }
// views::DialogDelegateView: // views::DialogDelegateView:
int GetDialogButtons() const override { int GetDialogButtons() const override {
int buttons = ui::DIALOG_BUTTON_CANCEL; return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
if (match_.SupportsDeletion())
buttons |= ui::DIALOG_BUTTON_OK;
return buttons;
} }
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override { base::string16 GetDialogButtonLabel(ui::DialogButton button) const override {
// TODO(tommycli): Replace this with the real translated string from UX. return l10n_util::GetStringUTF16(
if (button == ui::DIALOG_BUTTON_OK) button == ui::DIALOG_BUTTON_OK ? IDS_REMOVE : IDS_CANCEL);
return base::ASCIIToUTF16("Remove");
return l10n_util::GetStringUTF16(match_.SupportsDeletion() ? IDS_CANCEL
: IDS_CLOSE);
} }
bool Accept() override { bool Accept() override {
DCHECK(match_.SupportsDeletion());
std::move(remove_closure_).Run(); std::move(remove_closure_).Run();
return true; return true;
} }
...@@ -76,7 +92,10 @@ class RemoveSuggestionBubbleDialogDelegateView ...@@ -76,7 +92,10 @@ class RemoveSuggestionBubbleDialogDelegateView
// views::WidgetDelegate: // views::WidgetDelegate:
ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_WINDOW; } ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_WINDOW; }
base::string16 GetWindowTitle() const override { return match_.contents; } base::string16 GetWindowTitle() const override {
return l10n_util::GetStringUTF16(
IDS_OMNIBOX_REMOVE_SUGGESTION_BUBBLE_TITLE);
}
private: private:
AutocompleteMatch match_; AutocompleteMatch match_;
...@@ -85,12 +104,13 @@ class RemoveSuggestionBubbleDialogDelegateView ...@@ -85,12 +104,13 @@ class RemoveSuggestionBubbleDialogDelegateView
} // namespace } // namespace
void ShowRemoveSuggestion(views::View* anchor_view, void ShowRemoveSuggestion(TemplateURLService* template_url_service,
views::View* anchor_view,
const AutocompleteMatch& match, const AutocompleteMatch& match,
base::OnceClosure remove_closure) { base::OnceClosure remove_closure) {
views::BubbleDialogDelegateView::CreateBubble( views::BubbleDialogDelegateView::CreateBubble(
new RemoveSuggestionBubbleDialogDelegateView(anchor_view, match, new RemoveSuggestionBubbleDialogDelegateView(
std::move(remove_closure))) template_url_service, anchor_view, match, std::move(remove_closure)))
->Show(); ->Show();
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/callback_forward.h" #include "base/callback_forward.h"
class TemplateURLService;
struct AutocompleteMatch; struct AutocompleteMatch;
namespace views { namespace views {
...@@ -16,7 +17,8 @@ class View; ...@@ -16,7 +17,8 @@ class View;
// Shows a confirmation bubble to remove a suggestion represented by |match|. // Shows a confirmation bubble to remove a suggestion represented by |match|.
// If the user clicks Remove, then |remove_closure| is executed, and the bubble // If the user clicks Remove, then |remove_closure| is executed, and the bubble
// is closed. // is closed.
void ShowRemoveSuggestion(views::View* anchor_view, void ShowRemoveSuggestion(TemplateURLService* template_url_service,
views::View* anchor_view,
const AutocompleteMatch& match, const AutocompleteMatch& match,
base::OnceClosure remove_closure); base::OnceClosure remove_closure);
......
...@@ -250,6 +250,9 @@ ...@@ -250,6 +250,9 @@
<message name="IDS_ADD" desc="Used for Add on buttons"> <message name="IDS_ADD" desc="Used for Add on buttons">
Add Add
</message> </message>
<message name="IDS_REMOVE" desc="Used for Remove on buttons">
Remove
</message>
<message name="IDS_SAVE" desc="Used on a button to save information you are editing."> <message name="IDS_SAVE" desc="Used on a button to save information you are editing.">
Save Save
</message> </message>
......
4f7bd70a3a0304338ef3af278686c8cd75162ee9
\ No newline at end of file
...@@ -64,6 +64,7 @@ class OmniboxPopupModel { ...@@ -64,6 +64,7 @@ class OmniboxPopupModel {
bool IsOpen() const; bool IsOpen() const;
OmniboxPopupView* view() const { return view_; } OmniboxPopupView* view() const { return view_; }
OmniboxEditModel* edit_model() const { return edit_model_; }
// Returns the AutocompleteController used by this popup. // Returns the AutocompleteController used by this popup.
AutocompleteController* autocomplete_controller() const { AutocompleteController* autocomplete_controller() const {
......
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