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/browsing_data/browsing_data_counter_utils.h" | 5 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/browsing_data/autofill_counter.h" | 9 #include "chrome/browser/browsing_data/autofill_counter.h" |
10 #include "chrome/browser/browsing_data/cache_counter.h" | 10 #include "chrome/browser/browsing_data/cache_counter.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 displayed_strings[2]); | 161 displayed_strings[2]); |
162 break; | 162 break; |
163 default: | 163 default: |
164 NOTREACHED(); | 164 NOTREACHED(); |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 return text; | 168 return text; |
169 } | 169 } |
170 | 170 |
171 bool GetDeletionPreferenceFromDataType( | |
172 BrowsingDataType data_type, std::string* out_pref) { | |
173 switch (data_type) { | |
174 case HISTORY: | |
175 *out_pref = prefs::kDeleteBrowsingHistory; | |
176 return true; | |
177 case CACHE: | |
178 *out_pref = prefs::kDeleteCache; | |
179 return true; | |
180 case COOKIES: | |
181 *out_pref = prefs::kDeleteCookies; | |
182 return true; | |
183 case PASSWORDS: | |
184 *out_pref = prefs::kDeletePasswords; | |
185 return true; | |
186 case FORM_DATA: | |
187 *out_pref = prefs::kDeleteFormData; | |
188 return true; | |
189 case BOOKMARKS: | |
190 // Bookmarks are deleted on the Android side. No corresponding deletion | |
191 // preference. | |
192 return false; | |
193 default: | |
Bernhard Bauer
2016/01/14 16:12:43
Replace this with NUM_TYPES please, so that the co
msramek
2016/01/14 18:03:33
Done. Unfortunately, since |data_type| can possibl
Bernhard Bauer
2016/01/14 18:23:00
Yes, but that's what NOTREACHED() is for. :)
(I t
msramek
2016/01/14 18:37:58
It came to my mind, but I decided for a separate N
| |
194 NOTREACHED(); | |
195 return false; | |
196 } | |
197 } | |
198 | |
171 BrowsingDataCounter* CreateCounterForPreference(std::string pref_name) { | 199 BrowsingDataCounter* CreateCounterForPreference(std::string pref_name) { |
172 if (!AreCountersEnabled()) | 200 if (!AreCountersEnabled()) |
173 return nullptr; | 201 return nullptr; |
174 | 202 |
175 if (pref_name == prefs::kDeleteBrowsingHistory) | 203 if (pref_name == prefs::kDeleteBrowsingHistory) |
176 return new HistoryCounter(); | 204 return new HistoryCounter(); |
177 if (pref_name == prefs::kDeleteCache) | 205 if (pref_name == prefs::kDeleteCache) |
178 return new CacheCounter(); | 206 return new CacheCounter(); |
179 if (pref_name == prefs::kDeletePasswords) | 207 if (pref_name == prefs::kDeletePasswords) |
180 return new PasswordsCounter(); | 208 return new PasswordsCounter(); |
181 if (pref_name == prefs::kDeleteFormData) | 209 if (pref_name == prefs::kDeleteFormData) |
182 return new AutofillCounter(); | 210 return new AutofillCounter(); |
183 | 211 |
184 return nullptr; | 212 return nullptr; |
185 } | 213 } |
OLD | NEW |