| 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/options2/clear_browser_data_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/clear_browser_data_handler2.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 static OptionsStringResource resources[] = { | 43 static OptionsStringResource resources[] = { |
| 44 { "clearBrowserDataLabel", IDS_CLEAR_BROWSING_DATA_LABEL }, | 44 { "clearBrowserDataLabel", IDS_CLEAR_BROWSING_DATA_LABEL }, |
| 45 { "deleteBrowsingHistoryCheckbox", IDS_DEL_BROWSING_HISTORY_CHKBOX }, | 45 { "deleteBrowsingHistoryCheckbox", IDS_DEL_BROWSING_HISTORY_CHKBOX }, |
| 46 { "deleteDownloadHistoryCheckbox", IDS_DEL_DOWNLOAD_HISTORY_CHKBOX }, | 46 { "deleteDownloadHistoryCheckbox", IDS_DEL_DOWNLOAD_HISTORY_CHKBOX }, |
| 47 { "deleteCacheCheckbox", IDS_DEL_CACHE_CHKBOX }, | 47 { "deleteCacheCheckbox", IDS_DEL_CACHE_CHKBOX }, |
| 48 { "deleteCookiesCheckbox", IDS_DEL_COOKIES_CHKBOX }, | 48 { "deleteCookiesCheckbox", IDS_DEL_COOKIES_CHKBOX }, |
| 49 { "deleteCookiesFlashCheckbox", IDS_DEL_COOKIES_FLASH_CHKBOX }, | 49 { "deleteCookiesFlashCheckbox", IDS_DEL_COOKIES_FLASH_CHKBOX }, |
| 50 { "deletePasswordsCheckbox", IDS_DEL_PASSWORDS_CHKBOX }, | 50 { "deletePasswordsCheckbox", IDS_DEL_PASSWORDS_CHKBOX }, |
| 51 { "deleteFormDataCheckbox", IDS_DEL_FORM_DATA_CHKBOX }, | 51 { "deleteFormDataCheckbox", IDS_DEL_FORM_DATA_CHKBOX }, |
| 52 { "deauthorizeContentLicensesCheckbox", |
| 53 IDS_DEAUTHORIZE_CONTENT_LICENSES_CHKBOX }, |
| 52 { "clearBrowserDataCommit", IDS_CLEAR_BROWSING_DATA_COMMIT }, | 54 { "clearBrowserDataCommit", IDS_CLEAR_BROWSING_DATA_COMMIT }, |
| 53 { "flash_storage_url", IDS_FLASH_STORAGE_URL }, | 55 { "flash_storage_url", IDS_FLASH_STORAGE_URL }, |
| 54 }; | 56 }; |
| 55 | 57 |
| 56 RegisterStrings(localized_strings, resources, arraysize(resources)); | 58 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 57 RegisterTitle(localized_strings, "clearBrowserDataOverlay", | 59 RegisterTitle(localized_strings, "clearBrowserDataOverlay", |
| 58 IDS_CLEAR_BROWSING_DATA_TITLE); | 60 IDS_CLEAR_BROWSING_DATA_TITLE); |
| 59 | 61 |
| 60 ListValue* time_list = new ListValue; | 62 ListValue* time_list = new ListValue; |
| 61 for (int i = 0; i < 5; i++) { | 63 for (int i = 0; i < 5; i++) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 int site_data_mask = BrowsingDataRemover::REMOVE_SITE_DATA; | 109 int site_data_mask = BrowsingDataRemover::REMOVE_SITE_DATA; |
| 108 // Don't try to clear LSO data if it's not supported. | 110 // Don't try to clear LSO data if it's not supported. |
| 109 if (!*clear_plugin_lso_data_enabled_) | 111 if (!*clear_plugin_lso_data_enabled_) |
| 110 site_data_mask &= ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; | 112 site_data_mask &= ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; |
| 111 remove_mask |= site_data_mask; | 113 remove_mask |= site_data_mask; |
| 112 } | 114 } |
| 113 if (prefs->GetBoolean(prefs::kDeletePasswords)) | 115 if (prefs->GetBoolean(prefs::kDeletePasswords)) |
| 114 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; | 116 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; |
| 115 if (prefs->GetBoolean(prefs::kDeleteFormData)) | 117 if (prefs->GetBoolean(prefs::kDeleteFormData)) |
| 116 remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; | 118 remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; |
| 119 if (prefs->GetBoolean(prefs::kDeauthorizeContentLicenses)) |
| 120 remove_mask |= BrowsingDataRemover::REMOVE_CONTENT_LICENSES; |
| 117 | 121 |
| 118 int period_selected = prefs->GetInteger(prefs::kDeleteTimePeriod); | 122 int period_selected = prefs->GetInteger(prefs::kDeleteTimePeriod); |
| 119 | 123 |
| 120 base::FundamentalValue state(true); | 124 base::FundamentalValue state(true); |
| 121 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.setClearingState", | 125 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.setClearingState", |
| 122 state); | 126 state); |
| 123 | 127 |
| 124 // If we are still observing a previous data remover, we need to stop | 128 // If we are still observing a previous data remover, we need to stop |
| 125 // observing. | 129 // observing. |
| 126 if (remover_) | 130 if (remover_) |
| 127 remover_->RemoveObserver(this); | 131 remover_->RemoveObserver(this); |
| 128 | 132 |
| 129 // BrowsingDataRemover deletes itself when done. | 133 // BrowsingDataRemover deletes itself when done. |
| 130 remover_ = new BrowsingDataRemover(profile, | 134 remover_ = new BrowsingDataRemover(profile, |
| 131 static_cast<BrowsingDataRemover::TimePeriod>(period_selected), | 135 static_cast<BrowsingDataRemover::TimePeriod>(period_selected), |
| 132 base::Time()); | 136 base::Time()); |
| 133 remover_->AddObserver(this); | 137 remover_->AddObserver(this); |
| 134 remover_->Remove(remove_mask); | 138 remover_->Remove(remove_mask); |
| 135 } | 139 } |
| 136 | 140 |
| 137 void ClearBrowserDataHandler::OnBrowsingDataRemoverDone() { | 141 void ClearBrowserDataHandler::OnBrowsingDataRemoverDone() { |
| 138 // No need to remove ourselves as an observer as BrowsingDataRemover deletes | 142 // No need to remove ourselves as an observer as BrowsingDataRemover deletes |
| 139 // itself after we return. | 143 // itself after we return. |
| 140 remover_ = NULL; | 144 remover_ = NULL; |
| 141 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.doneClearing"); | 145 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.doneClearing"); |
| 142 } | 146 } |
| 143 | 147 |
| 144 } // namespace options2 | 148 } // namespace options2 |
| OLD | NEW |