| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 const char kMyActivityUrlInFooter[] = | 54 const char kMyActivityUrlInFooter[] = |
| 55 "https://history.google.com/history/?utm_source=chrome_cbd"; | 55 "https://history.google.com/history/?utm_source=chrome_cbd"; |
| 56 | 56 |
| 57 const char kMyActivityUrlInDialog[] = | 57 const char kMyActivityUrlInDialog[] = |
| 58 "https://history.google.com/history/?utm_source=chrome_n"; | 58 "https://history.google.com/history/?utm_source=chrome_n"; |
| 59 | 59 |
| 60 const int kMaxTimesHistoryNoticeShown = 1; | 60 const int kMaxTimesHistoryNoticeShown = 1; |
| 61 | 61 |
| 62 const char* kCounterPrefs[] = { | 62 const char* kCounterPrefs[] = { |
| 63 prefs::kDeleteBrowsingHistory, | 63 browsing_data::prefs::kDeleteBrowsingHistory, |
| 64 prefs::kDeleteCache, | 64 browsing_data::prefs::kDeleteCache, |
| 65 prefs::kDeleteFormData, | 65 browsing_data::prefs::kDeleteFormData, |
| 66 prefs::kDeleteMediaLicenses, | 66 browsing_data::prefs::kDeleteMediaLicenses, |
| 67 prefs::kDeletePasswords, | 67 browsing_data::prefs::kDeletePasswords, |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 namespace options { | 72 namespace options { |
| 73 | 73 |
| 74 ClearBrowserDataHandler::ClearBrowserDataHandler() | 74 ClearBrowserDataHandler::ClearBrowserDataHandler() |
| 75 : remover_(nullptr), | 75 : remover_(nullptr), |
| 76 sync_service_(nullptr), | 76 sync_service_(nullptr), |
| 77 should_show_history_notice_(false), | 77 should_show_history_notice_(false), |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 Profile* profile = Profile::FromWebUI(web_ui()); | 247 Profile* profile = Profile::FromWebUI(web_ui()); |
| 248 PrefService* prefs = profile->GetPrefs(); | 248 PrefService* prefs = profile->GetPrefs(); |
| 249 | 249 |
| 250 int site_data_mask = BrowsingDataRemover::REMOVE_SITE_DATA; | 250 int site_data_mask = BrowsingDataRemover::REMOVE_SITE_DATA; |
| 251 // Don't try to clear LSO data if it's not supported. | 251 // Don't try to clear LSO data if it's not supported. |
| 252 if (!*clear_plugin_lso_data_enabled_) | 252 if (!*clear_plugin_lso_data_enabled_) |
| 253 site_data_mask &= ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; | 253 site_data_mask &= ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; |
| 254 | 254 |
| 255 int remove_mask = 0; | 255 int remove_mask = 0; |
| 256 int origin_mask = 0; | 256 int origin_mask = 0; |
| 257 if (prefs->GetBoolean(prefs::kDeleteBrowsingHistory) && | 257 if (prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistory) && |
| 258 *allow_deleting_browser_history_) { | 258 *allow_deleting_browser_history_) { |
| 259 remove_mask |= BrowsingDataRemover::REMOVE_HISTORY; | 259 remove_mask |= BrowsingDataRemover::REMOVE_HISTORY; |
| 260 } | 260 } |
| 261 if (prefs->GetBoolean(prefs::kDeleteDownloadHistory) && | 261 if (prefs->GetBoolean(browsing_data::prefs::kDeleteDownloadHistory) && |
| 262 *allow_deleting_browser_history_) { | 262 *allow_deleting_browser_history_) { |
| 263 remove_mask |= BrowsingDataRemover::REMOVE_DOWNLOADS; | 263 remove_mask |= BrowsingDataRemover::REMOVE_DOWNLOADS; |
| 264 } | 264 } |
| 265 if (prefs->GetBoolean(prefs::kDeleteCache)) | 265 if (prefs->GetBoolean(browsing_data::prefs::kDeleteCache)) |
| 266 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; | 266 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; |
| 267 if (prefs->GetBoolean(prefs::kDeleteCookies)) { | 267 if (prefs->GetBoolean(browsing_data::prefs::kDeleteCookies)) { |
| 268 remove_mask |= site_data_mask; | 268 remove_mask |= site_data_mask; |
| 269 origin_mask |= BrowsingDataHelper::UNPROTECTED_WEB; | 269 origin_mask |= BrowsingDataHelper::UNPROTECTED_WEB; |
| 270 } | 270 } |
| 271 if (prefs->GetBoolean(prefs::kDeletePasswords)) | 271 if (prefs->GetBoolean(browsing_data::prefs::kDeletePasswords)) |
| 272 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; | 272 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; |
| 273 if (prefs->GetBoolean(prefs::kDeleteFormData)) | 273 if (prefs->GetBoolean(browsing_data::prefs::kDeleteFormData)) |
| 274 remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; | 274 remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; |
| 275 if (prefs->GetBoolean(prefs::kDeleteMediaLicenses)) | 275 if (prefs->GetBoolean(browsing_data::prefs::kDeleteMediaLicenses)) |
| 276 remove_mask |= BrowsingDataRemover::REMOVE_MEDIA_LICENSES; | 276 remove_mask |= BrowsingDataRemover::REMOVE_MEDIA_LICENSES; |
| 277 if (prefs->GetBoolean(prefs::kDeleteHostedAppsData)) { | 277 if (prefs->GetBoolean(browsing_data::prefs::kDeleteHostedAppsData)) { |
| 278 remove_mask |= site_data_mask; | 278 remove_mask |= site_data_mask; |
| 279 origin_mask |= BrowsingDataHelper::PROTECTED_WEB; | 279 origin_mask |= BrowsingDataHelper::PROTECTED_WEB; |
| 280 } | 280 } |
| 281 | 281 |
| 282 // Record the deletion of cookies and cache. | 282 // Record the deletion of cookies and cache. |
| 283 BrowsingDataRemover::CookieOrCacheDeletionChoice choice = | 283 BrowsingDataRemover::CookieOrCacheDeletionChoice choice = |
| 284 BrowsingDataRemover::NEITHER_COOKIES_NOR_CACHE; | 284 BrowsingDataRemover::NEITHER_COOKIES_NOR_CACHE; |
| 285 if (prefs->GetBoolean(prefs::kDeleteCookies)) { | 285 if (prefs->GetBoolean(browsing_data::prefs::kDeleteCookies)) { |
| 286 choice = prefs->GetBoolean(prefs::kDeleteCache) | 286 choice = prefs->GetBoolean(browsing_data::prefs::kDeleteCache) |
| 287 ? BrowsingDataRemover::BOTH_COOKIES_AND_CACHE | 287 ? BrowsingDataRemover::BOTH_COOKIES_AND_CACHE |
| 288 : BrowsingDataRemover::ONLY_COOKIES; | 288 : BrowsingDataRemover::ONLY_COOKIES; |
| 289 } else if (prefs->GetBoolean(prefs::kDeleteCache)) { | 289 } else if (prefs->GetBoolean(browsing_data::prefs::kDeleteCache)) { |
| 290 choice = BrowsingDataRemover::ONLY_CACHE; | 290 choice = BrowsingDataRemover::ONLY_CACHE; |
| 291 } | 291 } |
| 292 UMA_HISTOGRAM_ENUMERATION( | 292 UMA_HISTOGRAM_ENUMERATION( |
| 293 "History.ClearBrowsingData.UserDeletedCookieOrCacheFromDialog", | 293 "History.ClearBrowsingData.UserDeletedCookieOrCacheFromDialog", |
| 294 choice, BrowsingDataRemover::MAX_CHOICE_VALUE); | 294 choice, BrowsingDataRemover::MAX_CHOICE_VALUE); |
| 295 | 295 |
| 296 // Record the circumstances under which passwords are deleted. | 296 // Record the circumstances under which passwords are deleted. |
| 297 if (prefs->GetBoolean(prefs::kDeletePasswords)) { | 297 if (prefs->GetBoolean(browsing_data::prefs::kDeletePasswords)) { |
| 298 static const char* other_types[] = { | 298 static const char* other_types[] = { |
| 299 prefs::kDeleteBrowsingHistory, | 299 browsing_data::prefs::kDeleteBrowsingHistory, |
| 300 prefs::kDeleteDownloadHistory, | 300 browsing_data::prefs::kDeleteDownloadHistory, |
| 301 prefs::kDeleteCache, | 301 browsing_data::prefs::kDeleteCache, |
| 302 prefs::kDeleteCookies, | 302 browsing_data::prefs::kDeleteCookies, |
| 303 prefs::kDeleteFormData, | 303 browsing_data::prefs::kDeleteFormData, |
| 304 prefs::kDeleteHostedAppsData, | 304 browsing_data::prefs::kDeleteHostedAppsData, |
| 305 prefs::kDeleteMediaLicenses, | 305 browsing_data::prefs::kDeleteMediaLicenses, |
| 306 }; | 306 }; |
| 307 static size_t num_other_types = arraysize(other_types); | 307 static size_t num_other_types = arraysize(other_types); |
| 308 int checked_other_types = std::count_if( | 308 int checked_other_types = std::count_if( |
| 309 other_types, | 309 other_types, |
| 310 other_types + num_other_types, | 310 other_types + num_other_types, |
| 311 [prefs](const std::string& pref) { return prefs->GetBoolean(pref); }); | 311 [prefs](const std::string& pref) { return prefs->GetBoolean(pref); }); |
| 312 UMA_HISTOGRAM_SPARSE_SLOWLY( | 312 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 313 "History.ClearBrowsingData.PasswordsDeletion.AdditionalDatatypesCount", | 313 "History.ClearBrowsingData.PasswordsDeletion.AdditionalDatatypesCount", |
| 314 checked_other_types); | 314 checked_other_types); |
| 315 } | 315 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 336 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 336 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 337 int notice_shown_times = | 337 int notice_shown_times = |
| 338 prefs->GetInteger(prefs::kClearBrowsingDataHistoryNoticeShownTimes); | 338 prefs->GetInteger(prefs::kClearBrowsingDataHistoryNoticeShownTimes); |
| 339 | 339 |
| 340 // When the deletion is complete, we might show an additional dialog with | 340 // When the deletion is complete, we might show an additional dialog with |
| 341 // a notice about other forms of browsing history. This is the case if | 341 // a notice about other forms of browsing history. This is the case if |
| 342 const bool show_notice = | 342 const bool show_notice = |
| 343 // 1. The dialog is relevant for the user. | 343 // 1. The dialog is relevant for the user. |
| 344 should_show_history_deletion_dialog_ && | 344 should_show_history_deletion_dialog_ && |
| 345 // 2. The selected data types contained browsing history. | 345 // 2. The selected data types contained browsing history. |
| 346 prefs->GetBoolean(prefs::kDeleteBrowsingHistory) && | 346 prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistory) && |
| 347 // 3. The notice has been shown less than |kMaxTimesHistoryNoticeShown|. | 347 // 3. The notice has been shown less than |kMaxTimesHistoryNoticeShown|. |
| 348 notice_shown_times < kMaxTimesHistoryNoticeShown; | 348 notice_shown_times < kMaxTimesHistoryNoticeShown; |
| 349 | 349 |
| 350 if (show_notice) { | 350 if (show_notice) { |
| 351 // Increment the preference. | 351 // Increment the preference. |
| 352 prefs->SetInteger(prefs::kClearBrowsingDataHistoryNoticeShownTimes, | 352 prefs->SetInteger(prefs::kClearBrowsingDataHistoryNoticeShownTimes, |
| 353 notice_shown_times + 1); | 353 notice_shown_times + 1); |
| 354 } | 354 } |
| 355 | 355 |
| 356 UMA_HISTOGRAM_BOOLEAN( | 356 UMA_HISTOGRAM_BOOLEAN( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", | 423 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", |
| 424 should_show_history_notice_); | 424 should_show_history_notice_); |
| 425 } | 425 } |
| 426 | 426 |
| 427 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) { | 427 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) { |
| 428 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes). | 428 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes). |
| 429 should_show_history_deletion_dialog_ = show; | 429 should_show_history_deletion_dialog_ = show; |
| 430 } | 430 } |
| 431 | 431 |
| 432 } // namespace options | 432 } // namespace options |
| OLD | NEW |