Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.h

Issue 2701313002: Adds a modal dialog implementation of the settings reset prompt. (Closed)
Patch Set: Fix constness in mock test class Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT _CONTROLLER_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT _CONTROLLER_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "base/strings/string16.h"
13
14 class Browser;
15
16 namespace safe_browsing {
17
18 class SettingsResetPromptModel;
19
20 // The |SettingsResetPromptController| class is responsible for providing the
21 // text that will be displayed in the settings reset dialog. The controller's
22 // |Accept()| and |Cancel()| functions will be called based on user
23 // interaction. Objects of this class will delete themselves after |Accept()| or
24 // |Cancel()| has been called.
25 class SettingsResetPromptController {
26 public:
27 // A simple struct representing text to be displayed in the dialog.
28 struct LabelInfo {
29 enum LabelType {
30 // Strings of type PARAGRAPH will be displayed by multiline labels.
31 PARAGRAPH,
32 // Strings of type BULLET_ITEM will be displayed as a (possibly elided)
33 // single-line label starting with a bullet point.
34 BULLET_ITEM,
35 };
36
37 LabelInfo(LabelType type, const base::string16& text);
38 // Convenience constructor for displaying resource strings.
39 LabelInfo(LabelType type, int message_id);
40 ~LabelInfo();
41
42 LabelType type;
43 base::string16 text;
44 };
45
46 // A controller should be created only if |model->ShouldPromptforReset()|
47 // is true.
48 explicit SettingsResetPromptController(
49 std::unique_ptr<SettingsResetPromptModel> model);
50 static void ShowSettingsResetPrompt(
51 Browser* browser,
52 SettingsResetPromptController* controller);
53
54 base::string16 GetWindowTitle() const;
55 base::string16 GetButtonLabel() const;
56 base::string16 GetShowDetailsLabel() const;
57 base::string16 GetHideDetailsLabel() const;
58 const std::vector<LabelInfo>& GetMainText() const;
59 const std::vector<LabelInfo>& GetDetailsText() const;
60 // |Accept()| will be called by the dialog when the user clicks the main
61 // button, after which the dialog will be closed.
62 void Accept();
63 // |Cancel()| will be called by the dialog when the user clicks the dismiss
64 // button on the top right, after which the dialog will be closed.
65 void Cancel();
66
67 private:
68 ~SettingsResetPromptController();
69 void InitMainText();
70 void InitDetailsText();
71 // Function to be called sometime after |Accept()| or |Cancel()| has been
72 // called to perform any final tasks (such as metrcis reporting) and delete
73 // this object.
74 void OnInteractionDone();
75
76 std::unique_ptr<SettingsResetPromptModel> model_;
77 std::vector<SettingsResetPromptController::LabelInfo> details_text_;
78 std::vector<SettingsResetPromptController::LabelInfo> main_text_;
79
80 DISALLOW_COPY_AND_ASSIGN(SettingsResetPromptController);
81 };
82
83 } // namespace safe_browsing
84
85 #endif // CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PRO MPT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698