diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browsing_data_remover.cc | 8 | ||||
-rw-r--r-- | chrome/browser/browsing_data_remover.h | 3 | ||||
-rw-r--r-- | chrome/browser/browsing_data_remover_unittest.cc | 23 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_clear_api.cc | 43 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_clear_api.h | 13 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/clear_browser_data_handler.cc | 9 |
6 files changed, 72 insertions, 27 deletions
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc index ee38cc1..11f0eab 100644 --- a/chrome/browser/browsing_data_remover.cc +++ b/chrome/browser/browsing_data_remover.cc @@ -82,9 +82,6 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile, waiting_for_clear_cache_(false), waiting_for_clear_lso_data_(false) { DCHECK(profile); - clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, - profile_->GetPrefs(), - NULL); } BrowsingDataRemover::BrowsingDataRemover(Profile* profile, @@ -108,9 +105,6 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile, waiting_for_clear_cache_(false), waiting_for_clear_lso_data_(false) { DCHECK(profile); - clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, - profile_->GetPrefs(), - NULL); } BrowsingDataRemover::~BrowsingDataRemover() { @@ -236,7 +230,7 @@ void BrowsingDataRemover::Remove(int remove_mask) { } } - if (remove_mask & REMOVE_LSO_DATA && *clear_plugin_lso_data_enabled_) { + if (remove_mask & REMOVE_LSO_DATA) { UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); waiting_for_clear_lso_data_ = true; diff --git a/chrome/browser/browsing_data_remover.h b/chrome/browser/browsing_data_remover.h index 7c66f3a..4405400 100644 --- a/chrome/browser/browsing_data_remover.h +++ b/chrome/browser/browsing_data_remover.h @@ -259,9 +259,6 @@ class BrowsingDataRemover : public NotificationObserver, // Used if we need to clear history. CancelableRequestConsumer request_consumer_; - // Keeps track of whether clearing LSO data is supported. - BooleanPrefMember clear_plugin_lso_data_enabled_; - DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); }; diff --git a/chrome/browser/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data_remover_unittest.cc index afc0249..ceedfda 100644 --- a/chrome/browser/browsing_data_remover_unittest.cc +++ b/chrome/browser/browsing_data_remover_unittest.cc @@ -308,7 +308,7 @@ TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) { ASSERT_TRUE(tester->ContainsCookie()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); + BrowsingDataRemover::REMOVE_COOKIES, tester.get()); EXPECT_FALSE(tester->ContainsCookie()); } @@ -350,7 +350,8 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverBoth) { tester->PopulateTestQuotaManagedData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA & + ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -372,7 +373,8 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { tester->PopulateTestQuotaManagedTemporaryData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA & + ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -394,7 +396,8 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { tester->PopulateTestQuotaManagedPersistentData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA & + ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -416,7 +419,8 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { GetMockManager(); // Creates the QuotaManager instance. BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA & + ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -438,7 +442,8 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { tester->PopulateTestQuotaManagedData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, - BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA & + ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -460,7 +465,8 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { tester->PopulateTestQuotaManagedData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, - BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA & + ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -488,7 +494,8 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { tester->PopulateTestQuotaManagedData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA & + ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); diff --git a/chrome/browser/extensions/extension_clear_api.cc b/chrome/browser/extensions/extension_clear_api.cc index f2fc800..07c999f 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) { + // 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; + 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 { diff --git a/chrome/browser/extensions/extension_clear_api.h b/chrome/browser/extensions/extension_clear_api.h index 46c89cb..ed074e0 100644 --- a/chrome/browser/extensions/extension_clear_api.h +++ b/chrome/browser/extensions/extension_clear_api.h @@ -20,6 +20,8 @@ namespace base { class DictionaryValue; } +class PluginPrefs; + // This serves as a base class from which the browsing data API functions will // inherit. Each needs to be an observer of BrowsingDataRemover events, and each // will handle those events in the same way (by calling the passed-in callback @@ -40,6 +42,17 @@ class BrowsingDataExtensionFunction : public AsyncExtensionFunction, // Children should override this method to provide the proper removal mask // based on the API call they represent. virtual int GetRemovalMask() const = 0; + + private: + // Updates the removal bitmask according to whether removing LSO data is + // supported or not. + void CheckRemovingLSODataSupported(scoped_refptr<PluginPrefs> plugin_prefs); + + // Called when we're ready to start removing data. + void StartRemoving(); + + BrowsingDataRemover::TimePeriod period_; + int removal_mask_; }; class ClearBrowsingDataFunction : public BrowsingDataExtensionFunction { diff --git a/chrome/browser/ui/webui/options/clear_browser_data_handler.cc b/chrome/browser/ui/webui/options/clear_browser_data_handler.cc index c422356..acca585 100644 --- a/chrome/browser/ui/webui/options/clear_browser_data_handler.cc +++ b/chrome/browser/ui/webui/options/clear_browser_data_handler.cc @@ -103,8 +103,13 @@ void ClearBrowserDataHandler::HandleClearBrowserData(const ListValue* value) { remove_mask |= BrowsingDataRemover::REMOVE_DOWNLOADS; if (prefs->GetBoolean(prefs::kDeleteCache)) remove_mask |= BrowsingDataRemover::REMOVE_CACHE; - if (prefs->GetBoolean(prefs::kDeleteCookies)) - remove_mask |= BrowsingDataRemover::REMOVE_SITE_DATA; + if (prefs->GetBoolean(prefs::kDeleteCookies)) { + int site_data_mask = BrowsingDataRemover::REMOVE_SITE_DATA; + // Don't try to clear LSO data if it's not supported. + if (!*clear_plugin_lso_data_enabled_) + site_data_mask &= ~BrowsingDataRemover::REMOVE_LSO_DATA; + remove_mask |= site_data_mask; + } if (prefs->GetBoolean(prefs::kDeletePasswords)) remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; if (prefs->GetBoolean(prefs::kDeleteFormData)) |