| 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 // 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 removal_mask_ &= ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; | 308 removal_mask_ &= ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; |
| 309 | 309 |
| 310 BrowserThread::PostTask( | 310 BrowserThread::PostTask( |
| 311 BrowserThread::UI, FROM_HERE, | 311 BrowserThread::UI, FROM_HERE, |
| 312 base::Bind(&BrowsingDataRemoverFunction::StartRemoving, this)); | 312 base::Bind(&BrowsingDataRemoverFunction::StartRemoving, this)); |
| 313 } | 313 } |
| 314 | 314 |
| 315 void BrowsingDataRemoverFunction::StartRemoving() { | 315 void BrowsingDataRemoverFunction::StartRemoving() { |
| 316 BrowsingDataRemover* remover = | 316 BrowsingDataRemover* remover = |
| 317 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); | 317 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); |
| 318 // TODO(msramek): This restriction is no longer needed. Remove it. |
| 318 if (remover->is_removing()) { | 319 if (remover->is_removing()) { |
| 319 error_ = extension_browsing_data_api_constants::kOneAtATimeError; | 320 error_ = extension_browsing_data_api_constants::kOneAtATimeError; |
| 320 SendResponse(false); | 321 SendResponse(false); |
| 321 return; | 322 return; |
| 322 } | 323 } |
| 323 | 324 |
| 324 // If we're good to go, add a ref (Balanced in OnBrowsingDataRemoverDone) | 325 // If we're good to go, add a ref (Balanced in OnBrowsingDataRemoverDone) |
| 325 AddRef(); | 326 AddRef(); |
| 326 | 327 |
| 327 // Create a BrowsingDataRemover, set the current object as an observer (so | 328 // Create a BrowsingDataRemover, set the current object as an observer (so |
| 328 // that we're notified after removal) and call remove() with the arguments | 329 // that we're notified after removal) and call remove() with the arguments |
| 329 // we've generated above. We can use a raw pointer here, as the browsing data | 330 // we've generated above. We can use a raw pointer here, as the browsing data |
| 330 // remover is responsible for deleting itself once data removal is complete. | 331 // remover is responsible for deleting itself once data removal is complete. |
| 331 observer_.Add(remover); | 332 observer_.Add(remover); |
| 332 remover->Remove( | 333 remover->RemoveAndReply( |
| 333 BrowsingDataRemover::TimeRange(remove_since_, base::Time::Max()), | 334 BrowsingDataRemover::TimeRange(remove_since_, base::Time::Max()), |
| 334 removal_mask_, origin_type_mask_); | 335 removal_mask_, origin_type_mask_, this); |
| 335 } | 336 } |
| 336 | 337 |
| 337 int BrowsingDataRemoverFunction::ParseOriginTypeMask( | 338 int BrowsingDataRemoverFunction::ParseOriginTypeMask( |
| 338 const base::DictionaryValue& options) { | 339 const base::DictionaryValue& options) { |
| 339 // Parse the |options| dictionary to generate the origin set mask. Default to | 340 // Parse the |options| dictionary to generate the origin set mask. Default to |
| 340 // UNPROTECTED_WEB if the developer doesn't specify anything. | 341 // UNPROTECTED_WEB if the developer doesn't specify anything. |
| 341 int mask = BrowsingDataHelper::UNPROTECTED_WEB; | 342 int mask = BrowsingDataHelper::UNPROTECTED_WEB; |
| 342 | 343 |
| 343 const base::DictionaryValue* d = NULL; | 344 const base::DictionaryValue* d = NULL; |
| 344 if (options.HasKey(extension_browsing_data_api_constants::kOriginTypesKey)) { | 345 if (options.HasKey(extension_browsing_data_api_constants::kOriginTypesKey)) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 return BrowsingDataRemover::REMOVE_SERVICE_WORKERS; | 452 return BrowsingDataRemover::REMOVE_SERVICE_WORKERS; |
| 452 } | 453 } |
| 453 | 454 |
| 454 int BrowsingDataRemoveCacheStorageFunction::GetRemovalMask() { | 455 int BrowsingDataRemoveCacheStorageFunction::GetRemovalMask() { |
| 455 return BrowsingDataRemover::REMOVE_CACHE_STORAGE; | 456 return BrowsingDataRemover::REMOVE_CACHE_STORAGE; |
| 456 } | 457 } |
| 457 | 458 |
| 458 int BrowsingDataRemoveWebSQLFunction::GetRemovalMask() { | 459 int BrowsingDataRemoveWebSQLFunction::GetRemovalMask() { |
| 459 return BrowsingDataRemover::REMOVE_WEBSQL; | 460 return BrowsingDataRemover::REMOVE_WEBSQL; |
| 460 } | 461 } |
| OLD | NEW |