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

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

Issue 2084903002: Moved BrowsingDataCounter and part of BrowsingDataCounterUtils to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed deps Created 4 years, 6 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 extension_browsing_data_api_constants::kUnprotectedWebKey, 137 extension_browsing_data_api_constants::kUnprotectedWebKey,
138 prefs->GetBoolean(prefs::kDeleteCookies)); 138 prefs->GetBoolean(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(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(prefs::kDeleteTimePeriod); 146 int period_pref = prefs->GetInteger(prefs::kDeleteTimePeriod);
147 BrowsingDataRemover::TimePeriod period = 147 TimePeriod period = static_cast<TimePeriod>(period_pref);
148 static_cast<BrowsingDataRemover::TimePeriod>(period_pref);
149 double since = 0; 148 double since = 0;
150 if (period != BrowsingDataRemover::EVERYTHING) { 149 if (period != EVERYTHING) {
151 base::Time time = BrowsingDataRemover::CalculateBeginDeleteTime(period); 150 base::Time time = CalculateBeginDeleteTime(period);
152 since = time.ToJsTime(); 151 since = time.ToJsTime();
153 } 152 }
154 153
155 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue); 154 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue);
156 options->Set(extension_browsing_data_api_constants::kOriginTypesKey, 155 options->Set(extension_browsing_data_api_constants::kOriginTypesKey,
157 origin_types.release()); 156 origin_types.release());
158 options->SetDouble(extension_browsing_data_api_constants::kSinceKey, since); 157 options->SetDouble(extension_browsing_data_api_constants::kSinceKey, since);
159 158
160 // Fill dataToRemove and dataRemovalPermitted. 159 // Fill dataToRemove and dataRemovalPermitted.
161 std::unique_ptr<base::DictionaryValue> selected(new base::DictionaryValue); 160 std::unique_ptr<base::DictionaryValue> selected(new base::DictionaryValue);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 320 }
322 321
323 // If we're good to go, add a ref (Balanced in OnBrowsingDataRemoverDone) 322 // If we're good to go, add a ref (Balanced in OnBrowsingDataRemoverDone)
324 AddRef(); 323 AddRef();
325 324
326 // Create a BrowsingDataRemover, set the current object as an observer (so 325 // Create a BrowsingDataRemover, set the current object as an observer (so
327 // that we're notified after removal) and call remove() with the arguments 326 // that we're notified after removal) and call remove() with the arguments
328 // we've generated above. We can use a raw pointer here, as the browsing data 327 // we've generated above. We can use a raw pointer here, as the browsing data
329 // remover is responsible for deleting itself once data removal is complete. 328 // remover is responsible for deleting itself once data removal is complete.
330 observer_.Add(remover); 329 observer_.Add(remover);
331 remover->Remove( 330 remover->Remove(TimeRange(remove_since_, base::Time::Max()), removal_mask_,
332 BrowsingDataRemover::TimeRange(remove_since_, base::Time::Max()), 331 origin_type_mask_);
333 removal_mask_, origin_type_mask_);
334 } 332 }
335 333
336 int BrowsingDataRemoverFunction::ParseOriginTypeMask( 334 int BrowsingDataRemoverFunction::ParseOriginTypeMask(
337 const base::DictionaryValue& options) { 335 const base::DictionaryValue& options) {
338 // Parse the |options| dictionary to generate the origin set mask. Default to 336 // Parse the |options| dictionary to generate the origin set mask. Default to
339 // UNPROTECTED_WEB if the developer doesn't specify anything. 337 // UNPROTECTED_WEB if the developer doesn't specify anything.
340 int mask = BrowsingDataHelper::UNPROTECTED_WEB; 338 int mask = BrowsingDataHelper::UNPROTECTED_WEB;
341 339
342 const base::DictionaryValue* d = NULL; 340 const base::DictionaryValue* d = NULL;
343 if (options.HasKey(extension_browsing_data_api_constants::kOriginTypesKey)) { 341 if (options.HasKey(extension_browsing_data_api_constants::kOriginTypesKey)) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 return BrowsingDataRemover::REMOVE_SERVICE_WORKERS; 449 return BrowsingDataRemover::REMOVE_SERVICE_WORKERS;
452 } 450 }
453 451
454 int BrowsingDataRemoveCacheStorageFunction::GetRemovalMask() { 452 int BrowsingDataRemoveCacheStorageFunction::GetRemovalMask() {
455 return BrowsingDataRemover::REMOVE_CACHE_STORAGE; 453 return BrowsingDataRemover::REMOVE_CACHE_STORAGE;
456 } 454 }
457 455
458 int BrowsingDataRemoveWebSQLFunction::GetRemovalMask() { 456 int BrowsingDataRemoveWebSQLFunction::GetRemovalMask() {
459 return BrowsingDataRemover::REMOVE_WEBSQL; 457 return BrowsingDataRemover::REMOVE_WEBSQL;
460 } 458 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698