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

Chrome Cleaner UI: Add a dialog class for the new UI

Adds a new dialog class based on our current UX mocks. The intention
is to iterate with the UX team to come up with a UI for the Chrome
Cleanup tool.

Some functionality is currently missing and will be added in
subsequent CLs:
- Checkbox to ask for logs upload permissions
- Animation when the details section is expanded/folded

BUG=690020

Review-Url: https://codereview.chromium.org/2795133002
Cr-Commit-Position: refs/heads/master@{#462669}
parent e9d564bf
...@@ -3081,6 +3081,8 @@ split_static_library("ui") { ...@@ -3081,6 +3081,8 @@ split_static_library("ui") {
"views/network_profile_bubble_view.cc", "views/network_profile_bubble_view.cc",
"views/settings_reset_prompt_dialog.cc", "views/settings_reset_prompt_dialog.cc",
"views/settings_reset_prompt_dialog.h", "views/settings_reset_prompt_dialog.h",
"views/srt_prompt_dialog.cc",
"views/srt_prompt_dialog.h",
"views/uninstall_view.cc", "views/uninstall_view.cc",
"views/uninstall_view.h", "views/uninstall_view.h",
"webui/cleanup_tool/cleanup_action_handler.cc", "webui/cleanup_tool/cleanup_action_handler.cc",
......
...@@ -55,6 +55,10 @@ class PaymentRequest; ...@@ -55,6 +55,10 @@ class PaymentRequest;
class PaymentRequestDialog; class PaymentRequestDialog;
} }
namespace safe_browsing {
class SRTPromptController;
}
namespace security_state { namespace security_state {
struct SecurityInfo; struct SecurityInfo;
} // namespace security_state } // namespace security_state
...@@ -189,6 +193,16 @@ enum class DialogIdentifier { UNKNOWN = 0, TRANSLATE = 1, MAX_VALUE }; ...@@ -189,6 +193,16 @@ enum class DialogIdentifier { UNKNOWN = 0, TRANSLATE = 1, MAX_VALUE };
// Record an UMA metric counting the creation of a dialog box of this type. // Record an UMA metric counting the creation of a dialog box of this type.
void RecordDialogCreation(DialogIdentifier identifier); void RecordDialogCreation(DialogIdentifier identifier);
#if defined(OS_WIN)
// Shows the Chrome Cleanup dialog asking the user if they want to clean their
// system from unwanted software. This is called when unwanted software has been
// detected on the system.
void ShowSRTPrompt(Browser* browser,
safe_browsing::SRTPromptController* controller);
#endif // OS_WIN
} // namespace chrome } // namespace chrome
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
This diff is collapsed.
// Copyright 2017 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_SRT_PROMPT_DIALOG_H_
#define CHROME_BROWSER_UI_VIEWS_SRT_PROMPT_DIALOG_H_
#include "base/macros.h"
#include "third_party/skia/include/core/SkColor.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 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).
//
// The strings and icons used in the dialog are provided by a
// |SRTPromptController| object, which will also receive information about how
// the user interacts with the dialog. The controller object owns itself and
// will delete itself once it has received information about the user's
// interaction with the dialog. See the |SRTPromptController| class's
// description for more details.
class SRTPromptDialog : public views::DialogDelegateView,
public views::ButtonListener {
public:
// The |controller| object manages its own lifetime and is not owned by
// |SRTPromptDialog|. See the description of the |SRTPromptController| class
// for details.
explicit SRTPromptDialog(safe_browsing::SRTPromptController* controller);
~SRTPromptDialog() override;
void Show(Browser* browser);
// ui::DialogModel overrides.
bool ShouldDefaultButtonBeBlue() const override;
// views::WidgetDelegate overrides.
ui::ModalType GetModalType() const override;
base::string16 GetWindowTitle() const override;
// views::DialogDelegate overrides.
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool Accept() override;
bool Cancel() override;
// views::View overrides.
gfx::Size GetPreferredSize() const override;
// views::ButtonListener overrides.
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
private:
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_;
views::View* details_view_;
views::LabelButton* details_button_;
DISALLOW_COPY_AND_ASSIGN(SRTPromptDialog);
};
#endif // CHROME_BROWSER_UI_VIEWS_SRT_PROMPT_DIALOG_H_
// Copyright 2017 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/srt_prompt_dialog.h"
#include "base/macros.h"
#include "chrome/browser/safe_browsing/srt_prompt_controller.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "content/public/test/browser_test.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
class SRTPromptDialogTest : public DialogBrowserTest {
public:
SRTPromptDialogTest() {}
void ShowDialog(const std::string& name) override {
chrome::ShowSRTPrompt(browser(), new safe_browsing::SRTPromptController());
}
private:
DISALLOW_COPY_AND_ASSIGN(SRTPromptDialogTest);
};
IN_PROC_BROWSER_TEST_F(SRTPromptDialogTest, InvokeDialog_default) {
RunDialog();
}
} // namespace
...@@ -2592,6 +2592,7 @@ test("browser_tests") { ...@@ -2592,6 +2592,7 @@ test("browser_tests") {
sources += [ sources += [
"../browser/extensions/api/networking_private/networking_private_credentials_getter_browsertest.cc", "../browser/extensions/api/networking_private/networking_private_credentials_getter_browsertest.cc",
"../browser/ui/views/settings_reset_prompt_dialog_browsertest.cc", "../browser/ui/views/settings_reset_prompt_dialog_browsertest.cc",
"../browser/ui/views/srt_prompt_dialog_browsertest.cc",
] ]
} }
if (is_mac || is_win) { if (is_mac || is_win) {
......
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