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

Side by Side Diff: chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc

Issue 2657673004: Add shutdown notification and service refs to SyncServiceObserver. (Closed)
Patch Set: Use parameter Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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
248 } 248 }
249 249
250 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) { 250 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) {
251 AllowJavascript(); 251 AllowJavascript();
252 const base::Value* callback_id; 252 const base::Value* callback_id;
253 CHECK(args->Get(0, &callback_id)); 253 CHECK(args->Get(0, &callback_id));
254 254
255 // Needed because WebUI doesn't handle renderer crashes. See crbug.com/610450. 255 // Needed because WebUI doesn't handle renderer crashes. See crbug.com/610450.
256 task_observer_.reset(); 256 task_observer_.reset();
257 257
258 OnStateChanged(); 258 OnStateChanged(nullptr);
sky 2017/01/27 16:29:44 Same comment above using another function.
Steven Holte 2017/01/27 20:11:45 Done.
259 RefreshHistoryNotice(); 259 RefreshHistoryNotice();
260 260
261 // Restart the counters each time the dialog is reopened. 261 // Restart the counters each time the dialog is reopened.
262 for (const auto& counter : counters_) 262 for (const auto& counter : counters_)
263 counter->Restart(); 263 counter->Restart();
264 264
265 ResolveJavascriptCallback( 265 ResolveJavascriptCallback(
266 *callback_id, 266 *callback_id,
267 *base::Value::CreateNullValue() /* Promise<void> */); 267 *base::Value::CreateNullValue() /* Promise<void> */);
268 } 268 }
269 269
270 void ClearBrowsingDataHandler::OnStateChanged() { 270 void ClearBrowsingDataHandler::OnStateChanged(syncer::SyncService* sync) {
271 CallJavascriptFunction( 271 CallJavascriptFunction(
272 "cr.webUIListenerCallback", 272 "cr.webUIListenerCallback",
273 base::StringValue("update-footer"), 273 base::StringValue("update-footer"),
274 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), 274 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()),
275 base::FundamentalValue(show_history_footer_)); 275 base::FundamentalValue(show_history_footer_));
276 } 276 }
277 277
278 void ClearBrowsingDataHandler::RefreshHistoryNotice() { 278 void ClearBrowsingDataHandler::RefreshHistoryNotice() {
279 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( 279 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory(
280 sync_service_, 280 sync_service_,
(...skipping 12 matching lines...) Expand all
293 sync_service_, 293 sync_service_,
294 WebHistoryServiceFactory::GetForProfile(profile_), 294 WebHistoryServiceFactory::GetForProfile(profile_),
295 chrome::GetChannel(), 295 chrome::GetChannel(),
296 base::Bind(&ClearBrowsingDataHandler::UpdateHistoryDeletionDialog, 296 base::Bind(&ClearBrowsingDataHandler::UpdateHistoryDeletionDialog,
297 weak_ptr_factory_.GetWeakPtr())); 297 weak_ptr_factory_.GetWeakPtr()));
298 } 298 }
299 } 299 }
300 300
301 void ClearBrowsingDataHandler::UpdateHistoryNotice(bool show) { 301 void ClearBrowsingDataHandler::UpdateHistoryNotice(bool show) {
302 show_history_footer_ = show; 302 show_history_footer_ = show;
303 OnStateChanged(); 303 OnStateChanged(nullptr);
304 304
305 UMA_HISTOGRAM_BOOLEAN( 305 UMA_HISTOGRAM_BOOLEAN(
306 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", 306 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated",
307 show_history_footer_); 307 show_history_footer_);
308 } 308 }
309 309
310 void ClearBrowsingDataHandler::UpdateHistoryDeletionDialog(bool show) { 310 void ClearBrowsingDataHandler::UpdateHistoryDeletionDialog(bool show) {
311 // This is used by OnClearingTaskFinished (when the deletion finishes). 311 // This is used by OnClearingTaskFinished (when the deletion finishes).
312 show_history_deletion_dialog_ = show; 312 show_history_deletion_dialog_ = show;
313 } 313 }
314 314
315 void ClearBrowsingDataHandler::AddCounter( 315 void ClearBrowsingDataHandler::AddCounter(
316 std::unique_ptr<browsing_data::BrowsingDataCounter> counter) { 316 std::unique_ptr<browsing_data::BrowsingDataCounter> counter) {
317 counter->Init(profile_->GetPrefs(), 317 counter->Init(profile_->GetPrefs(),
318 base::Bind(&ClearBrowsingDataHandler::UpdateCounterText, 318 base::Bind(&ClearBrowsingDataHandler::UpdateCounterText,
319 base::Unretained(this))); 319 base::Unretained(this)));
320 counters_.push_back(std::move(counter)); 320 counters_.push_back(std::move(counter));
321 } 321 }
322 322
323 void ClearBrowsingDataHandler::UpdateCounterText( 323 void ClearBrowsingDataHandler::UpdateCounterText(
324 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { 324 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) {
325 CallJavascriptFunction( 325 CallJavascriptFunction(
326 "cr.webUIListenerCallback", 326 "cr.webUIListenerCallback",
327 base::StringValue("update-counter-text"), 327 base::StringValue("update-counter-text"),
328 base::StringValue(result->source()->GetPrefName()), 328 base::StringValue(result->source()->GetPrefName()),
329 base::StringValue(GetChromeCounterTextFromResult(result.get()))); 329 base::StringValue(GetChromeCounterTextFromResult(result.get())));
330 } 330 }
331 331
332 } // namespace settings 332 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698