| 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 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/app/chrome_command_ids.h" | 22 #include "chrome/app/chrome_command_ids.h" |
| 23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/browsing_data/autofill_counter.h" | 24 #include "chrome/browser/browsing_data/autofill_counter.h" |
| 25 #include "chrome/browser/browsing_data/browsing_data_counter.h" | 25 #include "chrome/browser/browsing_data/browsing_data_counter.h" |
| 26 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 26 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
| 27 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 27 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 28 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 28 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 29 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 29 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 30 #include "chrome/browser/browsing_data/cache_counter.h" | 30 #include "chrome/browser/browsing_data/cache_counter.h" |
| 31 #include "chrome/browser/browsing_data/history_counter.h" | 31 #include "chrome/browser/browsing_data/history_counter.h" |
| 32 #include "chrome/browser/browsing_data/media_license_counter.h" |
| 32 #include "chrome/browser/browsing_data/passwords_counter.h" | 33 #include "chrome/browser/browsing_data/passwords_counter.h" |
| 33 #include "chrome/browser/history/web_history_service_factory.h" | 34 #include "chrome/browser/history/web_history_service_factory.h" |
| 34 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 35 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/sync/profile_sync_service_factory.h" | 37 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 37 #include "chrome/browser/ui/accelerator_utils.h" | 38 #include "chrome/browser/ui/accelerator_utils.h" |
| 38 #include "chrome/common/channel_info.h" | 39 #include "chrome/common/channel_info.h" |
| 39 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
| 40 #include "chrome/grit/generated_resources.h" | 41 #include "chrome/grit/generated_resources.h" |
| 41 #include "chrome/grit/locale_settings.h" | 42 #include "chrome/grit/locale_settings.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 ClearBrowserDataHandler::~ClearBrowserDataHandler() { | 77 ClearBrowserDataHandler::~ClearBrowserDataHandler() { |
| 77 if (remover_) | 78 if (remover_) |
| 78 remover_->RemoveObserver(this); | 79 remover_->RemoveObserver(this); |
| 79 if (sync_service_) | 80 if (sync_service_) |
| 80 sync_service_->RemoveObserver(this); | 81 sync_service_->RemoveObserver(this); |
| 81 } | 82 } |
| 82 | 83 |
| 83 void ClearBrowserDataHandler::InitializeHandler() { | 84 void ClearBrowserDataHandler::InitializeHandler() { |
| 84 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 85 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 85 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, prefs); | 86 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, prefs); |
| 86 pepper_flash_settings_enabled_.Init(prefs::kPepperFlashSettingsEnabled, | |
| 87 prefs); | |
| 88 allow_deleting_browser_history_.Init( | 87 allow_deleting_browser_history_.Init( |
| 89 prefs::kAllowDeletingBrowserHistory, | 88 prefs::kAllowDeletingBrowserHistory, |
| 90 prefs, | 89 prefs, |
| 91 base::Bind(&ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged, | 90 base::Bind(&ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged, |
| 92 base::Unretained(this))); | 91 base::Unretained(this))); |
| 93 | 92 |
| 94 if (AreCountersEnabled()) { | 93 if (AreCountersEnabled()) { |
| 95 AddCounter(base::WrapUnique(new PasswordsCounter())); | 94 AddCounter(base::WrapUnique(new PasswordsCounter())); |
| 96 AddCounter(base::WrapUnique(new HistoryCounter())); | 95 AddCounter(base::WrapUnique(new HistoryCounter())); |
| 97 AddCounter(base::WrapUnique(new CacheCounter())); | 96 AddCounter(base::WrapUnique(new CacheCounter())); |
| 98 AddCounter(base::WrapUnique(new AutofillCounter())); | 97 AddCounter(base::WrapUnique(new AutofillCounter())); |
| 98 AddCounter(base::WrapUnique(new MediaLicenseCounter())); |
| 99 | 99 |
| 100 sync_service_ = | 100 sync_service_ = |
| 101 ProfileSyncServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); | 101 ProfileSyncServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); |
| 102 if (sync_service_) | 102 if (sync_service_) |
| 103 sync_service_->AddObserver(this); | 103 sync_service_->AddObserver(this); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 void ClearBrowserDataHandler::InitializePage() { | 107 void ClearBrowserDataHandler::InitializePage() { |
| 108 web_ui()->CallJavascriptFunctionUnsafe( | 108 web_ui()->CallJavascriptFunctionUnsafe( |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 if (prefs->GetBoolean(prefs::kDeleteCache)) | 262 if (prefs->GetBoolean(prefs::kDeleteCache)) |
| 263 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; | 263 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; |
| 264 if (prefs->GetBoolean(prefs::kDeleteCookies)) { | 264 if (prefs->GetBoolean(prefs::kDeleteCookies)) { |
| 265 remove_mask |= site_data_mask; | 265 remove_mask |= site_data_mask; |
| 266 origin_mask |= BrowsingDataHelper::UNPROTECTED_WEB; | 266 origin_mask |= BrowsingDataHelper::UNPROTECTED_WEB; |
| 267 } | 267 } |
| 268 if (prefs->GetBoolean(prefs::kDeletePasswords)) | 268 if (prefs->GetBoolean(prefs::kDeletePasswords)) |
| 269 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; | 269 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; |
| 270 if (prefs->GetBoolean(prefs::kDeleteFormData)) | 270 if (prefs->GetBoolean(prefs::kDeleteFormData)) |
| 271 remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; | 271 remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; |
| 272 // Clearing Content Licenses is only supported in Pepper Flash. | 272 if (prefs->GetBoolean(prefs::kDeleteMediaLicenses)) |
| 273 if (prefs->GetBoolean(prefs::kDeauthorizeContentLicenses) && | |
| 274 *pepper_flash_settings_enabled_) { | |
| 275 remove_mask |= BrowsingDataRemover::REMOVE_CONTENT_LICENSES; | 273 remove_mask |= BrowsingDataRemover::REMOVE_CONTENT_LICENSES; |
| 276 } | |
| 277 if (prefs->GetBoolean(prefs::kDeleteHostedAppsData)) { | 274 if (prefs->GetBoolean(prefs::kDeleteHostedAppsData)) { |
| 278 remove_mask |= site_data_mask; | 275 remove_mask |= site_data_mask; |
| 279 origin_mask |= BrowsingDataHelper::PROTECTED_WEB; | 276 origin_mask |= BrowsingDataHelper::PROTECTED_WEB; |
| 280 } | 277 } |
| 281 | 278 |
| 282 // Record the deletion of cookies and cache. | 279 // Record the deletion of cookies and cache. |
| 283 BrowsingDataRemover::CookieOrCacheDeletionChoice choice = | 280 BrowsingDataRemover::CookieOrCacheDeletionChoice choice = |
| 284 BrowsingDataRemover::NEITHER_COOKIES_NOR_CACHE; | 281 BrowsingDataRemover::NEITHER_COOKIES_NOR_CACHE; |
| 285 if (prefs->GetBoolean(prefs::kDeleteCookies)) { | 282 if (prefs->GetBoolean(prefs::kDeleteCookies)) { |
| 286 choice = prefs->GetBoolean(prefs::kDeleteCache) | 283 choice = prefs->GetBoolean(prefs::kDeleteCache) |
| 287 ? BrowsingDataRemover::BOTH_COOKIES_AND_CACHE | 284 ? BrowsingDataRemover::BOTH_COOKIES_AND_CACHE |
| 288 : BrowsingDataRemover::ONLY_COOKIES; | 285 : BrowsingDataRemover::ONLY_COOKIES; |
| 289 } else if (prefs->GetBoolean(prefs::kDeleteCache)) { | 286 } else if (prefs->GetBoolean(prefs::kDeleteCache)) { |
| 290 choice = BrowsingDataRemover::ONLY_CACHE; | 287 choice = BrowsingDataRemover::ONLY_CACHE; |
| 291 } | 288 } |
| 292 UMA_HISTOGRAM_ENUMERATION( | 289 UMA_HISTOGRAM_ENUMERATION( |
| 293 "History.ClearBrowsingData.UserDeletedCookieOrCacheFromDialog", | 290 "History.ClearBrowsingData.UserDeletedCookieOrCacheFromDialog", |
| 294 choice, BrowsingDataRemover::MAX_CHOICE_VALUE); | 291 choice, BrowsingDataRemover::MAX_CHOICE_VALUE); |
| 295 | 292 |
| 296 // Record the circumstances under which passwords are deleted. | 293 // Record the circumstances under which passwords are deleted. |
| 297 if (prefs->GetBoolean(prefs::kDeletePasswords)) { | 294 if (prefs->GetBoolean(prefs::kDeletePasswords)) { |
| 298 static const char* other_types[] = { | 295 static const char* other_types[] = { |
| 299 prefs::kDeleteBrowsingHistory, | 296 prefs::kDeleteBrowsingHistory, prefs::kDeleteDownloadHistory, |
| 300 prefs::kDeleteDownloadHistory, | 297 prefs::kDeleteCache, prefs::kDeleteCookies, |
| 301 prefs::kDeleteCache, | 298 prefs::kDeleteFormData, prefs::kDeleteHostedAppsData, |
| 302 prefs::kDeleteCookies, | 299 prefs::kDeleteMediaLicenses, |
| 303 prefs::kDeleteFormData, | |
| 304 prefs::kDeleteHostedAppsData, | |
| 305 prefs::kDeauthorizeContentLicenses, | |
| 306 }; | 300 }; |
| 307 static size_t num_other_types = arraysize(other_types); | 301 static size_t num_other_types = arraysize(other_types); |
| 308 int checked_other_types = std::count_if( | 302 int checked_other_types = std::count_if( |
| 309 other_types, | 303 other_types, |
| 310 other_types + num_other_types, | 304 other_types + num_other_types, |
| 311 [prefs](const std::string& pref) { return prefs->GetBoolean(pref); }); | 305 [prefs](const std::string& pref) { return prefs->GetBoolean(pref); }); |
| 312 UMA_HISTOGRAM_SPARSE_SLOWLY( | 306 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 313 "History.ClearBrowsingData.PasswordsDeletion.AdditionalDatatypesCount", | 307 "History.ClearBrowsingData.PasswordsDeletion.AdditionalDatatypesCount", |
| 314 checked_other_types); | 308 checked_other_types); |
| 315 } | 309 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", | 418 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", |
| 425 should_show_history_notice_); | 419 should_show_history_notice_); |
| 426 } | 420 } |
| 427 | 421 |
| 428 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) { | 422 void ClearBrowserDataHandler::UpdateHistoryDeletionDialog(bool show) { |
| 429 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes). | 423 // This is used by OnBrowsingDataRemoverDone (when the deletion finishes). |
| 430 should_show_history_deletion_dialog_ = show; | 424 should_show_history_deletion_dialog_ = show; |
| 431 } | 425 } |
| 432 | 426 |
| 433 } // namespace options | 427 } // namespace options |
| OLD | NEW |