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 @@
#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"
namespace safe_browsing {
......@@ -15,49 +12,16 @@ namespace {
// 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.
constexpr char kMainTextIntroduction[] =
"Have you seen unusual startup pages or strange search results? Chrome has "
"detected the following kinds of programs on your computer that may be "
"causing the problem:";
constexpr char kMainTextActionExplanation[] =
"Chrome can remove the detected programs, which should stop the strange "
"behavior.";
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";
constexpr char kWindowTitle[] = "Clean up your computer?";
constexpr char kMainText[] =
"Chrome found software that harms your browsing experience. Remove related "
"files from your computer and restore browser settings, including your "
"search engine and home page.";
constexpr char kAcceptButtonLabel[] = "Cleanup";
constexpr char kAdvancedButtonLabel[] = "Advanced";
} // namespace
SRTPromptController::LabelInfo::LabelInfo(LabelType type,
const base::string16& text)
: type(type), text(text) {}
SRTPromptController::LabelInfo::~LabelInfo() = default;
SRTPromptController::SRTPromptController() {}
SRTPromptController::~SRTPromptController() = default;
......@@ -66,65 +30,18 @@ base::string16 SRTPromptController::GetWindowTitle() const {
return base::UTF8ToUTF16(kWindowTitle);
}
std::vector<SRTPromptController::LabelInfo> SRTPromptController::GetMainText()
const {
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::GetMainText() const {
return base::UTF8ToUTF16(kMainText);
}
base::string16 SRTPromptController::GetAcceptButtonLabel() const {
return base::UTF8ToUTF16(kAcceptButtonLabel);
}
base::string16 SRTPromptController::GetAdvancedButtonLabel() const {
return base::UTF8ToUTF16(kAdvancedButtonLabel);
}
void SRTPromptController::DialogShown() {}
void SRTPromptController::Accept() {
......@@ -135,6 +52,14 @@ void SRTPromptController::Cancel() {
OnInteractionDone();
}
void SRTPromptController::Close() {
OnInteractionDone();
}
void SRTPromptController::AdvancedButtonClicked() {
OnInteractionDone();
}
void SRTPromptController::OnInteractionDone() {
delete this;
}
......
......@@ -16,57 +16,40 @@ namespace safe_browsing {
// UI. Also provides functions, such as |Accept()| and |Cancel()|, that should
// 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
// dialog has been dismissed and either of |Accept()| or |Cancel()| have been
// called.
class SRTPromptController {
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();
base::string16 GetWindowTitle() const;
// The text to be shown in the Cleaner dialog's main section and will
// 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 GetMainText() const;
base::string16 GetAcceptButtonLabel() const;
base::string16 GetAdvancedButtonLabel() const;
// Called by the Cleaner dialog when the dialog has been shown. Used for
// reporting metrics.
void DialogShown();
// Called by the Cleaner dialog when user accepts the prompt. Once |Accept()|
// has been called, the controller will eventually delete itself and so no
// member functions should be called after that.
// has been called, the controller will eventually delete itself and no member
// functions should be called after that.
void Accept();
// Called by the Cleaner dialog when the dialog is dismissed or canceled. Once
// |Cancel()| has been called, the controller will eventually delete itself
// and so no member functions should be called after that.
// Called by the Cleaner dialog when the dialog is closed via the cancel
// button. Once |Cancel()| has been called, the controller will eventually
// delete itself and no member functions should be called after that.
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:
~SRTPromptController();
......
......@@ -8,31 +8,18 @@
#include <memory>
#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/label_button.h"
#include "ui/views/window/dialog_delegate.h"
class Browser;
namespace gfx {
class SlideAnimation;
}
namespace safe_browsing {
class SRTPromptController;
}
// A modal dialog asking the user if they want to run the Chrome Cleanup
// tool. The dialog will have the following sections:
//
// 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).
// A modal dialog asking the user if they want to remove harmful software from
// their computers by running the Chrome Cleanup tool.
//
// The strings and icons used in the dialog are provided by a
// |SRTPromptController| object, which will also receive information about how
......@@ -41,8 +28,7 @@ class SRTPromptController;
// interaction with the dialog. See the |SRTPromptController| class's
// description for more details.
class SRTPromptDialog : public views::DialogDelegateView,
public views::ButtonListener,
public gfx::AnimationDelegate {
public views::ButtonListener {
public:
// The |controller| object manages its own lifetime and is not owned by
// |SRTPromptDialog|. See the description of the |SRTPromptController| class
......@@ -61,8 +47,10 @@ class SRTPromptDialog : public views::DialogDelegateView,
// views::DialogDelegate overrides.
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
views::View* CreateExtraView() override;
bool Accept() override;
bool Cancel() override;
bool Close() override;
// views::View overrides.
gfx::Size GetPreferredSize() const override;
......@@ -70,24 +58,13 @@ class SRTPromptDialog : public views::DialogDelegateView,
// views::ButtonListener overrides.
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:
class ExpandableMessageView;
SkColor GetDetailsButtonColor();
void UpdateDetailsButton();
Browser* browser_;
// 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.
safe_browsing::SRTPromptController* controller_;
std::unique_ptr<gfx::SlideAnimation> slide_animation_;
ExpandableMessageView* details_view_;
views::LabelButton* details_button_;
views::LabelButton* advanced_button_;
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