OLD | NEW |
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 18 matching lines...) Expand all Loading... |
29 #include "chrome/browser/history/web_history_service_factory.h" | 29 #include "chrome/browser/history/web_history_service_factory.h" |
30 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 30 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
31 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/browser/sync/profile_sync_service_factory.h" | 32 #include "chrome/browser/sync/profile_sync_service_factory.h" |
33 #include "chrome/browser/ui/accelerator_utils.h" | 33 #include "chrome/browser/ui/accelerator_utils.h" |
34 #include "chrome/common/channel_info.h" | 34 #include "chrome/common/channel_info.h" |
35 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
36 #include "chrome/grit/generated_resources.h" | 36 #include "chrome/grit/generated_resources.h" |
37 #include "chrome/grit/locale_settings.h" | 37 #include "chrome/grit/locale_settings.h" |
38 #include "components/browsing_data/core/counters/browsing_data_counter.h" | 38 #include "components/browsing_data/core/counters/browsing_data_counter.h" |
| 39 #include "components/browsing_data/core/history_notice_utils.h" |
39 #include "components/browsing_data/core/pref_names.h" | 40 #include "components/browsing_data/core/pref_names.h" |
40 #include "components/browsing_data_ui/history_notice_utils.h" | |
41 #include "components/google/core/browser/google_util.h" | 41 #include "components/google/core/browser/google_util.h" |
42 #include "components/prefs/pref_service.h" | 42 #include "components/prefs/pref_service.h" |
43 #include "content/public/browser/notification_details.h" | 43 #include "content/public/browser/notification_details.h" |
44 #include "content/public/browser/web_ui.h" | 44 #include "content/public/browser/web_ui.h" |
45 #include "ui/base/accelerators/accelerator.h" | 45 #include "ui/base/accelerators/accelerator.h" |
46 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
47 #include "ui/events/keycodes/keyboard_codes.h" | 47 #include "ui/events/keycodes/keyboard_codes.h" |
48 | 48 |
49 namespace { | 49 namespace { |
50 | 50 |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 } | 389 } |
390 | 390 |
391 void ClearBrowserDataHandler::OnStateChanged() { | 391 void ClearBrowserDataHandler::OnStateChanged() { |
392 web_ui()->CallJavascriptFunctionUnsafe( | 392 web_ui()->CallJavascriptFunctionUnsafe( |
393 "ClearBrowserDataOverlay.updateSyncWarningAndHistoryFooter", | 393 "ClearBrowserDataOverlay.updateSyncWarningAndHistoryFooter", |
394 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), | 394 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), |
395 base::FundamentalValue(should_show_history_notice_)); | 395 base::FundamentalValue(should_show_history_notice_)); |
396 } | 396 } |
397 | 397 |
398 void ClearBrowserDataHandler::RefreshHistoryNotice() { | 398 void ClearBrowserDataHandler::RefreshHistoryNotice() { |
399 browsing_data_ui::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( | 399 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( |
400 sync_service_, | 400 sync_service_, |
401 WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())), | 401 WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())), |
402 base::Bind(&ClearBrowserDataHandler::UpdateHistoryNotice, | 402 base::Bind(&ClearBrowserDataHandler::UpdateHistoryNotice, |
403 weak_ptr_factory_.GetWeakPtr())); | 403 weak_ptr_factory_.GetWeakPtr())); |
404 | 404 |
405 // If the dialog with history notice has been shown less than | 405 // If the dialog with history notice has been shown less than |
406 // |kMaxTimesHistoryNoticeShown| times, we might have to show it when the | 406 // |kMaxTimesHistoryNoticeShown| times, we might have to show it when the |
407 // user deletes history. Find out if the conditions are met. | 407 // user deletes history. Find out if the conditions are met. |
408 int notice_shown_times = Profile::FromWebUI(web_ui())->GetPrefs()->GetInteger( | 408 int notice_shown_times = Profile::FromWebUI(web_ui())->GetPrefs()->GetInteger( |
409 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes); | 409 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes); |
410 | 410 |
411 if (notice_shown_times < kMaxTimesHistoryNoticeShown) { | 411 if (notice_shown_times < kMaxTimesHistoryNoticeShown) { |
412 browsing_data_ui::ShouldPopupDialogAboutOtherFormsOfBrowsingHistory( | 412 browsing_data::ShouldPopupDialogAboutOtherFormsOfBrowsingHistory( |
413 sync_service_, | 413 sync_service_, |
414 WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())), | 414 WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())), |
415 chrome::GetChannel(), | 415 chrome::GetChannel(), |
416 base::Bind(&ClearBrowserDataHandler::UpdateHistoryDeletionDialog, | 416 base::Bind(&ClearBrowserDataHandler::UpdateHistoryDeletionDialog, |
417 weak_ptr_factory_.GetWeakPtr())); | 417 weak_ptr_factory_.GetWeakPtr())); |
418 } | 418 } |
419 } | 419 } |
420 | 420 |
421 void ClearBrowserDataHandler::UpdateHistoryNotice(bool show) { | 421 void ClearBrowserDataHandler::UpdateHistoryNotice(bool show) { |
422 should_show_history_notice_ = show; | 422 should_show_history_notice_ = show; |
423 OnStateChanged(); | 423 OnStateChanged(); |
424 | 424 |
425 UMA_HISTOGRAM_BOOLEAN( | 425 UMA_HISTOGRAM_BOOLEAN( |
426 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", | 426 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", |
427 should_show_history_notice_); | 427 should_show_history_notice_); |
428 } | 428 } |
429 | 429 |
430 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) { | 430 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) { |
431 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes). | 431 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes). |
432 should_show_history_deletion_dialog_ = show; | 432 should_show_history_deletion_dialog_ = show; |
433 } | 433 } |
434 | 434 |
435 } // namespace options | 435 } // namespace options |
OLD | NEW |