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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.h
diff --git a/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.h b/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..85f49faba436b4c74a7b36dbc08aceeb63704323
--- /dev/null
+++ b/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.h
@@ -0,0 +1,83 @@
+// 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_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT_CONTROLLER_H_
+#define CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT_CONTROLLER_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/strings/string16.h"
+
+class Browser;
+
+namespace safe_browsing {
+
+class SettingsResetPromptModel;
+
+// The |SettingsResetPromptController| class is responsible for providing the
+// text that will be displayed in the settings reset dialog. The controller's
+// |Accept()| and |Cancel()| functions will be called based on user
+// interaction. Objects of this class will delete themselves after |Accept()| or
+// |Cancel()| has been called.
+class SettingsResetPromptController {
+ public:
+ // A simple struct representing text to be displayed in the dialog.
+ struct LabelInfo {
+ enum LabelType {
+ // Strings of type PARAGRAPH will be displayed by multiline labels.
+ PARAGRAPH,
+ // Strings of type BULLET_ITEM will be displayed as a (possibly elided)
+ // single-line label starting with a bullet point.
+ BULLET_ITEM,
+ };
+
+ LabelInfo(LabelType type, const base::string16& text);
+ // Convenience constructor for displaying resource strings.
+ LabelInfo(LabelType type, int message_id);
+ ~LabelInfo();
+
+ LabelType type;
sky 2017/02/21 17:37:28 If you can, make both of these const.
alito 2017/02/23 02:31:59 Seems hard to accomplish since I'm using a vector
+ base::string16 text;
+ };
+
+ static void ShowSettingsResetPrompt(
+ Browser* browser,
+ SettingsResetPromptController* controller);
+
+ // A controller should be created only if |model->ShouldPromptforReset()|
sky 2017/02/21 17:37:28 constructor/destructor above other functions (see
alito 2017/02/23 02:31:59 Done.
+ // is true.
+ SettingsResetPromptController(
+ std::unique_ptr<SettingsResetPromptModel> model);
+ ~SettingsResetPromptController();
+
+ base::string16 GetWindowTitle();
sky 2017/02/21 17:37:28 GetWindowTitle() const ? Same comment for similar
alito 2017/02/23 02:31:59 Done.
+ base::string16 GetButtonLabel();
+ base::string16 GetShowDetailsLabel();
+ base::string16 GetHideDetailsLabel();
+ std::vector<LabelInfo> GetMainText();
sky 2017/02/21 17:37:28 const std::vector<LabelInfo>& GetMainText() const?
alito 2017/02/23 02:31:59 Done.
+ std::vector<LabelInfo> GetDetailsText();
+ // |Accept()| will be called by the dialog when the user clicks the main
+ // button, after which the dialog will be closed.
+ void Accept();
+ // |Cancel()| will be called by the dialog when the user clicks the dismiss
+ // button on the top right, after which the dialog will be closed.
+ void Cancel();
+
+ private:
+ void InitMainText();
+ void InitDetailsText();
+ // Function to be called sometime after |Accept()| or |Cancel()| has been
+ // called to perform any final tasks (such as metrcis reporting) and delete
+ // this object.
+ void OnInteractionDone();
+
+ std::unique_ptr<SettingsResetPromptModel> model_;
+ std::vector<SettingsResetPromptController::LabelInfo> details_text_;
+ std::vector<SettingsResetPromptController::LabelInfo> main_text_;
+};
sky 2017/02/21 17:37:28 DISALLOW...
alito 2017/02/23 02:31:59 Done.
+
+} // namespace safe_browsing
+
+#endif // CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698