Commit d2f9f9ff authored by alito's avatar alito Committed by Commit bot

Chrome Cleaner UI: update the modal dialog

This is the next iteration of the modal dialog based on UX team's
latest proposal. Strings are still not finalized.

BUG=690020

Review-Url: https://codereview.chromium.org/2847643002
Cr-Commit-Position: refs/heads/master@{#467858}
parent 77a4bd9d
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
#include "chrome/browser/safe_browsing/srt_prompt_controller.h" #include "chrome/browser/safe_browsing/srt_prompt_controller.h"
#include <initializer_list>
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
namespace safe_browsing { namespace safe_browsing {
...@@ -15,49 +12,16 @@ namespace { ...@@ -15,49 +12,16 @@ namespace {
// Some dummy strings to be displayed in the Cleaner dialog while iterating on // Some dummy strings to be displayed in the Cleaner dialog while iterating on
// the dialog's UX design and work on the Chrome<->Cleaner IPC is ongoing. // the dialog's UX design and work on the Chrome<->Cleaner IPC is ongoing.
constexpr char kMainTextIntroduction[] = constexpr char kWindowTitle[] = "Clean up your computer?";
"Have you seen unusual startup pages or strange search results? Chrome has " constexpr char kMainText[] =
"detected the following kinds of programs on your computer that may be " "Chrome found software that harms your browsing experience. Remove related "
"causing the problem:"; "files from your computer and restore browser settings, including your "
constexpr char kMainTextActionExplanation[] = "search engine and home page.";
"Chrome can remove the detected programs, which should stop the strange " constexpr char kAcceptButtonLabel[] = "Cleanup";
"behavior."; constexpr char kAdvancedButtonLabel[] = "Advanced";
constexpr char kUnwantedSoftwareCategory1[] = "1 Browser hijacker";
constexpr char kUnwantedSoftwareCategory2[] = "2 Ad Injectors";
constexpr char kDetailsSectionSettingsResetExplanation[] =
"Chrome will reset the following settings:";
constexpr char kDetailsSectionSetting1[] = "Default search engine";
constexpr char kDetailsSectionSetting2[] = "Startup pages";
constexpr char kDetailsSectionSetting3[] = "Homepage";
constexpr char kDetailsSectionSetting4[] = "Shortcuts";
constexpr char kDetailsSectionSetting5[] =
"All extensions (these can be enabled again later)";
constexpr char kDetailsSectionActionExplanation[] =
"The following files will be removed:";
constexpr char kDetailsSectionPoweredBy[] = "Powered by: <ESET logo>";
constexpr char kDummyDirectory[] =
"C:\\Documents and Settings\\JohnDoe\\Local Settings\\Application Data"
"\\IAmNotWanted\\application\\";
constexpr char kDummyFilename1[] = "somefile.dll";
constexpr char kDummyFilename2[] = "another_file.dll";
constexpr char kDummyFilename3[] = "more_stuff.dll";
constexpr char kDummyFilename4[] = "run_me.exe";
constexpr char kShowDetails[] = "Learn more";
constexpr char kHideDetails[] = "Close";
constexpr char kWindowTitle[] = "Chrome detected unusual behavior";
constexpr char kAcceptButtonLabel[] = "Start cleanup";
} // namespace } // namespace
SRTPromptController::LabelInfo::LabelInfo(LabelType type,
const base::string16& text)
: type(type), text(text) {}
SRTPromptController::LabelInfo::~LabelInfo() = default;
SRTPromptController::SRTPromptController() {} SRTPromptController::SRTPromptController() {}
SRTPromptController::~SRTPromptController() = default; SRTPromptController::~SRTPromptController() = default;
...@@ -66,65 +30,18 @@ base::string16 SRTPromptController::GetWindowTitle() const { ...@@ -66,65 +30,18 @@ base::string16 SRTPromptController::GetWindowTitle() const {
return base::UTF8ToUTF16(kWindowTitle); return base::UTF8ToUTF16(kWindowTitle);
} }
std::vector<SRTPromptController::LabelInfo> SRTPromptController::GetMainText() base::string16 SRTPromptController::GetMainText() const {
const { return base::UTF8ToUTF16(kMainText);
return {
LabelInfo(LabelInfo::PARAGRAPH, base::UTF8ToUTF16(kMainTextIntroduction)),
LabelInfo(LabelInfo::BULLET_ITEM,
base::UTF8ToUTF16(kUnwantedSoftwareCategory1)),
LabelInfo(LabelInfo::BULLET_ITEM,
base::UTF8ToUTF16(kUnwantedSoftwareCategory2)),
LabelInfo(LabelInfo::PARAGRAPH,
base::UTF8ToUTF16(kMainTextActionExplanation)),
};
}
std::vector<SRTPromptController::LabelInfo>
SRTPromptController::GetDetailsText() const {
return {
LabelInfo(LabelInfo::PARAGRAPH,
base::UTF8ToUTF16(kDetailsSectionSettingsResetExplanation)),
LabelInfo(LabelInfo::BULLET_ITEM,
base::UTF8ToUTF16(kDetailsSectionSetting1)),
LabelInfo(LabelInfo::BULLET_ITEM,
base::UTF8ToUTF16(kDetailsSectionSetting2)),
LabelInfo(LabelInfo::BULLET_ITEM,
base::UTF8ToUTF16(kDetailsSectionSetting3)),
LabelInfo(LabelInfo::BULLET_ITEM,
base::UTF8ToUTF16(kDetailsSectionSetting4)),
LabelInfo(LabelInfo::BULLET_ITEM,
base::UTF8ToUTF16(kDetailsSectionSetting5)),
LabelInfo(LabelInfo::PARAGRAPH,
base::UTF8ToUTF16(kDetailsSectionActionExplanation)),
LabelInfo(LabelInfo::BULLET_ITEM,
base::UTF8ToUTF16(base::JoinString(
{kDummyDirectory, kDummyFilename1}, nullptr))),
LabelInfo(LabelInfo::BULLET_ITEM,
base::UTF8ToUTF16(base::JoinString(
{kDummyDirectory, kDummyFilename2}, nullptr))),
LabelInfo(LabelInfo::BULLET_ITEM,
base::UTF8ToUTF16(base::JoinString(
{kDummyDirectory, kDummyFilename3}, nullptr))),
LabelInfo(LabelInfo::BULLET_ITEM,
base::UTF8ToUTF16(base::JoinString(
{kDummyDirectory, kDummyFilename4}, nullptr))),
LabelInfo(LabelInfo::PARAGRAPH,
base::UTF8ToUTF16(kDetailsSectionPoweredBy)),
};
}
base::string16 SRTPromptController::GetShowDetailsLabel() const {
return base::UTF8ToUTF16(kShowDetails);
}
base::string16 SRTPromptController::GetHideDetailsLabel() const {
return base::UTF8ToUTF16(kHideDetails);
} }
base::string16 SRTPromptController::GetAcceptButtonLabel() const { base::string16 SRTPromptController::GetAcceptButtonLabel() const {
return base::UTF8ToUTF16(kAcceptButtonLabel); return base::UTF8ToUTF16(kAcceptButtonLabel);
} }
base::string16 SRTPromptController::GetAdvancedButtonLabel() const {
return base::UTF8ToUTF16(kAdvancedButtonLabel);
}
void SRTPromptController::DialogShown() {} void SRTPromptController::DialogShown() {}
void SRTPromptController::Accept() { void SRTPromptController::Accept() {
...@@ -135,6 +52,14 @@ void SRTPromptController::Cancel() { ...@@ -135,6 +52,14 @@ void SRTPromptController::Cancel() {
OnInteractionDone(); OnInteractionDone();
} }
void SRTPromptController::Close() {
OnInteractionDone();
}
void SRTPromptController::AdvancedButtonClicked() {
OnInteractionDone();
}
void SRTPromptController::OnInteractionDone() { void SRTPromptController::OnInteractionDone() {
delete this; delete this;
} }
......
...@@ -16,57 +16,40 @@ namespace safe_browsing { ...@@ -16,57 +16,40 @@ namespace safe_browsing {
// UI. Also provides functions, such as |Accept()| and |Cancel()|, that should // UI. Also provides functions, such as |Accept()| and |Cancel()|, that should
// be called by the UI in response to user actions. // be called by the UI in response to user actions.
// //
// Objects of this class are typically created by the SwReporterProcess class,
// which will pass in information the controller needs to be able to create
// strings to be displayed in the prompt dialog.
//
// This class manages its own lifetime and will delete itself once the Cleaner // This class manages its own lifetime and will delete itself once the Cleaner
// dialog has been dismissed and either of |Accept()| or |Cancel()| have been // dialog has been dismissed and either of |Accept()| or |Cancel()| have been
// called. // called.
class SRTPromptController { class SRTPromptController {
public: public:
struct LabelInfo {
enum LabelType {
// Indicates that |text| should be displayed as a multi-line label.
PARAGRAPH,
// Indicates that |text| should be displayed as a multi-line label that is
// indented and starts with a bullet point.
BULLET_ITEM,
};
LabelInfo(LabelType type, const base::string16& text);
~LabelInfo();
LabelType type;
base::string16 text;
};
SRTPromptController(); SRTPromptController();
base::string16 GetWindowTitle() const; base::string16 GetWindowTitle() const;
// The text to be shown in the Cleaner dialog's main section and will base::string16 GetMainText() const;
// always be visible while the dialog is displayed.
std::vector<LabelInfo> GetMainText() const;
// The text to be shown in the expandable details section of the
// Cleaner dialog.
std::vector<LabelInfo> GetDetailsText() const;
// The text on the button that expands the details section.
base::string16 GetShowDetailsLabel() const;
// The text on the button that folds the details section.
base::string16 GetHideDetailsLabel() const;
base::string16 GetAcceptButtonLabel() const; base::string16 GetAcceptButtonLabel() const;
base::string16 GetAdvancedButtonLabel() const;
// Called by the Cleaner dialog when the dialog has been shown. Used for // Called by the Cleaner dialog when the dialog has been shown. Used for
// reporting metrics. // reporting metrics.
void DialogShown(); void DialogShown();
// Called by the Cleaner dialog when user accepts the prompt. Once |Accept()| // Called by the Cleaner dialog when user accepts the prompt. Once |Accept()|
// has been called, the controller will eventually delete itself and so no // has been called, the controller will eventually delete itself and no member
// member functions should be called after that. // functions should be called after that.
void Accept(); void Accept();
// Called by the Cleaner dialog when the dialog is dismissed or canceled. Once // Called by the Cleaner dialog when the dialog is closed via the cancel
// |Cancel()| has been called, the controller will eventually delete itself // button. Once |Cancel()| has been called, the controller will eventually
// and so no member functions should be called after that. // delete itself and no member functions should be called after that.
void Cancel(); void Cancel();
// Called by the Cleaner dialog when the dialog is closed by some other means
// than the cancel button (for example, by pressing Esc or clicking the 'x' on
// the top of the dialog). After a call to |Dismiss()|, the controller will
// eventually delete itself and no member functions should be called after
// that.
void Close();
// Called when the advanced button is clicked, after which the dialog will
// close. After a call to |AdvancedButtonClicked()|, the controller will
// eventually delete itself and no member functions should be called after
// that.
void AdvancedButtonClicked();
protected: protected:
~SRTPromptController(); ~SRTPromptController();
......
...@@ -4,33 +4,18 @@ ...@@ -4,33 +4,18 @@
#include "chrome/browser/ui/views/srt_prompt_dialog.h" #include "chrome/browser/ui/views/srt_prompt_dialog.h"
#include <vector>
#include "base/memory/ptr_util.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/safe_browsing/srt_prompt_controller.h" #include "chrome/browser/safe_browsing/srt_prompt_controller.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h"
#include "components/constrained_window/constrained_window_views.h" #include "components/constrained_window/constrained_window_views.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
#include "ui/base/ui_base_types.h" #include "ui/base/ui_base_types.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/text_constants.h" #include "ui/gfx/text_constants.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/border.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/separator.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h" #include "ui/views/layout/layout_constants.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -45,198 +30,30 @@ void ShowSRTPrompt(Browser* browser, ...@@ -45,198 +30,30 @@ void ShowSRTPrompt(Browser* browser,
} // namespace chrome } // namespace chrome
namespace { namespace {
using LabelInfo = safe_browsing::SRTPromptController::LabelInfo;
constexpr int kDialogWidth = 448; constexpr int kDialogWidth = 448;
constexpr int kDetailsSectionMaxHeight = 150;
constexpr int kBulletColumnWidth = 10;
// Constants used for the layout of the label views.
constexpr int kMainColumSetId = 0;
constexpr int kBulletColumnSetId = 1;
// Returns a view containing |item| with insets defined by |top|, |left|,
// |bottom|, and |right|.
views::View* CreateViewWithInsets(views::View* item,
int top,
int left,
int bottom,
int right) {
views::View* view = new views::View();
view->SetLayoutManager(new views::FillLayout());
view->SetBorder(views::CreateEmptyBorder(top, left, bottom, right));
view->AddChildView(item);
return view;
}
// Helper function used by |CreateLabelView()| below that adds |labels| to
// |label_view|.
void AddLabelsToLabelView(views::View* label_view,
views::GridLayout* layout,
const std::vector<LabelInfo>& labels) {
static constexpr base::char16 kBulletPoint[] = {0x2022, 0};
bool first_label = true;
bool last_label_was_bullet = false;
for (const LabelInfo& label_info : labels) {
const bool is_bullet = label_info.type == LabelInfo::BULLET_ITEM;
views::Label* label = new views::Label(label_info.text);
label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
// Do not add a padding row if
// - this is the first label being added, or
// - a bullet item is being added and the last label was also a bullet item.
bool skip_padding = first_label || (is_bullet && last_label_was_bullet);
if (!skip_padding)
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
layout->StartRow(0, is_bullet ? kBulletColumnSetId : kMainColumSetId);
if (is_bullet) {
views::Label* bullet = new views::Label(base::string16(kBulletPoint));
layout->AddView(bullet);
}
layout->AddView(label);
last_label_was_bullet = is_bullet;
first_label = false;
}
}
// Creates a view that displays two types of labels: multiline labels
// representing whole paragraphs or indented labels that are start with a bullet
// point.
//
// A vertical padding of size |top_vertical_space| is added before the labels.
views::View* CreateLabelView(int top_vertical_space,
const std::vector<LabelInfo>& labels) {
views::View* label_view = new views::View();
views::GridLayout* layout = new views::GridLayout(label_view);
layout->SetInsets(0, views::kButtonHEdgeMarginNew, 0,
views::kButtonHEdgeMarginNew);
label_view->SetLayoutManager(layout);
views::ColumnSet* main_column_set = layout->AddColumnSet(kMainColumSetId);
main_column_set->AddColumn(views::GridLayout::FILL,
views::GridLayout::LEADING,
/*resize_percent=*/1, views::GridLayout::USE_PREF,
/*fixed_width=*/0,
/*min_width=*/0);
views::ColumnSet* bullet_column_set_ =
layout->AddColumnSet(kBulletColumnSetId);
bullet_column_set_->AddPaddingColumn(
/*resize_percent=*/0, views::kUnrelatedControlLargeHorizontalSpacing);
bullet_column_set_->AddColumn(
views::GridLayout::FILL, views::GridLayout::LEADING,
/*resize_percent=*/0, views::GridLayout::USE_PREF,
/*fixed_width=*/0,
/*min_width=*/0);
bullet_column_set_->AddPaddingColumn(/*resize_percent=*/0,
kBulletColumnWidth);
bullet_column_set_->AddColumn(
views::GridLayout::FILL, views::GridLayout::LEADING,
/*resize_percent=*/1, views::GridLayout::USE_PREF,
/*fixed_width=*/0,
/*min_width=*/0);
if (top_vertical_space > 0)
layout->AddPaddingRow(/*vertical_resize=*/0, top_vertical_space);
AddLabelsToLabelView(label_view, layout, labels);
layout->AddPaddingRow(/*vertical_resize=*/0,
views::kUnrelatedControlLargeHorizontalSpacing);
return label_view;
}
} // namespace } // namespace
////////////////////////////////////////////////////////////////////////////////
// SRTPromptDialog::ExpandableMessageView
//
// A view, whose visibilty can be toggled, and will be used for the details
// section the main dialog.
class SRTPromptDialog::ExpandableMessageView : public views::View {
public:
explicit ExpandableMessageView(const std::vector<LabelInfo>& labels);
~ExpandableMessageView() override;
void AnimateToState(double state);
// views::View overrides.
gfx::Size GetPreferredSize() const override;
int GetHeightForWidth(int width) const override;
private:
// A number between 0 and 1 that determines how much of the view's preferred
// height should be visible.
double animation_state_;
DISALLOW_COPY_AND_ASSIGN(ExpandableMessageView);
};
SRTPromptDialog::ExpandableMessageView::ExpandableMessageView(
const std::vector<LabelInfo>& labels)
: animation_state_(0.0) {
// Add the main message view inside a scroll view.
views::View* label_view =
CreateLabelView(views::kUnrelatedControlLargeHorizontalSpacing, labels);
views::ScrollView* scroll_view = new views::ScrollView();
scroll_view->ClipHeightTo(kDetailsSectionMaxHeight, kDetailsSectionMaxHeight);
scroll_view->SetContents(label_view);
scroll_view->SetSize(gfx::Size(kDialogWidth, kDetailsSectionMaxHeight));
AddChildView(scroll_view);
}
SRTPromptDialog::ExpandableMessageView::~ExpandableMessageView() {}
void SRTPromptDialog::ExpandableMessageView::AnimateToState(double state) {
DCHECK_LE(0.0, state);
DCHECK_GE(1.0, state);
animation_state_ = state;
PreferredSizeChanged();
}
gfx::Size SRTPromptDialog::ExpandableMessageView::GetPreferredSize() const {
return gfx::Size(kDialogWidth, kDetailsSectionMaxHeight * animation_state_);
}
int SRTPromptDialog::ExpandableMessageView::GetHeightForWidth(int width) const {
return GetPreferredSize().height();
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// SRTPromptDialog // SRTPromptDialog
SRTPromptDialog::SRTPromptDialog(safe_browsing::SRTPromptController* controller) SRTPromptDialog::SRTPromptDialog(safe_browsing::SRTPromptController* controller)
: browser_(nullptr), : browser_(nullptr),
controller_(controller), controller_(controller),
slide_animation_(base::MakeUnique<gfx::SlideAnimation>(this)), advanced_button_(
details_view_(new ExpandableMessageView(controller_->GetDetailsText())), new views::LabelButton(this, controller_->GetAdvancedButtonLabel())) {
details_button_(
new views::LabelButton(this, controller_->GetShowDetailsLabel())) {
DCHECK(controller_); DCHECK(controller_);
SetLayoutManager(new views::BoxLayout( SetLayoutManager(new views::BoxLayout(
/*orientation=*/views::BoxLayout::kVertical, /*orientation=*/views::BoxLayout::kVertical,
/*inside_border_horizontal_spacing=*/0, /*inside_border_horizontal_spacing=*/views::kButtonHEdgeMarginNew,
/*inside_border_vertical_spacing=*/views::kPanelVertMargin, /*inside_border_vertical_spacing=*/views::kPanelVertMargin,
/*between_child_spacing=*/0)); /*between_child_spacing=*/0));
views::Label* label = new views::Label(controller_->GetMainText());
label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
AddChildView(label);
AddChildView(CreateLabelView(0, controller_->GetMainText())); advanced_button_->SetStyle(views::Button::STYLE_BUTTON);
AddChildView(new views::Separator());
AddChildView(details_view_);
details_button_->SetEnabledTextColors(GetDetailsButtonColor());
UpdateDetailsButton();
AddChildView(CreateViewWithInsets(
details_button_, views::kPanelVertMargin, views::kButtonHEdgeMarginNew,
views::kPanelVertMargin, views::kButtonHEdgeMarginNew));
AddChildView(new views::Separator());
} }
SRTPromptDialog::~SRTPromptDialog() { SRTPromptDialog::~SRTPromptDialog() {
...@@ -282,9 +99,13 @@ base::string16 SRTPromptDialog::GetDialogButtonLabel( ...@@ -282,9 +99,13 @@ base::string16 SRTPromptDialog::GetDialogButtonLabel(
DCHECK(button == ui::DIALOG_BUTTON_OK || button == ui::DIALOG_BUTTON_CANCEL); DCHECK(button == ui::DIALOG_BUTTON_OK || button == ui::DIALOG_BUTTON_CANCEL);
DCHECK(controller_); DCHECK(controller_);
if (button == ui::DIALOG_BUTTON_OK) return button == ui::DIALOG_BUTTON_OK
return controller_->GetAcceptButtonLabel(); ? controller_->GetAcceptButtonLabel()
return DialogDelegate::GetDialogButtonLabel(button); : DialogDelegate::GetDialogButtonLabel(button);
}
views::View* SRTPromptDialog::CreateExtraView() {
return advanced_button_;
} }
bool SRTPromptDialog::Accept() { bool SRTPromptDialog::Accept() {
...@@ -303,6 +124,14 @@ bool SRTPromptDialog::Cancel() { ...@@ -303,6 +124,14 @@ bool SRTPromptDialog::Cancel() {
return true; return true;
} }
bool SRTPromptDialog::Close() {
if (controller_) {
controller_->Close();
controller_ = nullptr;
}
return true;
}
// View overrides. // View overrides.
gfx::Size SRTPromptDialog::GetPreferredSize() const { gfx::Size SRTPromptDialog::GetPreferredSize() const {
...@@ -313,42 +142,14 @@ gfx::Size SRTPromptDialog::GetPreferredSize() const { ...@@ -313,42 +142,14 @@ gfx::Size SRTPromptDialog::GetPreferredSize() const {
void SRTPromptDialog::ButtonPressed(views::Button* sender, void SRTPromptDialog::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
DCHECK_EQ(sender, details_button_); DCHECK_EQ(sender, advanced_button_);
DCHECK(browser_); DCHECK(browser_);
if (slide_animation_->IsShowing()) // TODO(alito): Navigate to the webui version of the Chrome Cleaner UI when
slide_animation_->Hide(); // that is implemented.
else if (controller_) {
slide_animation_->Show(); controller_->AdvancedButtonClicked();
} controller_ = nullptr;
}
void SRTPromptDialog::AnimationProgressed(const gfx::Animation* animation) { GetWidget()->Close();
DCHECK_EQ(slide_animation_.get(), animation);
details_view_->AnimateToState(animation->GetCurrentValue());
ChromeWebModalDialogManagerDelegate* manager = browser_;
constrained_window::UpdateWidgetModalDialogPosition(
GetWidget(), manager->GetWebContentsModalDialogHost());
}
void SRTPromptDialog::AnimationEnded(const gfx::Animation* animation) {
DCHECK_EQ(slide_animation_.get(), animation);
UpdateDetailsButton();
}
SkColor SRTPromptDialog::GetDetailsButtonColor() {
return GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_LinkEnabled);
}
void SRTPromptDialog::UpdateDetailsButton() {
DCHECK(controller_);
details_button_->SetText(slide_animation_->IsShowing()
? controller_->GetHideDetailsLabel()
: controller_->GetShowDetailsLabel());
details_button_->SetImage(
views::Button::STATE_NORMAL,
slide_animation_->IsShowing()
? gfx::CreateVectorIcon(kCaretUpIcon, GetDetailsButtonColor())
: gfx::CreateVectorIcon(kCaretDownIcon, GetDetailsButtonColor()));
} }
...@@ -8,31 +8,18 @@ ...@@ -8,31 +8,18 @@
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/animation/animation_delegate.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/label_button.h"
#include "ui/views/window/dialog_delegate.h" #include "ui/views/window/dialog_delegate.h"
class Browser; class Browser;
namespace gfx {
class SlideAnimation;
}
namespace safe_browsing { namespace safe_browsing {
class SRTPromptController; class SRTPromptController;
} }
// A modal dialog asking the user if they want to run the Chrome Cleanup // A modal dialog asking the user if they want to remove harmful software from
// tool. The dialog will have the following sections: // their computers by running the Chrome Cleanup tool.
//
// 1. Main section with general information about unwanted software that has
// been found on the user's system.
// 2. Expandable details section with more details about unwanted software that
// will be removed and Chrome settings that will be reset.
// 3. Checkbox asking for permissions to upload logs (not yet implemented).
// //
// The strings and icons used in the dialog are provided by a // The strings and icons used in the dialog are provided by a
// |SRTPromptController| object, which will also receive information about how // |SRTPromptController| object, which will also receive information about how
...@@ -41,8 +28,7 @@ class SRTPromptController; ...@@ -41,8 +28,7 @@ class SRTPromptController;
// interaction with the dialog. See the |SRTPromptController| class's // interaction with the dialog. See the |SRTPromptController| class's
// description for more details. // description for more details.
class SRTPromptDialog : public views::DialogDelegateView, class SRTPromptDialog : public views::DialogDelegateView,
public views::ButtonListener, public views::ButtonListener {
public gfx::AnimationDelegate {
public: public:
// The |controller| object manages its own lifetime and is not owned by // The |controller| object manages its own lifetime and is not owned by
// |SRTPromptDialog|. See the description of the |SRTPromptController| class // |SRTPromptDialog|. See the description of the |SRTPromptController| class
...@@ -61,8 +47,10 @@ class SRTPromptDialog : public views::DialogDelegateView, ...@@ -61,8 +47,10 @@ class SRTPromptDialog : public views::DialogDelegateView,
// views::DialogDelegate overrides. // views::DialogDelegate overrides.
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
views::View* CreateExtraView() override;
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
bool Close() override;
// views::View overrides. // views::View overrides.
gfx::Size GetPreferredSize() const override; gfx::Size GetPreferredSize() const override;
...@@ -70,24 +58,13 @@ class SRTPromptDialog : public views::DialogDelegateView, ...@@ -70,24 +58,13 @@ class SRTPromptDialog : public views::DialogDelegateView,
// views::ButtonListener overrides. // views::ButtonListener overrides.
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// gfx::AnimationDelegate overrides.
void AnimationProgressed(const gfx::Animation* animation) override;
void AnimationEnded(const gfx::Animation* animation) override;
private: private:
class ExpandableMessageView;
SkColor GetDetailsButtonColor();
void UpdateDetailsButton();
Browser* browser_; Browser* browser_;
// The pointer will be set to nullptr once the controller has been notified of // The pointer will be set to nullptr once the controller has been notified of
// user interaction since the controller can delete itself after that point. // user interaction since the controller can delete itself after that point.
safe_browsing::SRTPromptController* controller_; safe_browsing::SRTPromptController* controller_;
std::unique_ptr<gfx::SlideAnimation> slide_animation_; views::LabelButton* advanced_button_;
ExpandableMessageView* details_view_;
views::LabelButton* details_button_;
DISALLOW_COPY_AND_ASSIGN(SRTPromptDialog); DISALLOW_COPY_AND_ASSIGN(SRTPromptDialog);
}; };
......
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