| 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" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
| 13 #include "chrome/browser/browsing_data/autofill_counter.h" | 13 #include "chrome/browser/browsing_data/autofill_counter.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 14 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 17 #include "chrome/browser/browsing_data/cache_counter.h" | 17 #include "chrome/browser/browsing_data/cache_counter.h" |
| 18 #include "chrome/browser/browsing_data/downloads_counter.h" | 18 #include "chrome/browser/browsing_data/downloads_counter.h" |
| 19 #include "chrome/browser/browsing_data/history_counter.h" | 19 #include "chrome/browser/browsing_data/history_counter.h" |
| 20 #include "chrome/browser/browsing_data/hosted_apps_counter.h" | 20 #include "chrome/browser/browsing_data/hosted_apps_counter.h" |
| 21 #include "chrome/browser/browsing_data/media_licenses_counter.h" |
| 21 #include "chrome/browser/browsing_data/passwords_counter.h" | 22 #include "chrome/browser/browsing_data/passwords_counter.h" |
| 22 #include "chrome/browser/history/web_history_service_factory.h" | 23 #include "chrome/browser/history/web_history_service_factory.h" |
| 23 #include "chrome/browser/sync/profile_sync_service_factory.h" | 24 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 25 #include "components/browsing_data_ui/history_notice_utils.h" | 26 #include "components/browsing_data_ui/history_notice_utils.h" |
| 26 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
| 27 #include "content/public/browser/web_ui.h" | 28 #include "content/public/browser/web_ui.h" |
| 28 | 29 |
| 29 namespace settings { | 30 namespace settings { |
| 30 | 31 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 remove_mask |= site_data_mask; | 102 remove_mask |= site_data_mask; |
| 102 origin_mask |= BrowsingDataHelper::UNPROTECTED_WEB; | 103 origin_mask |= BrowsingDataHelper::UNPROTECTED_WEB; |
| 103 } | 104 } |
| 104 | 105 |
| 105 if (prefs->GetBoolean(prefs::kDeletePasswords)) | 106 if (prefs->GetBoolean(prefs::kDeletePasswords)) |
| 106 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; | 107 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; |
| 107 | 108 |
| 108 if (prefs->GetBoolean(prefs::kDeleteFormData)) | 109 if (prefs->GetBoolean(prefs::kDeleteFormData)) |
| 109 remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; | 110 remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; |
| 110 | 111 |
| 111 // Clearing Content Licenses is only supported in Pepper Flash. | 112 if (prefs->GetBoolean(prefs::kDeleteMediaLicenses)) |
| 112 if (prefs->GetBoolean(prefs::kDeauthorizeContentLicenses) && | 113 remove_mask |= BrowsingDataRemover::REMOVE_MEDIA_LICENSES; |
| 113 prefs->GetBoolean(prefs::kPepperFlashSettingsEnabled)) { | |
| 114 remove_mask |= BrowsingDataRemover::REMOVE_CONTENT_LICENSES; | |
| 115 } | |
| 116 | 114 |
| 117 if (prefs->GetBoolean(prefs::kDeleteHostedAppsData)) { | 115 if (prefs->GetBoolean(prefs::kDeleteHostedAppsData)) { |
| 118 remove_mask |= site_data_mask; | 116 remove_mask |= site_data_mask; |
| 119 origin_mask |= BrowsingDataHelper::PROTECTED_WEB; | 117 origin_mask |= BrowsingDataHelper::PROTECTED_WEB; |
| 120 } | 118 } |
| 121 | 119 |
| 122 // Record the deletion of cookies and cache. | 120 // Record the deletion of cookies and cache. |
| 123 BrowsingDataRemover::CookieOrCacheDeletionChoice choice = | 121 BrowsingDataRemover::CookieOrCacheDeletionChoice choice = |
| 124 BrowsingDataRemover::NEITHER_COOKIES_NOR_CACHE; | 122 BrowsingDataRemover::NEITHER_COOKIES_NOR_CACHE; |
| 125 if (prefs->GetBoolean(prefs::kDeleteCookies)) { | 123 if (prefs->GetBoolean(prefs::kDeleteCookies)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 136 | 134 |
| 137 // Record the circumstances under which passwords are deleted. | 135 // Record the circumstances under which passwords are deleted. |
| 138 if (prefs->GetBoolean(prefs::kDeletePasswords)) { | 136 if (prefs->GetBoolean(prefs::kDeletePasswords)) { |
| 139 static const char* other_types[] = { | 137 static const char* other_types[] = { |
| 140 prefs::kDeleteBrowsingHistory, | 138 prefs::kDeleteBrowsingHistory, |
| 141 prefs::kDeleteDownloadHistory, | 139 prefs::kDeleteDownloadHistory, |
| 142 prefs::kDeleteCache, | 140 prefs::kDeleteCache, |
| 143 prefs::kDeleteCookies, | 141 prefs::kDeleteCookies, |
| 144 prefs::kDeleteFormData, | 142 prefs::kDeleteFormData, |
| 145 prefs::kDeleteHostedAppsData, | 143 prefs::kDeleteHostedAppsData, |
| 146 prefs::kDeauthorizeContentLicenses, | 144 prefs::kDeleteMediaLicenses, |
| 147 }; | 145 }; |
| 148 static size_t num_other_types = arraysize(other_types); | 146 static size_t num_other_types = arraysize(other_types); |
| 149 int checked_other_types = std::count_if( | 147 int checked_other_types = std::count_if( |
| 150 other_types, other_types + num_other_types, | 148 other_types, other_types + num_other_types, |
| 151 [prefs](const std::string& pref) { return prefs->GetBoolean(pref); }); | 149 [prefs](const std::string& pref) { return prefs->GetBoolean(pref); }); |
| 152 UMA_HISTOGRAM_SPARSE_SLOWLY( | 150 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 153 "History.ClearBrowsingData.PasswordsDeletion.AdditionalDatatypesCount", | 151 "History.ClearBrowsingData.PasswordsDeletion.AdditionalDatatypesCount", |
| 154 checked_other_types); | 152 checked_other_types); |
| 155 } | 153 } |
| 156 | 154 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 184 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) { | 182 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) { |
| 185 AllowJavascript(); | 183 AllowJavascript(); |
| 186 | 184 |
| 187 // TODO(msramek): Simplify this using a factory. | 185 // TODO(msramek): Simplify this using a factory. |
| 188 AddCounter(base::WrapUnique(new AutofillCounter())); | 186 AddCounter(base::WrapUnique(new AutofillCounter())); |
| 189 AddCounter(base::WrapUnique(new CacheCounter())); | 187 AddCounter(base::WrapUnique(new CacheCounter())); |
| 190 AddCounter(base::WrapUnique(new DownloadsCounter())); | 188 AddCounter(base::WrapUnique(new DownloadsCounter())); |
| 191 AddCounter(base::WrapUnique(new HistoryCounter())); | 189 AddCounter(base::WrapUnique(new HistoryCounter())); |
| 192 AddCounter(base::WrapUnique(new HostedAppsCounter())); | 190 AddCounter(base::WrapUnique(new HostedAppsCounter())); |
| 193 AddCounter(base::WrapUnique(new PasswordsCounter())); | 191 AddCounter(base::WrapUnique(new PasswordsCounter())); |
| 192 AddCounter(base::WrapUnique(new MediaLicensesCounter())); |
| 194 | 193 |
| 195 OnStateChanged(); | 194 OnStateChanged(); |
| 196 RefreshHistoryNotice(); | 195 RefreshHistoryNotice(); |
| 197 } | 196 } |
| 198 | 197 |
| 199 void ClearBrowsingDataHandler::OnStateChanged() { | 198 void ClearBrowsingDataHandler::OnStateChanged() { |
| 200 CallJavascriptFunction( | 199 CallJavascriptFunction( |
| 201 "cr.webUIListenerCallback", | 200 "cr.webUIListenerCallback", |
| 202 base::StringValue("update-footer"), | 201 base::StringValue("update-footer"), |
| 203 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), | 202 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 234 void ClearBrowsingDataHandler::UpdateCounterText( | 233 void ClearBrowsingDataHandler::UpdateCounterText( |
| 235 std::unique_ptr<BrowsingDataCounter::Result> result) { | 234 std::unique_ptr<BrowsingDataCounter::Result> result) { |
| 236 CallJavascriptFunction( | 235 CallJavascriptFunction( |
| 237 "cr.webUIListenerCallback", | 236 "cr.webUIListenerCallback", |
| 238 base::StringValue("update-counter-text"), | 237 base::StringValue("update-counter-text"), |
| 239 base::StringValue(result->source()->GetPrefName()), | 238 base::StringValue(result->source()->GetPrefName()), |
| 240 base::StringValue(GetCounterTextFromResult(result.get()))); | 239 base::StringValue(GetCounterTextFromResult(result.get()))); |
| 241 } | 240 } |
| 242 | 241 |
| 243 } // namespace settings | 242 } // namespace settings |
| OLD | NEW |