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

Unified Diff: chrome/browser/ui/webui/options/reset_profile_settings_handler.cc

Issue 533183002: Revert "Eliminate all code related to the AutomaticProfileResetter." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed next set of comments from gab@. Created 6 years, 3 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/ui/webui/options/reset_profile_settings_handler.cc
diff --git a/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc b/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc
index cd4db5e7cb74362a05bb21321eeec7a7e3c48029..93e5778ed722735e4cee10aa633b5609a05e38ec 100644
--- a/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc
@@ -11,6 +11,8 @@
#include "base/strings/string16.h"
#include "base/values.h"
#include "chrome/browser/google/google_brand.h"
+#include "chrome/browser/profile_resetter/automatic_profile_resetter.h"
+#include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
#include "chrome/browser/profile_resetter/brandcode_config_fetcher.h"
#include "chrome/browser/profile_resetter/brandcoded_default_settings.h"
#include "chrome/browser/profile_resetter/profile_resetter.h"
@@ -24,7 +26,8 @@
namespace options {
-ResetProfileSettingsHandler::ResetProfileSettingsHandler() {
+ResetProfileSettingsHandler::ResetProfileSettingsHandler()
+ : automatic_profile_resetter_(NULL), has_shown_confirmation_dialog_(false) {
Dan Beam 2014/09/05 19:21:45 nit: \n after ,
engedy 2014/09/10 13:46:26 Done.
google_brand::GetBrand(&brandcode_);
}
@@ -33,12 +36,24 @@ ResetProfileSettingsHandler::~ResetProfileSettingsHandler() {}
void ResetProfileSettingsHandler::InitializeHandler() {
Profile* profile = Profile::FromWebUI(web_ui());
resetter_.reset(new ProfileResetter(profile));
+ automatic_profile_resetter_ =
+ AutomaticProfileResetterFactory::GetForBrowserContext(profile);
}
void ResetProfileSettingsHandler::InitializePage() {
web_ui()->CallJavascriptFunction(
"ResetProfileSettingsOverlay.setResettingState",
base::FundamentalValue(resetter_->IsActive()));
+ if (automatic_profile_resetter_ &&
+ automatic_profile_resetter_->ShouldShowResetBanner())
Dan Beam 2014/09/05 19:21:45 curlies
engedy 2014/09/10 13:46:26 Done.
+ web_ui()->CallJavascriptFunction("ResetProfileSettingsBanner.show");
+}
+
+void ResetProfileSettingsHandler::Uninitialize() {
+ if (has_shown_confirmation_dialog_ && automatic_profile_resetter_) {
+ automatic_profile_resetter_->NotifyDidCloseWebUIResetDialog(
+ false /*performed_reset*/);
+ }
}
void ResetProfileSettingsHandler::GetLocalizedValues(
@@ -46,6 +61,8 @@ void ResetProfileSettingsHandler::GetLocalizedValues(
DCHECK(localized_strings);
static OptionsStringResource resources[] = {
+ { "resetProfileSettingsBannerText",
+ IDS_RESET_PROFILE_SETTINGS_BANNER_TEXT },
{ "resetProfileSettingsCommit", IDS_RESET_PROFILE_SETTINGS_COMMIT_BUTTON },
{ "resetProfileSettingsExplanation",
IDS_RESET_PROFILE_SETTINGS_EXPLANATION },
@@ -71,6 +88,10 @@ void ResetProfileSettingsHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("onHideResetProfileDialog",
base::Bind(&ResetProfileSettingsHandler::OnHideResetProfileDialog,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback("onDismissedResetProfileSettingsBanner",
+ base::Bind(&ResetProfileSettingsHandler::
+ OnDismissedResetProfileSettingsBanner,
Dan Beam 2014/09/05 19:21:45 usually these methods are named HandleChromeSendNa
engedy 2014/09/10 13:46:26 True. However, the messages above also use this di
Dan Beam 2014/09/10 19:14:44 I don't say I feel *strongly* as there is a bit of
+ base::Unretained(this)));
}
void ResetProfileSettingsHandler::HandleResetProfileSettings(
@@ -102,10 +123,17 @@ void ResetProfileSettingsHandler::OnResetProfileSettingsDone(
setting_snapshot_->Subtract(current_snapshot);
std::string report = SerializeSettingsReport(*setting_snapshot_,
difference);
- SendSettingsFeedback(report, profile);
+ bool is_reset_prompt_active = automatic_profile_resetter_ &&
+ automatic_profile_resetter_->IsResetPromptFlowActive();
+ SendSettingsFeedback(report, profile, is_reset_prompt_active ?
+ PROFILE_RESET_PROMPT : PROFILE_RESET_WEBUI);
}
}
setting_snapshot_.reset();
+ if (automatic_profile_resetter_) {
+ automatic_profile_resetter_->NotifyDidCloseWebUIResetDialog(
+ true /*performed_reset*/);
+ }
}
void ResetProfileSettingsHandler::OnShowResetProfileDialog(
@@ -118,6 +146,10 @@ void ResetProfileSettingsHandler::OnShowResetProfileDialog(
UpdateFeedbackUI();
}
+ if (automatic_profile_resetter_)
+ automatic_profile_resetter_->NotifyDidOpenWebUIResetDialog();
+ has_shown_confirmation_dialog_ = true;
+
if (brandcode_.empty())
return;
config_fetcher_.reset(new BrandcodeConfigFetcher(
@@ -133,6 +165,12 @@ void ResetProfileSettingsHandler::OnHideResetProfileDialog(
setting_snapshot_.reset();
}
+void ResetProfileSettingsHandler::OnDismissedResetProfileSettingsBanner(
+ const base::ListValue* args) {
+ if (automatic_profile_resetter_)
+ automatic_profile_resetter_->NotifyDidCloseWebUIResetBanner();
+}
+
void ResetProfileSettingsHandler::OnSettingsFetched() {
DCHECK(config_fetcher_);
DCHECK(!config_fetcher_->IsActive());

Powered by Google App Engine
This is Rietveld 408576698