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

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

Issue 2918053003: Settings reset prompt: Fetch default settings only when needed. (Closed)
Patch Set: Addressed Chris's comment Created 3 years, 6 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT _CONTROLLER_H_ 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_ 6 #define CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT _CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "ui/gfx/range/range.h" 14 #include "ui/gfx/range/range.h"
15 15
16 class BrandcodedDefaultSettings;
16 class Browser; 17 class Browser;
17 18
18 namespace safe_browsing { 19 namespace safe_browsing {
19 20
20 class SettingsResetPromptModel; 21 class SettingsResetPromptModel;
21 22
22 // The |SettingsResetPromptController| class is responsible for providing the 23 // The |SettingsResetPromptController| class is responsible for providing the
23 // text that will be displayed in the settings reset dialog. The controller's 24 // text that will be displayed in the settings reset dialog. The controller's
24 // |Accept()| and |Cancel()| functions will be called based on user 25 // |Accept()| and |Cancel()| functions will be called based on user
25 // interaction. Objects of this class will delete themselves after |Accept()| or 26 // interaction. Objects of this class will delete themselves after |Accept()| or
26 // |Cancel()| has been called. 27 // |Cancel()| has been called.
27 class SettingsResetPromptController { 28 class SettingsResetPromptController {
28 public: 29 public:
29 // A controller should be created only if |model->ShouldPromptforReset()| 30 // A controller should be created only if |model->ShouldPromptforReset()|
30 // is true. 31 // is true.
31 explicit SettingsResetPromptController( 32 SettingsResetPromptController(
32 std::unique_ptr<SettingsResetPromptModel> model); 33 std::unique_ptr<SettingsResetPromptModel> model,
34 std::unique_ptr<BrandcodedDefaultSettings> default_settings);
33 35
34 static void ShowSettingsResetPrompt( 36 static void ShowSettingsResetPrompt(
35 Browser* browser, 37 Browser* browser,
36 SettingsResetPromptController* controller); 38 SettingsResetPromptController* controller);
37 39
38 base::string16 GetWindowTitle() const; 40 base::string16 GetWindowTitle() const;
39 base::string16 GetButtonLabel() const; 41 base::string16 GetButtonLabel() const;
40 base::string16 GetMainText() const; 42 base::string16 GetMainText() const;
41 // Returns the offset into the main text string where a URL was inserted. To 43 // Returns the offset into the main text string where a URL was inserted. To
42 // be used by the dialog to apply an appropriate style to the URL text. 44 // be used by the dialog to apply an appropriate style to the URL text.
(...skipping 15 matching lines...) Expand all
58 60
59 private: 61 private:
60 ~SettingsResetPromptController(); 62 ~SettingsResetPromptController();
61 void InitMainText(); 63 void InitMainText();
62 // Function to be called sometime after |Accept()| or |Cancel()| has been 64 // Function to be called sometime after |Accept()| or |Cancel()| has been
63 // called to perform any final tasks (such as metrcis reporting) and delete 65 // called to perform any final tasks (such as metrcis reporting) and delete
64 // this object. 66 // this object.
65 void OnInteractionDone(); 67 void OnInteractionDone();
66 68
67 std::unique_ptr<SettingsResetPromptModel> model_; 69 std::unique_ptr<SettingsResetPromptModel> model_;
70 std::unique_ptr<BrandcodedDefaultSettings> default_settings_;
68 base::string16 main_text_; 71 base::string16 main_text_;
69 gfx::Range main_text_url_range_; 72 gfx::Range main_text_url_range_;
70 73
71 // Used for metrics reporting. 74 // Used for metrics reporting.
72 base::Time time_dialog_shown_; 75 base::Time time_dialog_shown_;
73 76
74 DISALLOW_COPY_AND_ASSIGN(SettingsResetPromptController); 77 DISALLOW_COPY_AND_ASSIGN(SettingsResetPromptController);
75 }; 78 };
76 79
77 // Function to be called after startup in order to display the settings reset 80 // Function to be called after startup in order to display the settings reset
78 // prompt. The function will figure out if a prompt is needed, and if so, show 81 // prompt. The function will figure out if a prompt is needed, and if so, show
79 // the dialog after a delay as determined by the |kSettingsResetPrompt| 82 // the dialog after a delay as determined by the |kSettingsResetPrompt|
80 // feature parameters. 83 // feature parameters.
81 void MaybeShowSettingsResetPromptWithDelay(); 84 void MaybeShowSettingsResetPromptWithDelay();
82 85
83 } // namespace safe_browsing 86 } // namespace safe_browsing
84 87
85 #endif // CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PRO MPT_CONTROLLER_H_ 88 #endif // CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PRO MPT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698