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

Omnibox: Add Remove Suggestion confirmation bubble

For the context menu for suggestions project, this adds the
confirmation bubble for Remove Suggestion (from history).

This bubble is not yet hooked up to anything, but is just the UI.

Screenshots here: go/context-menu-for-suggestions

Bug: 929477
Change-Id: I60b7c481c45bb2d1c61584961ad8f69a86e7f9b1
Reviewed-on: https://chromium-review.googlesource.com/c/1461328Reviewed-by: default avatarmanuk hovanesian <manukh@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630571}
parent 9059ff37
...@@ -2644,6 +2644,8 @@ jumbo_split_static_library("ui") { ...@@ -2644,6 +2644,8 @@ jumbo_split_static_library("ui") {
"views/omnibox/omnibox_text_view.h", "views/omnibox/omnibox_text_view.h",
"views/omnibox/omnibox_view_views.cc", "views/omnibox/omnibox_view_views.cc",
"views/omnibox/omnibox_view_views.h", "views/omnibox/omnibox_view_views.h",
"views/omnibox/remove_suggestion_bubble.cc",
"views/omnibox/remove_suggestion_bubble.h",
"views/omnibox/rounded_omnibox_results_frame.cc", "views/omnibox/rounded_omnibox_results_frame.cc",
"views/omnibox/rounded_omnibox_results_frame.h", "views/omnibox/rounded_omnibox_results_frame.h",
"views/overlay/back_to_tab_image_button.cc", "views/overlay/back_to_tab_image_button.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/omnibox/remove_suggestion_bubble.h"
#include <memory>
#include <utility>
#include "base/strings/utf_string_conversions.h"
#include "chrome/grit/generated_resources.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
namespace {
class RemoveSuggestionBubbleDialogDelegateView
: public views::BubbleDialogDelegateView {
public:
RemoveSuggestionBubbleDialogDelegateView(views::View* anchor_view,
const AutocompleteMatch& match,
base::OnceClosure remove_closure)
: views::BubbleDialogDelegateView(anchor_view,
views::BubbleBorder::TOP_LEFT),
match_(match),
remove_closure_(std::move(remove_closure)) {
auto* layout_manager = SetLayoutManager(
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 translated string from UX.
AddChildView(new views::Label(
base::ASCIIToUTF16("Remove suggestion from history?")));
}
// views::DialogDelegateView:
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);
}
bool Accept() override {
std::move(remove_closure_).Run();
return true;
}
// views::WidgetDelegate:
ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_WINDOW; }
base::string16 GetWindowTitle() const override { return match_.contents; }
private:
AutocompleteMatch match_;
base::OnceClosure remove_closure_;
};
} // namespace
void ShowRemoveSuggestion(views::View* anchor_view,
const AutocompleteMatch& match,
base::OnceClosure remove_closure) {
views::BubbleDialogDelegateView::CreateBubble(
new RemoveSuggestionBubbleDialogDelegateView(anchor_view, match,
std::move(remove_closure)))
->Show();
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_REMOVE_SUGGESTION_BUBBLE_H_
#define CHROME_BROWSER_UI_VIEWS_OMNIBOX_REMOVE_SUGGESTION_BUBBLE_H_
#include "base/callback_forward.h"
struct AutocompleteMatch;
namespace views {
class View;
}
// Shows a confirmation bubble to remove a suggestion represented by |match|.
// If the user clicks Remove, then |remove_closure| is executed, and the bubble
// is closed.
void ShowRemoveSuggestion(views::View* anchor_view,
const AutocompleteMatch& match,
base::OnceClosure remove_closure);
#endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_REMOVE_SUGGESTION_BUBBLE_H_
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