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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 if (show_notice) { | 234 if (show_notice) { |
235 // Increment the preference. | 235 // Increment the preference. |
236 prefs->SetInteger( | 236 prefs->SetInteger( |
237 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes, | 237 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes, |
238 notice_shown_times + 1); | 238 notice_shown_times + 1); |
239 } | 239 } |
240 | 240 |
241 UMA_HISTOGRAM_BOOLEAN( | 241 UMA_HISTOGRAM_BOOLEAN( |
242 "History.ClearBrowsingData.ShownHistoryNoticeAfterClearing", show_notice); | 242 "History.ClearBrowsingData.ShownHistoryNoticeAfterClearing", show_notice); |
243 | 243 |
244 ResolveJavascriptCallback(base::StringValue(webui_callback_id), | 244 ResolveJavascriptCallback(base::Value(webui_callback_id), |
245 base::Value(show_notice)); | 245 base::Value(show_notice)); |
246 task_observer_.reset(); | 246 task_observer_.reset(); |
247 } | 247 } |
248 | 248 |
249 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) { | 249 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) { |
250 AllowJavascript(); | 250 AllowJavascript(); |
251 const base::Value* callback_id; | 251 const base::Value* callback_id; |
252 CHECK(args->Get(0, &callback_id)); | 252 CHECK(args->Get(0, &callback_id)); |
253 | 253 |
254 // Needed because WebUI doesn't handle renderer crashes. See crbug.com/610450. | 254 // Needed because WebUI doesn't handle renderer crashes. See crbug.com/610450. |
(...skipping 10 matching lines...) Expand all Loading... |
265 *callback_id, | 265 *callback_id, |
266 *base::Value::CreateNullValue() /* Promise<void> */); | 266 *base::Value::CreateNullValue() /* Promise<void> */); |
267 } | 267 } |
268 | 268 |
269 void ClearBrowsingDataHandler::OnStateChanged(syncer::SyncService* sync) { | 269 void ClearBrowsingDataHandler::OnStateChanged(syncer::SyncService* sync) { |
270 UpdateSyncState(); | 270 UpdateSyncState(); |
271 } | 271 } |
272 | 272 |
273 void ClearBrowsingDataHandler::UpdateSyncState() { | 273 void ClearBrowsingDataHandler::UpdateSyncState() { |
274 CallJavascriptFunction( | 274 CallJavascriptFunction( |
275 "cr.webUIListenerCallback", base::StringValue("update-footer"), | 275 "cr.webUIListenerCallback", base::Value("update-footer"), |
276 base::Value(sync_service_ && sync_service_->IsSyncActive()), | 276 base::Value(sync_service_ && sync_service_->IsSyncActive()), |
277 base::Value(show_history_footer_)); | 277 base::Value(show_history_footer_)); |
278 } | 278 } |
279 | 279 |
280 void ClearBrowsingDataHandler::RefreshHistoryNotice() { | 280 void ClearBrowsingDataHandler::RefreshHistoryNotice() { |
281 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( | 281 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( |
282 sync_service_, | 282 sync_service_, |
283 WebHistoryServiceFactory::GetForProfile(profile_), | 283 WebHistoryServiceFactory::GetForProfile(profile_), |
284 base::Bind(&ClearBrowsingDataHandler::UpdateHistoryNotice, | 284 base::Bind(&ClearBrowsingDataHandler::UpdateHistoryNotice, |
285 weak_ptr_factory_.GetWeakPtr())); | 285 weak_ptr_factory_.GetWeakPtr())); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 counter->Init(profile_->GetPrefs(), | 319 counter->Init(profile_->GetPrefs(), |
320 browsing_data::ClearBrowsingDataTab::ADVANCED, | 320 browsing_data::ClearBrowsingDataTab::ADVANCED, |
321 base::Bind(&ClearBrowsingDataHandler::UpdateCounterText, | 321 base::Bind(&ClearBrowsingDataHandler::UpdateCounterText, |
322 base::Unretained(this))); | 322 base::Unretained(this))); |
323 counters_.push_back(std::move(counter)); | 323 counters_.push_back(std::move(counter)); |
324 } | 324 } |
325 | 325 |
326 void ClearBrowsingDataHandler::UpdateCounterText( | 326 void ClearBrowsingDataHandler::UpdateCounterText( |
327 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { | 327 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { |
328 CallJavascriptFunction( | 328 CallJavascriptFunction( |
329 "cr.webUIListenerCallback", base::StringValue("update-counter-text"), | 329 "cr.webUIListenerCallback", base::Value("update-counter-text"), |
330 base::StringValue(result->source()->GetPrefName()), | 330 base::Value(result->source()->GetPrefName()), |
331 base::StringValue(GetChromeCounterTextFromResult(result.get()))); | 331 base::Value(GetChromeCounterTextFromResult(result.get()))); |
332 } | 332 } |
333 | 333 |
334 } // namespace settings | 334 } // namespace settings |
OLD | NEW |