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

Side by Side Diff: chrome/browser/extensions/api/browsing_data/browsing_data_api.cc

Issue 2136373003: Move browsing data deletion prefs to components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comment Created 4 years, 5 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 (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 // Defines the Chrome Extensions BrowsingData API functions, which entail 5 // Defines the Chrome Extensions BrowsingData API functions, which entail
6 // clearing browsing data, and clearing the browser's cache (which, let's be 6 // clearing browsing data, and clearing the browser's cache (which, let's be
7 // honest, are the same thing), as specified in the extension API JSON. 7 // honest, are the same thing), as specified in the extension API JSON.
8 8
9 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" 9 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h"
10 10
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 // Fill origin types. 129 // Fill origin types.
130 // The "cookies" and "hosted apps" UI checkboxes both map to 130 // The "cookies" and "hosted apps" UI checkboxes both map to
131 // REMOVE_SITE_DATA in browsing_data_remover.h, the former for the unprotected 131 // REMOVE_SITE_DATA in browsing_data_remover.h, the former for the unprotected
132 // web, the latter for protected web data. There is no UI control for 132 // web, the latter for protected web data. There is no UI control for
133 // extension data. 133 // extension data.
134 std::unique_ptr<base::DictionaryValue> origin_types( 134 std::unique_ptr<base::DictionaryValue> origin_types(
135 new base::DictionaryValue); 135 new base::DictionaryValue);
136 origin_types->SetBoolean( 136 origin_types->SetBoolean(
137 extension_browsing_data_api_constants::kUnprotectedWebKey, 137 extension_browsing_data_api_constants::kUnprotectedWebKey,
138 prefs->GetBoolean(prefs::kDeleteCookies)); 138 prefs->GetBoolean(browsing_data::prefs::kDeleteCookies));
139 origin_types->SetBoolean( 139 origin_types->SetBoolean(
140 extension_browsing_data_api_constants::kProtectedWebKey, 140 extension_browsing_data_api_constants::kProtectedWebKey,
141 prefs->GetBoolean(prefs::kDeleteHostedAppsData)); 141 prefs->GetBoolean(browsing_data::prefs::kDeleteHostedAppsData));
142 origin_types->SetBoolean( 142 origin_types->SetBoolean(
143 extension_browsing_data_api_constants::kExtensionsKey, false); 143 extension_browsing_data_api_constants::kExtensionsKey, false);
144 144
145 // Fill deletion time period. 145 // Fill deletion time period.
146 int period_pref = prefs->GetInteger(browsing_data::prefs::kDeleteTimePeriod); 146 int period_pref = prefs->GetInteger(browsing_data::prefs::kDeleteTimePeriod);
147 browsing_data::TimePeriod period = 147 browsing_data::TimePeriod period =
148 static_cast<browsing_data::TimePeriod>(period_pref); 148 static_cast<browsing_data::TimePeriod>(period_pref);
149 double since = 0; 149 double since = 0;
150 if (period != browsing_data::EVERYTHING) { 150 if (period != browsing_data::EVERYTHING) {
151 base::Time time = browsing_data::CalculateBeginDeleteTime(period); 151 base::Time time = browsing_data::CalculateBeginDeleteTime(period);
152 since = time.ToJsTime(); 152 since = time.ToJsTime();
153 } 153 }
154 154
155 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue); 155 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue);
156 options->Set(extension_browsing_data_api_constants::kOriginTypesKey, 156 options->Set(extension_browsing_data_api_constants::kOriginTypesKey,
157 origin_types.release()); 157 origin_types.release());
158 options->SetDouble(extension_browsing_data_api_constants::kSinceKey, since); 158 options->SetDouble(extension_browsing_data_api_constants::kSinceKey, since);
159 159
160 // Fill dataToRemove and dataRemovalPermitted. 160 // Fill dataToRemove and dataRemovalPermitted.
161 std::unique_ptr<base::DictionaryValue> selected(new base::DictionaryValue); 161 std::unique_ptr<base::DictionaryValue> selected(new base::DictionaryValue);
162 std::unique_ptr<base::DictionaryValue> permitted(new base::DictionaryValue); 162 std::unique_ptr<base::DictionaryValue> permitted(new base::DictionaryValue);
163 163
164 bool delete_site_data = prefs->GetBoolean(prefs::kDeleteCookies) || 164 bool delete_site_data =
165 prefs->GetBoolean(prefs::kDeleteHostedAppsData); 165 prefs->GetBoolean(browsing_data::prefs::kDeleteCookies) ||
166 prefs->GetBoolean(browsing_data::prefs::kDeleteHostedAppsData);
166 167
167 SetDetails(selected.get(), permitted.get(), 168 SetDetails(selected.get(), permitted.get(),
168 extension_browsing_data_api_constants::kAppCacheKey, 169 extension_browsing_data_api_constants::kAppCacheKey,
169 delete_site_data); 170 delete_site_data);
170 SetDetails(selected.get(), permitted.get(), 171 SetDetails(selected.get(), permitted.get(),
171 extension_browsing_data_api_constants::kCookiesKey, 172 extension_browsing_data_api_constants::kCookiesKey,
172 delete_site_data); 173 delete_site_data);
173 SetDetails(selected.get(), permitted.get(), 174 SetDetails(selected.get(), permitted.get(),
174 extension_browsing_data_api_constants::kFileSystemsKey, 175 extension_browsing_data_api_constants::kFileSystemsKey,
175 delete_site_data); 176 delete_site_data);
(...skipping 15 matching lines...) Expand all
191 SetDetails(selected.get(), permitted.get(), 192 SetDetails(selected.get(), permitted.get(),
192 extension_browsing_data_api_constants::kCacheStorageKey, 193 extension_browsing_data_api_constants::kCacheStorageKey,
193 delete_site_data); 194 delete_site_data);
194 195
195 SetDetails(selected.get(), permitted.get(), 196 SetDetails(selected.get(), permitted.get(),
196 extension_browsing_data_api_constants::kPluginDataKey, 197 extension_browsing_data_api_constants::kPluginDataKey,
197 delete_site_data && prefs->GetBoolean(prefs::kClearPluginLSODataEnabled)); 198 delete_site_data && prefs->GetBoolean(prefs::kClearPluginLSODataEnabled));
198 199
199 SetDetails(selected.get(), permitted.get(), 200 SetDetails(selected.get(), permitted.get(),
200 extension_browsing_data_api_constants::kHistoryKey, 201 extension_browsing_data_api_constants::kHistoryKey,
201 prefs->GetBoolean(prefs::kDeleteBrowsingHistory)); 202 prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistory));
202 SetDetails(selected.get(), permitted.get(), 203 SetDetails(selected.get(), permitted.get(),
203 extension_browsing_data_api_constants::kDownloadsKey, 204 extension_browsing_data_api_constants::kDownloadsKey,
204 prefs->GetBoolean(prefs::kDeleteDownloadHistory)); 205 prefs->GetBoolean(browsing_data::prefs::kDeleteDownloadHistory));
205 SetDetails(selected.get(), permitted.get(), 206 SetDetails(selected.get(), permitted.get(),
206 extension_browsing_data_api_constants::kCacheKey, 207 extension_browsing_data_api_constants::kCacheKey,
207 prefs->GetBoolean(prefs::kDeleteCache)); 208 prefs->GetBoolean(browsing_data::prefs::kDeleteCache));
208 SetDetails(selected.get(), permitted.get(), 209 SetDetails(selected.get(), permitted.get(),
209 extension_browsing_data_api_constants::kFormDataKey, 210 extension_browsing_data_api_constants::kFormDataKey,
210 prefs->GetBoolean(prefs::kDeleteFormData)); 211 prefs->GetBoolean(browsing_data::prefs::kDeleteFormData));
211 SetDetails(selected.get(), permitted.get(), 212 SetDetails(selected.get(), permitted.get(),
212 extension_browsing_data_api_constants::kPasswordsKey, 213 extension_browsing_data_api_constants::kPasswordsKey,
213 prefs->GetBoolean(prefs::kDeletePasswords)); 214 prefs->GetBoolean(browsing_data::prefs::kDeletePasswords));
214 215
215 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); 216 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
216 result->Set(extension_browsing_data_api_constants::kOptionsKey, 217 result->Set(extension_browsing_data_api_constants::kOptionsKey,
217 options.release()); 218 options.release());
218 result->Set(extension_browsing_data_api_constants::kDataToRemoveKey, 219 result->Set(extension_browsing_data_api_constants::kDataToRemoveKey,
219 selected.release()); 220 selected.release());
220 result->Set(extension_browsing_data_api_constants::kDataRemovalPermittedKey, 221 result->Set(extension_browsing_data_api_constants::kDataRemovalPermittedKey,
221 permitted.release()); 222 permitted.release());
222 SetResult(std::move(result)); 223 SetResult(std::move(result));
223 return true; 224 return true;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 return BrowsingDataRemover::REMOVE_SERVICE_WORKERS; 451 return BrowsingDataRemover::REMOVE_SERVICE_WORKERS;
451 } 452 }
452 453
453 int BrowsingDataRemoveCacheStorageFunction::GetRemovalMask() { 454 int BrowsingDataRemoveCacheStorageFunction::GetRemovalMask() {
454 return BrowsingDataRemover::REMOVE_CACHE_STORAGE; 455 return BrowsingDataRemover::REMOVE_CACHE_STORAGE;
455 } 456 }
456 457
457 int BrowsingDataRemoveWebSQLFunction::GetRemovalMask() { 458 int BrowsingDataRemoveWebSQLFunction::GetRemovalMask() {
458 return BrowsingDataRemover::REMOVE_WEBSQL; 459 return BrowsingDataRemover::REMOVE_WEBSQL;
459 } 460 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698