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

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

Issue 2118503005: [MD settings] disable clear browsing data while it is running (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved init to attached 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..154664ae100cc5f3e36ee2bd861b1644dca18d5f 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,16 @@ void ClearBrowsingDataHandler::OnJavascriptAllowed() {
if (sync_service_)
sync_service_observer_.Add(sync_service_);
+
+ if (!remover_) {
Dan Beam 2016/07/08 19:27:44 no curlies
+ remover_ = BrowsingDataRemoverFactory::GetForBrowserContext(profile_);
+ }
+
+ remover_observer_.Add(remover_);
}
void ClearBrowsingDataHandler::OnJavascriptDisallowed() {
+ remover_observer_.RemoveAll();
profile_pref_registrar_.RemoveAll();
sync_service_observer_.RemoveAll();
}
@@ -83,7 +89,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,17 +169,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));
+}
+void ClearBrowsingDataHandler::OnBrowsingDataRemoverDone() {
PrefService* prefs = profile_->GetPrefs();
int notice_shown_times =
prefs->GetInteger(prefs::kClearBrowsingDataHistoryNoticeShownTimes);
@@ -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_)));
@@ -226,6 +235,9 @@ void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) {
OnStateChanged();
RefreshHistoryNotice();
+ OnBrowsingDataRemoving(remover_->is_removing());
+
+ ResolveJavascriptCallback(*callback_id, *base::Value::CreateNullValue());
}
void ClearBrowsingDataHandler::OnStateChanged() {

Powered by Google App Engine
This is Rietveld 408576698