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

Unified Diff: chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc

Issue 2133893002: [MD settings] disable clear browsing data while it is running (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 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/ui/webui/settings/settings_clear_browsing_data_handler.cc
diff --git a/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc b/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
index ea235fab38ea5438c83fe98b847a90568b04d54d..4fe186e328f7d3484beca6c283a7252c8e7d381e 100644
--- a/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
@@ -42,13 +42,12 @@ ClearBrowsingDataHandler::ClearBrowsingDataHandler(content::WebUI* webui)
sync_service_(ProfileSyncServiceFactory::GetForProfile(profile_)),
sync_service_observer_(this),
remover_(nullptr),
+ remover_observer_(this),
show_history_footer_(false),
show_history_deletion_dialog_(false),
weak_ptr_factory_(this) {}
ClearBrowsingDataHandler::~ClearBrowsingDataHandler() {
- if (remover_)
- remover_->RemoveObserver(this);
}
void ClearBrowsingDataHandler::RegisterMessages() {
@@ -73,9 +72,15 @@ void ClearBrowsingDataHandler::OnJavascriptAllowed() {
if (sync_service_)
sync_service_observer_.Add(sync_service_);
+
+ if (!remover_)
+ remover_ = BrowsingDataRemoverFactory::GetForBrowserContext(profile_);
+
+ remover_observer_.Add(remover_);
}
void ClearBrowsingDataHandler::OnJavascriptDisallowed() {
+ remover_observer_.RemoveAll();
profile_pref_registrar_.RemoveAll();
sync_service_observer_.RemoveAll();
}
@@ -83,7 +88,7 @@ void ClearBrowsingDataHandler::OnJavascriptDisallowed() {
void ClearBrowsingDataHandler::HandleClearBrowsingData(
const base::ListValue* args) {
// We should never be called when the previous clearing has not yet finished.
- CHECK(!remover_);
+ CHECK(!remover_->is_removing());
CHECK_EQ(1U, args->GetSize());
CHECK(webui_callback_id_.empty());
CHECK(args->GetString(0, &webui_callback_id_));
@@ -163,16 +168,18 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData(
int period_selected =
prefs->GetInteger(browsing_data::prefs::kDeleteTimePeriod);
- remover_ = BrowsingDataRemoverFactory::GetForBrowserContext(profile_);
- remover_->AddObserver(this);
remover_->Remove(BrowsingDataRemover::Period(
static_cast<browsing_data::TimePeriod>(period_selected)),
remove_mask, origin_mask);
}
-void ClearBrowsingDataHandler::OnBrowsingDataRemoverDone() {
- remover_->RemoveObserver(this);
- remover_ = nullptr;
+void ClearBrowsingDataHandler::OnBrowsingDataRemoving(bool is_removing) {
+ CallJavascriptFunction("cr.webUIListenerCallback",
+ base::StringValue("browsing-data-removing"),
+ base::FundamentalValue(is_removing));
+
+ if (is_removing || webui_callback_id_.empty())
+ return;
PrefService* prefs = profile_->GetPrefs();
int notice_shown_times =
@@ -214,6 +221,8 @@ void ClearBrowsingDataHandler::OnBrowsingHistoryPrefChanged() {
void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) {
AllowJavascript();
+ const base::Value* callback_id;
+ CHECK(args->Get(0, &callback_id));
// TODO(msramek): Simplify this using a factory.
AddCounter(base::WrapUnique(new AutofillCounter(profile_)));
dpapad 2016/07/08 23:09:43 initialize() can be called multiple times (close d
Dan Beam 2016/07/08 23:26:58 Done.
@@ -226,6 +235,9 @@ void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) {
OnStateChanged();
RefreshHistoryNotice();
+
+ ResolveJavascriptCallback(*callback_id,
+ base::FundamentalValue(remover_->is_removing()));
}
void ClearBrowsingDataHandler::OnStateChanged() {
@@ -269,7 +281,7 @@ void ClearBrowsingDataHandler::UpdateHistoryNotice(bool show) {
}
void ClearBrowsingDataHandler::UpdateHistoryDeletionDialog(bool show) {
- // This is used by OnBrowsingDataRemoverDone (when the deletion finishes).
+ // This is used by OnBrowsingDataRemoving (when the deletion finishes).
show_history_deletion_dialog_ = show;
}

Powered by Google App Engine
This is Rietveld 408576698