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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 if (!IsRemovalPermitted(removal_mask_, GetProfile()->GetPrefs())) { | 277 if (!IsRemovalPermitted(removal_mask_, GetProfile()->GetPrefs())) { |
278 error_ = extension_browsing_data_api_constants::kDeleteProhibitedError; | 278 error_ = extension_browsing_data_api_constants::kDeleteProhibitedError; |
279 return false; | 279 return false; |
280 } | 280 } |
281 | 281 |
282 if (removal_mask_ & | 282 if (removal_mask_ & |
283 ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA) { | 283 ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA) { |
284 // If we're being asked to remove plugin data, check whether it's actually | 284 // If we're being asked to remove plugin data, check whether it's actually |
285 // supported. | 285 // supported. |
286 BrowserThread::PostTask( | 286 BrowserThread::PostTask( |
287 BrowserThread::FILE, | 287 BrowserThread::FILE, FROM_HERE, |
288 FROM_HERE, | 288 base::BindOnce( |
289 base::Bind( | |
290 &BrowsingDataRemoverFunction::CheckRemovingPluginDataSupported, | 289 &BrowsingDataRemoverFunction::CheckRemovingPluginDataSupported, |
291 this, | 290 this, PluginPrefs::GetForProfile(GetProfile()))); |
292 PluginPrefs::GetForProfile(GetProfile()))); | |
293 } else { | 291 } else { |
294 StartRemoving(); | 292 StartRemoving(); |
295 } | 293 } |
296 | 294 |
297 // Will finish asynchronously. | 295 // Will finish asynchronously. |
298 return true; | 296 return true; |
299 } | 297 } |
300 | 298 |
301 BrowsingDataRemoverFunction::~BrowsingDataRemoverFunction() {} | 299 BrowsingDataRemoverFunction::~BrowsingDataRemoverFunction() {} |
302 | 300 |
303 void BrowsingDataRemoverFunction::CheckRemovingPluginDataSupported( | 301 void BrowsingDataRemoverFunction::CheckRemovingPluginDataSupported( |
304 scoped_refptr<PluginPrefs> plugin_prefs) { | 302 scoped_refptr<PluginPrefs> plugin_prefs) { |
305 if (!PluginDataRemoverHelper::IsSupported(plugin_prefs.get())) | 303 if (!PluginDataRemoverHelper::IsSupported(plugin_prefs.get())) |
306 removal_mask_ &= ~ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA; | 304 removal_mask_ &= ~ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA; |
307 | 305 |
308 BrowserThread::PostTask( | 306 BrowserThread::PostTask( |
309 BrowserThread::UI, FROM_HERE, | 307 BrowserThread::UI, FROM_HERE, |
310 base::Bind(&BrowsingDataRemoverFunction::StartRemoving, this)); | 308 base::BindOnce(&BrowsingDataRemoverFunction::StartRemoving, this)); |
311 } | 309 } |
312 | 310 |
313 void BrowsingDataRemoverFunction::StartRemoving() { | 311 void BrowsingDataRemoverFunction::StartRemoving() { |
314 BrowsingDataRemover* remover = | 312 BrowsingDataRemover* remover = |
315 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); | 313 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); |
316 // Add a ref (Balanced in OnBrowsingDataRemoverDone) | 314 // Add a ref (Balanced in OnBrowsingDataRemoverDone) |
317 AddRef(); | 315 AddRef(); |
318 | 316 |
319 // Create a BrowsingDataRemover, set the current object as an observer (so | 317 // Create a BrowsingDataRemover, set the current object as an observer (so |
320 // that we're notified after removal) and call remove() with the arguments | 318 // that we're notified after removal) and call remove() with the arguments |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 464 |
467 bool BrowsingDataRemoveCacheStorageFunction::GetRemovalMask(int* removal_mask) { | 465 bool BrowsingDataRemoveCacheStorageFunction::GetRemovalMask(int* removal_mask) { |
468 *removal_mask = BrowsingDataRemover::DATA_TYPE_CACHE_STORAGE; | 466 *removal_mask = BrowsingDataRemover::DATA_TYPE_CACHE_STORAGE; |
469 return true; | 467 return true; |
470 } | 468 } |
471 | 469 |
472 bool BrowsingDataRemoveWebSQLFunction::GetRemovalMask(int* removal_mask) { | 470 bool BrowsingDataRemoveWebSQLFunction::GetRemovalMask(int* removal_mask) { |
473 *removal_mask = BrowsingDataRemover::DATA_TYPE_WEB_SQL; | 471 *removal_mask = BrowsingDataRemover::DATA_TYPE_WEB_SQL; |
474 return true; | 472 return true; |
475 } | 473 } |
OLD | NEW |