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

Side by Side Diff: chrome/browser/ui/webui/options/clear_browser_data_handler.cc

Issue 2666093002: Remove base::FundamentalValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/options/clear_browser_data_handler.h" 5 #include "chrome/browser/ui/webui/options/clear_browser_data_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 104
105 sync_service_ = ProfileSyncServiceFactory::GetForProfile(profile); 105 sync_service_ = ProfileSyncServiceFactory::GetForProfile(profile);
106 if (sync_service_) 106 if (sync_service_)
107 sync_service_->AddObserver(this); 107 sync_service_->AddObserver(this);
108 } 108 }
109 } 109 }
110 110
111 void ClearBrowserDataHandler::InitializePage() { 111 void ClearBrowserDataHandler::InitializePage() {
112 web_ui()->CallJavascriptFunctionUnsafe( 112 web_ui()->CallJavascriptFunctionUnsafe(
113 "ClearBrowserDataOverlay.createFooter", 113 "ClearBrowserDataOverlay.createFooter", base::Value(AreCountersEnabled()),
114 base::FundamentalValue(AreCountersEnabled()), 114 base::Value(sync_service_ && sync_service_->IsSyncActive()),
115 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), 115 base::Value(should_show_history_notice_));
116 base::FundamentalValue(should_show_history_notice_));
117 RefreshHistoryNotice(); 116 RefreshHistoryNotice();
118 UpdateInfoBannerVisibility(); 117 UpdateInfoBannerVisibility();
119 OnBrowsingHistoryPrefChanged(); 118 OnBrowsingHistoryPrefChanged();
120 bool removal_in_progress = !!remover_; 119 bool removal_in_progress = !!remover_;
121 web_ui()->CallJavascriptFunctionUnsafe( 120 web_ui()->CallJavascriptFunctionUnsafe("ClearBrowserDataOverlay.setClearing",
122 "ClearBrowserDataOverlay.setClearing", 121 base::Value(removal_in_progress));
123 base::FundamentalValue(removal_in_progress));
124 122
125 web_ui()->CallJavascriptFunctionUnsafe( 123 web_ui()->CallJavascriptFunctionUnsafe(
126 "ClearBrowserDataOverlay.markInitializationComplete"); 124 "ClearBrowserDataOverlay.markInitializationComplete");
127 } 125 }
128 126
129 void ClearBrowserDataHandler::UpdateInfoBannerVisibility() { 127 void ClearBrowserDataHandler::UpdateInfoBannerVisibility() {
130 base::string16 text; 128 base::string16 text;
131 129
132 Profile* profile = Profile::FromWebUI(web_ui()); 130 Profile* profile = Profile::FromWebUI(web_ui());
133 auto availability = IncognitoModePrefs::GetAvailability(profile->GetPrefs()); 131 auto availability = IncognitoModePrefs::GetAvailability(profile->GetPrefs());
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 // Increment the preference. 354 // Increment the preference.
357 prefs->SetInteger( 355 prefs->SetInteger(
358 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes, 356 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes,
359 notice_shown_times + 1); 357 notice_shown_times + 1);
360 } 358 }
361 359
362 UMA_HISTOGRAM_BOOLEAN( 360 UMA_HISTOGRAM_BOOLEAN(
363 "History.ClearBrowsingData.ShownHistoryNoticeAfterClearing", show_notice); 361 "History.ClearBrowsingData.ShownHistoryNoticeAfterClearing", show_notice);
364 362
365 web_ui()->CallJavascriptFunctionUnsafe("ClearBrowserDataOverlay.doneClearing", 363 web_ui()->CallJavascriptFunctionUnsafe("ClearBrowserDataOverlay.doneClearing",
366 base::FundamentalValue(show_notice)); 364 base::Value(show_notice));
367 } 365 }
368 366
369 void ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged() { 367 void ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged() {
370 web_ui()->CallJavascriptFunctionUnsafe( 368 web_ui()->CallJavascriptFunctionUnsafe(
371 "ClearBrowserDataOverlay.setAllowDeletingHistory", 369 "ClearBrowserDataOverlay.setAllowDeletingHistory",
372 base::FundamentalValue(*allow_deleting_browser_history_)); 370 base::Value(*allow_deleting_browser_history_));
373 } 371 }
374 372
375 void ClearBrowserDataHandler::AddCounter( 373 void ClearBrowserDataHandler::AddCounter(
376 std::unique_ptr<browsing_data::BrowsingDataCounter> counter) { 374 std::unique_ptr<browsing_data::BrowsingDataCounter> counter) {
377 DCHECK(AreCountersEnabled()); 375 DCHECK(AreCountersEnabled());
378 376
379 counter->Init(Profile::FromWebUI(web_ui())->GetPrefs(), 377 counter->Init(Profile::FromWebUI(web_ui())->GetPrefs(),
380 base::Bind(&ClearBrowserDataHandler::UpdateCounterText, 378 base::Bind(&ClearBrowserDataHandler::UpdateCounterText,
381 base::Unretained(this))); 379 base::Unretained(this)));
382 counters_.push_back(std::move(counter)); 380 counters_.push_back(std::move(counter));
383 } 381 }
384 382
385 void ClearBrowserDataHandler::UpdateCounterText( 383 void ClearBrowserDataHandler::UpdateCounterText(
386 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { 384 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) {
387 DCHECK(AreCountersEnabled()); 385 DCHECK(AreCountersEnabled());
388 web_ui()->CallJavascriptFunctionUnsafe( 386 web_ui()->CallJavascriptFunctionUnsafe(
389 "ClearBrowserDataOverlay.updateCounter", 387 "ClearBrowserDataOverlay.updateCounter",
390 base::StringValue(result->source()->GetPrefName()), 388 base::StringValue(result->source()->GetPrefName()),
391 base::StringValue(GetChromeCounterTextFromResult(result.get()))); 389 base::StringValue(GetChromeCounterTextFromResult(result.get())));
392 } 390 }
393 391
394 void ClearBrowserDataHandler::OnStateChanged(syncer::SyncService* sync) { 392 void ClearBrowserDataHandler::OnStateChanged(syncer::SyncService* sync) {
395 UpdateSyncState(); 393 UpdateSyncState();
396 } 394 }
397 395
398 void ClearBrowserDataHandler::UpdateSyncState() { 396 void ClearBrowserDataHandler::UpdateSyncState() {
399 web_ui()->CallJavascriptFunctionUnsafe( 397 web_ui()->CallJavascriptFunctionUnsafe(
400 "ClearBrowserDataOverlay.updateSyncWarningAndHistoryFooter", 398 "ClearBrowserDataOverlay.updateSyncWarningAndHistoryFooter",
401 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), 399 base::Value(sync_service_ && sync_service_->IsSyncActive()),
402 base::FundamentalValue(should_show_history_notice_)); 400 base::Value(should_show_history_notice_));
403 } 401 }
404 402
405 void ClearBrowserDataHandler::RefreshHistoryNotice() { 403 void ClearBrowserDataHandler::RefreshHistoryNotice() {
406 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( 404 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory(
407 sync_service_, 405 sync_service_,
408 WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())), 406 WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())),
409 base::Bind(&ClearBrowserDataHandler::UpdateHistoryNotice, 407 base::Bind(&ClearBrowserDataHandler::UpdateHistoryNotice,
410 weak_ptr_factory_.GetWeakPtr())); 408 weak_ptr_factory_.GetWeakPtr()));
411 409
412 // If the dialog with history notice has been shown less than 410 // If the dialog with history notice has been shown less than
(...skipping 20 matching lines...) Expand all
433 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", 431 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated",
434 should_show_history_notice_); 432 should_show_history_notice_);
435 } 433 }
436 434
437 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) { 435 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) {
438 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes). 436 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes).
439 should_show_history_deletion_dialog_ = show; 437 should_show_history_deletion_dialog_ = show;
440 } 438 }
441 439
442 } // namespace options 440 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698