| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.
h" | 5 #include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.
h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 AllowJavascript(); | 248 AllowJavascript(); |
| 249 const base::Value* callback_id; | 249 const base::Value* callback_id; |
| 250 CHECK(args->Get(0, &callback_id)); | 250 CHECK(args->Get(0, &callback_id)); |
| 251 | 251 |
| 252 // Needed because WebUI doesn't handle renderer crashes. See crbug.com/610450. | 252 // Needed because WebUI doesn't handle renderer crashes. See crbug.com/610450. |
| 253 task_observer_.reset(); | 253 task_observer_.reset(); |
| 254 | 254 |
| 255 OnStateChanged(); | 255 OnStateChanged(); |
| 256 RefreshHistoryNotice(); | 256 RefreshHistoryNotice(); |
| 257 | 257 |
| 258 // Restart the counters each time the dialog is reopened. |
| 259 for (const auto& counter : counters_) |
| 260 counter->Restart(); |
| 261 |
| 258 ResolveJavascriptCallback( | 262 ResolveJavascriptCallback( |
| 259 *callback_id, | 263 *callback_id, |
| 260 *base::Value::CreateNullValue() /* Promise<void> */); | 264 *base::Value::CreateNullValue() /* Promise<void> */); |
| 261 } | 265 } |
| 262 | 266 |
| 263 void ClearBrowsingDataHandler::OnStateChanged() { | 267 void ClearBrowsingDataHandler::OnStateChanged() { |
| 264 CallJavascriptFunction( | 268 CallJavascriptFunction( |
| 265 "cr.webUIListenerCallback", | 269 "cr.webUIListenerCallback", |
| 266 base::StringValue("update-footer"), | 270 base::StringValue("update-footer"), |
| 267 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), | 271 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 void ClearBrowsingDataHandler::UpdateHistoryDeletionDialog(bool show) { | 307 void ClearBrowsingDataHandler::UpdateHistoryDeletionDialog(bool show) { |
| 304 // This is used by OnClearingTaskFinished (when the deletion finishes). | 308 // This is used by OnClearingTaskFinished (when the deletion finishes). |
| 305 show_history_deletion_dialog_ = show; | 309 show_history_deletion_dialog_ = show; |
| 306 } | 310 } |
| 307 | 311 |
| 308 void ClearBrowsingDataHandler::AddCounter( | 312 void ClearBrowsingDataHandler::AddCounter( |
| 309 std::unique_ptr<browsing_data::BrowsingDataCounter> counter) { | 313 std::unique_ptr<browsing_data::BrowsingDataCounter> counter) { |
| 310 counter->Init(profile_->GetPrefs(), | 314 counter->Init(profile_->GetPrefs(), |
| 311 base::Bind(&ClearBrowsingDataHandler::UpdateCounterText, | 315 base::Bind(&ClearBrowsingDataHandler::UpdateCounterText, |
| 312 base::Unretained(this))); | 316 base::Unretained(this))); |
| 313 counter->Restart(); | |
| 314 counters_.push_back(std::move(counter)); | 317 counters_.push_back(std::move(counter)); |
| 315 } | 318 } |
| 316 | 319 |
| 317 void ClearBrowsingDataHandler::UpdateCounterText( | 320 void ClearBrowsingDataHandler::UpdateCounterText( |
| 318 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { | 321 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { |
| 319 CallJavascriptFunction( | 322 CallJavascriptFunction( |
| 320 "cr.webUIListenerCallback", | 323 "cr.webUIListenerCallback", |
| 321 base::StringValue("update-counter-text"), | 324 base::StringValue("update-counter-text"), |
| 322 base::StringValue(result->source()->GetPrefName()), | 325 base::StringValue(result->source()->GetPrefName()), |
| 323 base::StringValue(GetChromeCounterTextFromResult(result.get()))); | 326 base::StringValue(GetChromeCounterTextFromResult(result.get()))); |
| 324 } | 327 } |
| 325 | 328 |
| 326 } // namespace settings | 329 } // namespace settings |
| OLD | NEW |