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

Unified Diff: chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc

Issue 2971183002: Enforces order for settings reset (Closed)
Patch Set: Add browser test for dependency Created 3 years, 5 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.cc
diff --git a/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc b/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc
index 0d79644dd97f8e4cdf6f14cbececcc9225f92df0..b8e9169c0db2c9dff00aba903c6557ec4abde4b7 100644
--- a/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc
+++ b/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc
@@ -107,6 +107,36 @@ void MaybeShowSettingsResetPrompt(
base::Bind(&TryToShowSettingsResetPrompt, base::Passed(&model)));
}
+class SettingsResetPromptDelegateImpl : public SettingsResetPromptDelegate {
+ public:
+ SettingsResetPromptDelegateImpl();
+ ~SettingsResetPromptDelegateImpl() override;
+
+ void ShowSettingsResetPromptWithDelay() const override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SettingsResetPromptDelegateImpl);
+};
+
+SettingsResetPromptDelegateImpl::SettingsResetPromptDelegateImpl() = default;
+
+SettingsResetPromptDelegateImpl::~SettingsResetPromptDelegateImpl() = default;
+
+void SettingsResetPromptDelegateImpl::ShowSettingsResetPromptWithDelay() const {
+ std::unique_ptr<SettingsResetPromptConfig> config =
+ SettingsResetPromptConfig::Create();
+ if (!config)
+ return;
+
+ base::TimeDelta delay = config->delay_before_prompt();
+ content::BrowserThread::PostDelayedTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::BindOnce(MaybeShowSettingsResetPrompt, base::Passed(&config)),
+ delay);
+}
+
+SettingsResetPromptDelegate* g_settings_reset_prompt_delegate = nullptr;
+
} // namespace.
SettingsResetPromptController::SettingsResetPromptController(
@@ -257,16 +287,19 @@ void SettingsResetPromptController::OnInteractionDone() {
}
void MaybeShowSettingsResetPromptWithDelay() {
- std::unique_ptr<SettingsResetPromptConfig> config =
- SettingsResetPromptConfig::Create();
- if (!config)
- return;
+ if (g_settings_reset_prompt_delegate) {
+ g_settings_reset_prompt_delegate->ShowSettingsResetPromptWithDelay();
+ } else {
+ SettingsResetPromptDelegateImpl().ShowSettingsResetPromptWithDelay();
+ }
+}
- base::TimeDelta delay = config->delay_before_prompt();
- content::BrowserThread::PostDelayedTask(
- content::BrowserThread::UI, FROM_HERE,
- base::BindOnce(MaybeShowSettingsResetPrompt, base::Passed(&config)),
- delay);
+SettingsResetPromptDelegate::SettingsResetPromptDelegate() = default;
+
+SettingsResetPromptDelegate::~SettingsResetPromptDelegate() = default;
+
+void SetSettingsResetPromptDelegate(SettingsResetPromptDelegate* delegate) {
+ g_settings_reset_prompt_delegate = delegate;
}
} // namespace safe_browsing
« no previous file with comments | « chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698