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

Side by Side Diff: chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_model.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
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 _MODEL_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT _MODEL_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT _MODEL_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT _MODEL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 static void Create(Profile* profile, 47 static void Create(Profile* profile,
48 std::unique_ptr<SettingsResetPromptConfig> prompt_config, 48 std::unique_ptr<SettingsResetPromptConfig> prompt_config,
49 CreateCallback callback); 49 CreateCallback callback);
50 static std::unique_ptr<SettingsResetPromptModel> CreateForTesting( 50 static std::unique_ptr<SettingsResetPromptModel> CreateForTesting(
51 Profile* profile, 51 Profile* profile,
52 std::unique_ptr<SettingsResetPromptConfig> prompt_config, 52 std::unique_ptr<SettingsResetPromptConfig> prompt_config,
53 std::unique_ptr<ResettableSettingsSnapshot> settings_snapshot, 53 std::unique_ptr<ResettableSettingsSnapshot> settings_snapshot,
54 std::unique_ptr<BrandcodedDefaultSettings> default_settings, 54 std::unique_ptr<BrandcodedDefaultSettings> default_settings,
55 std::unique_ptr<ProfileResetter> profile_resetter); 55 std::unique_ptr<ProfileResetter> profile_resetter);
56 56
57 ~SettingsResetPromptModel(); 57 virtual ~SettingsResetPromptModel();
58 58
59 Profile* profile() const;
59 SettingsResetPromptConfig* config() const; 60 SettingsResetPromptConfig* config() const;
60 61
61 // Returns true if reset is enabled for any settings type. 62 // Returns true if reset is enabled for any settings type.
62 bool ShouldPromptForReset() const; 63 virtual bool ShouldPromptForReset() const;
63 // Resets the settings whose reset states are set to |RESET_REQUIRED| as 64 // Resets the settings whose reset states are set to |RESET_REQUIRED| as
64 // returned by the methods below. Should be called only on the UI 65 // returned by the methods below. Should be called only on the UI
65 // thread. |done_callback| will called from the UI thread when the reset 66 // thread. |done_callback| will called from the UI thread when the reset
66 // operation has been completed. 67 // operation has been completed.
67 // 68 //
68 // NOTE: Can only be called once during the lifetime of this object. 69 // NOTE: Can only be called once during the lifetime of this object.
69 void PerformReset(const base::Closure& done_callback); 70 virtual void PerformReset(const base::Closure& done_callback);
70 71
71 GURL homepage() const; 72 virtual GURL homepage() const;
72 ResetState homepage_reset_state() const; 73 virtual ResetState homepage_reset_state() const;
73 74
74 GURL default_search() const; 75 virtual GURL default_search() const;
75 ResetState default_search_reset_state() const; 76 virtual ResetState default_search_reset_state() const;
76 77
77 // Returns list of all current startup URLs. Returns empty list if session 78 // Returns list of all current startup URLs. Returns empty list if session
78 // startup is set to show the NTP or restore last session. 79 // startup is set to show the NTP or restore last session.
79 const std::vector<GURL>& startup_urls() const; 80 virtual const std::vector<GURL>& startup_urls() const;
80 // Returns the list of all startup URLs that have a match in the prompt 81 // Returns the list of all startup URLs that have a match in the prompt
81 // config. This is a subset of the URLs returned by |startup_urls()|. 82 // config. This is a subset of the URLs returned by |startup_urls()|.
82 const std::vector<GURL>& startup_urls_to_reset() const; 83 virtual const std::vector<GURL>& startup_urls_to_reset() const;
83 ResetState startup_urls_reset_state() const; 84 virtual ResetState startup_urls_reset_state() const;
84 85
85 // Returns a map of extension ID -> ExtensionInfo for all extensions that will 86 // Returns a map of extension ID -> ExtensionInfo for all extensions that will
86 // be disabled. 87 // be disabled.
87 const ExtensionMap& extensions_to_disable() const; 88 virtual const ExtensionMap& extensions_to_disable() const;
88 89
89 private: 90 protected:
90 static void OnSettingsFetched( 91 // Exposed for mocking in tests.
91 Profile* profile,
92 std::unique_ptr<SettingsResetPromptConfig> prompt_config,
93 SettingsResetPromptModel::CreateCallback callback,
94 std::unique_ptr<BrandcodedDefaultSettings> default_settings);
95
96 SettingsResetPromptModel( 92 SettingsResetPromptModel(
97 Profile* profile, 93 Profile* profile,
98 std::unique_ptr<SettingsResetPromptConfig> prompt_config, 94 std::unique_ptr<SettingsResetPromptConfig> prompt_config,
99 std::unique_ptr<ResettableSettingsSnapshot> settings_snapshot, 95 std::unique_ptr<ResettableSettingsSnapshot> settings_snapshot,
100 std::unique_ptr<BrandcodedDefaultSettings> default_settings, 96 std::unique_ptr<BrandcodedDefaultSettings> default_settings,
101 std::unique_ptr<ProfileResetter> profile_resetter); 97 std::unique_ptr<ProfileResetter> profile_resetter);
102 98
99 private:
100 static void OnSettingsFetched(
101 Profile* profile,
102 std::unique_ptr<SettingsResetPromptConfig> prompt_config,
103 SettingsResetPromptModel::CreateCallback callback,
104 std::unique_ptr<BrandcodedDefaultSettings> default_settings);
105
103 void InitHomepageData(); 106 void InitHomepageData();
104 void InitDefaultSearchData(); 107 void InitDefaultSearchData();
105 void InitExtensionData(); 108 void InitExtensionData();
106 void InitStartupUrlsData(); 109 void InitStartupUrlsData();
107 110
108 Profile* const profile_; 111 Profile* const profile_;
109 std::unique_ptr<SettingsResetPromptConfig> prompt_config_; 112 std::unique_ptr<SettingsResetPromptConfig> prompt_config_;
110 std::unique_ptr<ResettableSettingsSnapshot> settings_snapshot_; 113 std::unique_ptr<ResettableSettingsSnapshot> settings_snapshot_;
111 // |default_settings_| should only be accessed on the UI thread after 114 // |default_settings_| should only be accessed on the UI thread after
112 // construction. 115 // construction.
(...skipping 18 matching lines...) Expand all
131 ResetState startup_urls_reset_state_; 134 ResetState startup_urls_reset_state_;
132 135
133 ExtensionMap extensions_to_disable_; 136 ExtensionMap extensions_to_disable_;
134 137
135 DISALLOW_COPY_AND_ASSIGN(SettingsResetPromptModel); 138 DISALLOW_COPY_AND_ASSIGN(SettingsResetPromptModel);
136 }; 139 };
137 140
138 } // namespace safe_browsing 141 } // namespace safe_browsing
139 142
140 #endif // CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PRO MPT_MODEL_H_ 143 #endif // CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PRO MPT_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698