| 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 <set> |
| 10 |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 11 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/metrics/sparse_histogram.h" | 14 #include "base/metrics/sparse_histogram.h" |
| 13 #include "chrome/browser/browsing_data/browsing_data_counter_factory.h" | 15 #include "chrome/browser/browsing_data/browsing_data_counter_factory.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 16 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 18 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 19 #include "chrome/browser/browsing_data/chrome_browsing_data_types.h" |
| 17 #include "chrome/browser/history/web_history_service_factory.h" | 20 #include "chrome/browser/history/web_history_service_factory.h" |
| 18 #include "chrome/browser/sync/profile_sync_service_factory.h" | 21 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 19 #include "chrome/common/channel_info.h" | 22 #include "chrome/common/channel_info.h" |
| 20 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 21 #include "components/browsing_data/core/history_notice_utils.h" | 24 #include "components/browsing_data/core/history_notice_utils.h" |
| 22 #include "components/browsing_data/core/pref_names.h" | 25 #include "components/browsing_data/core/pref_names.h" |
| 23 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
| 24 #include "content/public/browser/web_ui.h" | 27 #include "content/public/browser/web_ui.h" |
| 25 | 28 |
| 26 namespace { | 29 namespace { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 task_observer_.reset(); | 118 task_observer_.reset(); |
| 116 counters_.clear(); | 119 counters_.clear(); |
| 117 } | 120 } |
| 118 | 121 |
| 119 void ClearBrowsingDataHandler::HandleClearBrowsingData( | 122 void ClearBrowsingDataHandler::HandleClearBrowsingData( |
| 120 const base::ListValue* args) { | 123 const base::ListValue* args) { |
| 121 DCHECK(!task_observer_); | 124 DCHECK(!task_observer_); |
| 122 | 125 |
| 123 PrefService* prefs = profile_->GetPrefs(); | 126 PrefService* prefs = profile_->GetPrefs(); |
| 124 | 127 |
| 125 int site_data_mask = BrowsingDataRemover::REMOVE_SITE_DATA; | 128 std::set<const content::BrowsingDataType*> remove_mask; |
| 126 // Don't try to clear LSO data if it's not supported. | |
| 127 if (!prefs->GetBoolean(prefs::kClearPluginLSODataEnabled)) | |
| 128 site_data_mask &= ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; | |
| 129 | |
| 130 int remove_mask = 0; | |
| 131 if (prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory)) { | 129 if (prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory)) { |
| 132 if (prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistory)) | 130 if (prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistory)) |
| 133 remove_mask |= BrowsingDataRemover::REMOVE_HISTORY; | 131 remove_mask.insert(&kBrowsingDataTypeHistory); |
| 134 if (prefs->GetBoolean(browsing_data::prefs::kDeleteDownloadHistory)) | 132 if (prefs->GetBoolean(browsing_data::prefs::kDeleteDownloadHistory)) |
| 135 remove_mask |= BrowsingDataRemover::REMOVE_DOWNLOADS; | 133 remove_mask.insert(&kBrowsingDataTypeDownloads); |
| 136 } | 134 } |
| 137 | 135 |
| 138 if (prefs->GetBoolean(browsing_data::prefs::kDeleteCache)) | 136 if (prefs->GetBoolean(browsing_data::prefs::kDeleteCache)) |
| 139 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; | 137 remove_mask.insert(&kBrowsingDataTypeCache); |
| 140 | 138 |
| 141 int origin_mask = 0; | 139 int origin_mask = 0; |
| 142 if (prefs->GetBoolean(browsing_data::prefs::kDeleteCookies)) { | 140 if (prefs->GetBoolean(browsing_data::prefs::kDeleteCookies)) { |
| 143 remove_mask |= site_data_mask; | 141 remove_mask.insert(BrowsingDataTypeSetSiteData().begin(), |
| 142 BrowsingDataTypeSetSiteData().end()); |
| 144 origin_mask |= BrowsingDataHelper::UNPROTECTED_WEB; | 143 origin_mask |= BrowsingDataHelper::UNPROTECTED_WEB; |
| 145 } | 144 } |
| 146 | 145 |
| 147 if (prefs->GetBoolean(browsing_data::prefs::kDeletePasswords)) | 146 if (prefs->GetBoolean(browsing_data::prefs::kDeletePasswords)) |
| 148 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; | 147 remove_mask.insert(&kBrowsingDataTypePasswords); |
| 149 | 148 |
| 150 if (prefs->GetBoolean(browsing_data::prefs::kDeleteFormData)) | 149 if (prefs->GetBoolean(browsing_data::prefs::kDeleteFormData)) |
| 151 remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; | 150 remove_mask.insert(&kBrowsingDataTypeFormData); |
| 152 | 151 |
| 153 if (prefs->GetBoolean(browsing_data::prefs::kDeleteMediaLicenses)) | 152 if (prefs->GetBoolean(browsing_data::prefs::kDeleteMediaLicenses)) |
| 154 remove_mask |= BrowsingDataRemover::REMOVE_MEDIA_LICENSES; | 153 remove_mask.insert(&kBrowsingDataTypeMediaLicenses); |
| 155 | 154 |
| 156 if (prefs->GetBoolean(browsing_data::prefs::kDeleteHostedAppsData)) { | 155 if (prefs->GetBoolean(browsing_data::prefs::kDeleteHostedAppsData)) { |
| 157 remove_mask |= site_data_mask; | 156 remove_mask.insert(BrowsingDataTypeSetSiteData().begin(), |
| 157 BrowsingDataTypeSetSiteData().end()); |
| 158 origin_mask |= BrowsingDataHelper::PROTECTED_WEB; | 158 origin_mask |= BrowsingDataHelper::PROTECTED_WEB; |
| 159 } | 159 } |
| 160 | 160 |
| 161 // Don't try to clear LSO data if it's not supported. |
| 162 if (!prefs->GetBoolean(prefs::kClearPluginLSODataEnabled)) |
| 163 remove_mask.erase(&kBrowsingDataTypePluginData); |
| 164 |
| 161 // Record the deletion of cookies and cache. | 165 // Record the deletion of cookies and cache. |
| 162 BrowsingDataRemover::CookieOrCacheDeletionChoice choice = | 166 BrowsingDataRemover::CookieOrCacheDeletionChoice choice = |
| 163 BrowsingDataRemover::NEITHER_COOKIES_NOR_CACHE; | 167 BrowsingDataRemover::NEITHER_COOKIES_NOR_CACHE; |
| 164 if (prefs->GetBoolean(browsing_data::prefs::kDeleteCookies)) { | 168 if (prefs->GetBoolean(browsing_data::prefs::kDeleteCookies)) { |
| 165 choice = prefs->GetBoolean(browsing_data::prefs::kDeleteCache) | 169 choice = prefs->GetBoolean(browsing_data::prefs::kDeleteCache) |
| 166 ? BrowsingDataRemover::BOTH_COOKIES_AND_CACHE | 170 ? BrowsingDataRemover::BOTH_COOKIES_AND_CACHE |
| 167 : BrowsingDataRemover::ONLY_COOKIES; | 171 : BrowsingDataRemover::ONLY_COOKIES; |
| 168 } else if (prefs->GetBoolean(browsing_data::prefs::kDeleteCache)) { | 172 } else if (prefs->GetBoolean(browsing_data::prefs::kDeleteCache)) { |
| 169 choice = BrowsingDataRemover::ONLY_CACHE; | 173 choice = BrowsingDataRemover::ONLY_CACHE; |
| 170 } | 174 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 void ClearBrowsingDataHandler::UpdateCounterText( | 331 void ClearBrowsingDataHandler::UpdateCounterText( |
| 328 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { | 332 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { |
| 329 CallJavascriptFunction( | 333 CallJavascriptFunction( |
| 330 "cr.webUIListenerCallback", | 334 "cr.webUIListenerCallback", |
| 331 base::StringValue("update-counter-text"), | 335 base::StringValue("update-counter-text"), |
| 332 base::StringValue(result->source()->GetPrefName()), | 336 base::StringValue(result->source()->GetPrefName()), |
| 333 base::StringValue(GetChromeCounterTextFromResult(result.get()))); | 337 base::StringValue(GetChromeCounterTextFromResult(result.get()))); |
| 334 } | 338 } |
| 335 | 339 |
| 336 } // namespace settings | 340 } // namespace settings |
| OLD | NEW |