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

Unified Diff: chrome/browser/extensions/extension_clear_api.cc

Issue 8223004: Check whether clearing LSO data is supported in clients of the BrowsingDataRemover. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unit test Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_clear_api.cc
diff --git a/chrome/browser/extensions/extension_clear_api.cc b/chrome/browser/extensions/extension_clear_api.cc
index f2fc800d1dc59a0f4f2eab229a73923e4fbc9a94..459e05cd545944ef139c81c2948f8ab8cff75482 100644
--- a/chrome/browser/extensions/extension_clear_api.cc
+++ b/chrome/browser/extensions/extension_clear_api.cc
@@ -14,6 +14,8 @@
#include "base/values.h"
#include "chrome/browser/browsing_data_remover.h"
#include "chrome/browser/extensions/extension_clear_api_constants.h"
+#include "chrome/browser/plugin_data_remover.h"
+#include "chrome/browser/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/extensions/extension.h"
@@ -95,10 +97,40 @@ bool BrowsingDataExtensionFunction::RunImpl() {
// Parse the |timeframe| argument to generate the TimePeriod.
std::string timeframe;
- BrowsingDataRemover::TimePeriod period;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &timeframe));
- EXTENSION_FUNCTION_VALIDATE(ParseTimePeriod(timeframe, &period));
+ EXTENSION_FUNCTION_VALIDATE(ParseTimePeriod(timeframe, &period_));
+
+ removal_mask_ = GetRemovalMask();
+
+ if (removal_mask_ & ~BrowsingDataRemover::REMOVE_LSO_DATA) {
Mike West 2011/10/10 18:41:11 I think taking the one's complement here is backwa
Bernhard Bauer 2011/10/11 13:52:58 Indeed, that was a copy-and-paste from below :) Th
+ // If we're being asked to remove LSO data, check whether it's actually
+ // supported.
+ Profile* profile = GetCurrentBrowser()->profile();
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(
+ &BrowsingDataExtensionFunction::CheckRemovingLSODataSupported,
+ this,
+ make_scoped_refptr(PluginPrefs::GetForProfile(profile))));
+ } else {
+ StartRemoving();
+ }
+
+ // Will finish asynchronously.
+ return true;
+}
+
+void BrowsingDataExtensionFunction::CheckRemovingLSODataSupported(
+ scoped_refptr<PluginPrefs> plugin_prefs) {
+ if (!PluginDataRemover::IsSupported(plugin_prefs))
+ removal_mask_ &= ~BrowsingDataRemover::REMOVE_LSO_DATA;
Mike West 2011/10/10 18:50:23 XOR might be clearer? I had to think about what th
Bernhard Bauer 2011/10/11 13:52:58 I think a bitwise "and" is the usual way to flip a
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&BrowsingDataExtensionFunction::StartRemoving, this));
+}
+
+void BrowsingDataExtensionFunction::StartRemoving() {
// If we're good to go, add a ref (Balanced in OnBrowsingDataRemoverDone)
AddRef();
@@ -107,12 +139,9 @@ bool BrowsingDataExtensionFunction::RunImpl() {
// we've generated above. We can use a raw pointer here, as the browsing data
// remover is responsible for deleting itself once data removal is complete.
BrowsingDataRemover* remover = new BrowsingDataRemover(
- GetCurrentBrowser()->profile(), period, base::Time::Now());
+ GetCurrentBrowser()->profile(), period_, base::Time::Now());
remover->AddObserver(this);
- remover->Remove(GetRemovalMask());
-
- // Will finish asynchronously.
- return true;
+ remover->Remove(removal_mask_);
}
int ClearBrowsingDataFunction::GetRemovalMask() const {

Powered by Google App Engine
This is Rietveld 408576698