Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: components/browsing_data/core/browsing_data_utils.cc

Issue 2816723002: Add "Site Settings" option to Clear Browsing Data on Android (Closed)
Patch Set: fixes Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/browsing_data/core/browsing_data_utils.h" 5 #include "components/browsing_data/core/browsing_data_utils.h"
6 6
7 #include "base/metrics/user_metrics.h" 7 #include "base/metrics/user_metrics.h"
8 #include "components/browsing_data/core/counters/autofill_counter.h" 8 #include "components/browsing_data/core/counters/autofill_counter.h"
9 #include "components/browsing_data/core/counters/history_counter.h" 9 #include "components/browsing_data/core/counters/history_counter.h"
10 #include "components/browsing_data/core/counters/passwords_counter.h" 10 #include "components/browsing_data/core/counters/passwords_counter.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 text = l10n_util::GetPluralStringFUTF16( 83 text = l10n_util::GetPluralStringFUTF16(
84 password_result->password_sync_enabled() 84 password_result->password_sync_enabled()
85 ? IDS_DEL_PASSWORDS_COUNTER_SYNCED 85 ? IDS_DEL_PASSWORDS_COUNTER_SYNCED
86 : IDS_DEL_PASSWORDS_COUNTER, 86 : IDS_DEL_PASSWORDS_COUNTER,
87 count); 87 count);
88 } else if (pref_name == prefs::kDeleteDownloadHistory) { 88 } else if (pref_name == prefs::kDeleteDownloadHistory) {
89 BrowsingDataCounter::ResultInt count = 89 BrowsingDataCounter::ResultInt count =
90 static_cast<const BrowsingDataCounter::FinishedResult*>(result) 90 static_cast<const BrowsingDataCounter::FinishedResult*>(result)
91 ->Value(); 91 ->Value();
92 text = l10n_util::GetPluralStringFUTF16(IDS_DEL_DOWNLOADS_COUNTER, count); 92 text = l10n_util::GetPluralStringFUTF16(IDS_DEL_DOWNLOADS_COUNTER, count);
93 } else if (pref_name == prefs::kDeleteSiteSettings) {
94 BrowsingDataCounter::ResultInt count =
95 static_cast<const BrowsingDataCounter::FinishedResult*>(result)
96 ->Value();
97 text =
98 l10n_util::GetPluralStringFUTF16(IDS_DEL_SITE_SETTINGS_COUNTER, count);
93 } else if (pref_name == prefs::kDeleteBrowsingHistoryBasic) { 99 } else if (pref_name == prefs::kDeleteBrowsingHistoryBasic) {
94 // The basic tab doesn't show history counter results. 100 // The basic tab doesn't show history counter results.
95 NOTREACHED(); 101 NOTREACHED();
96 } else if (pref_name == prefs::kDeleteBrowsingHistory) { 102 } else if (pref_name == prefs::kDeleteBrowsingHistory) {
97 // History counter. 103 // History counter.
98 const HistoryCounter::HistoryResult* history_result = 104 const HistoryCounter::HistoryResult* history_result =
99 static_cast<const HistoryCounter::HistoryResult*>(result); 105 static_cast<const HistoryCounter::HistoryResult*>(result);
100 BrowsingDataCounter::ResultInt local_item_count = history_result->Value(); 106 BrowsingDataCounter::ResultInt local_item_count = history_result->Value();
101 bool has_synced_visits = history_result->has_synced_visits(); 107 bool has_synced_visits = history_result->has_synced_visits();
102 text = has_synced_visits 108 text = has_synced_visits
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 case BrowsingDataType::PASSWORDS: 218 case BrowsingDataType::PASSWORDS:
213 *out_pref = prefs::kDeletePasswords; 219 *out_pref = prefs::kDeletePasswords;
214 return true; 220 return true;
215 case BrowsingDataType::FORM_DATA: 221 case BrowsingDataType::FORM_DATA:
216 *out_pref = prefs::kDeleteFormData; 222 *out_pref = prefs::kDeleteFormData;
217 return true; 223 return true;
218 case BrowsingDataType::BOOKMARKS: 224 case BrowsingDataType::BOOKMARKS:
219 // Bookmarks are deleted on the Android side. No corresponding deletion 225 // Bookmarks are deleted on the Android side. No corresponding deletion
220 // preference. 226 // preference.
221 return false; 227 return false;
228 case BrowsingDataType::SITE_SETTINGS:
229 *out_pref = prefs::kDeleteSiteSettings;
230 return true;
222 case BrowsingDataType::NUM_TYPES: 231 case BrowsingDataType::NUM_TYPES:
223 // This is not an actual type. 232 // This is not an actual type.
224 NOTREACHED(); 233 NOTREACHED();
225 return false; 234 return false;
226 } 235 }
227 NOTREACHED(); 236 NOTREACHED();
228 return false; 237 return false;
229 } 238 }
230 239
231 void MigratePreferencesToBasic(PrefService* prefs) { 240 void MigratePreferencesToBasic(PrefService* prefs) {
232 if (!prefs->GetBoolean(prefs::kPreferencesMigratedToBasic)) { 241 if (!prefs->GetBoolean(prefs::kPreferencesMigratedToBasic)) {
233 prefs->SetBoolean(prefs::kDeleteBrowsingHistoryBasic, 242 prefs->SetBoolean(prefs::kDeleteBrowsingHistoryBasic,
234 prefs->GetBoolean(prefs::kDeleteBrowsingHistory)); 243 prefs->GetBoolean(prefs::kDeleteBrowsingHistory));
235 prefs->SetBoolean(prefs::kDeleteCacheBasic, 244 prefs->SetBoolean(prefs::kDeleteCacheBasic,
236 prefs->GetBoolean(prefs::kDeleteCache)); 245 prefs->GetBoolean(prefs::kDeleteCache));
237 prefs->SetBoolean(prefs::kDeleteCookiesBasic, 246 prefs->SetBoolean(prefs::kDeleteCookiesBasic,
238 prefs->GetBoolean(prefs::kDeleteCookies)); 247 prefs->GetBoolean(prefs::kDeleteCookies));
239 prefs->SetInteger(prefs::kDeleteTimePeriodBasic, 248 prefs->SetInteger(prefs::kDeleteTimePeriodBasic,
240 prefs->GetInteger(prefs::kDeleteTimePeriod)); 249 prefs->GetInteger(prefs::kDeleteTimePeriod));
241 prefs->SetBoolean(prefs::kPreferencesMigratedToBasic, true); 250 prefs->SetBoolean(prefs::kPreferencesMigratedToBasic, true);
242 } 251 }
243 } 252 }
244 253
245 } // namespace browsing_data 254 } // namespace browsing_data
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698