diff options
10 files changed, 80 insertions, 60 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index eaaf5b3..addfa68 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -3832,7 +3832,7 @@ void TestingAutomationProvider::ClearBrowsingData( std::map<std::string, int> string_to_mask_value; string_to_mask_value["HISTORY"] = BrowsingDataRemover::REMOVE_HISTORY; string_to_mask_value["DOWNLOADS"] = BrowsingDataRemover::REMOVE_DOWNLOADS; - string_to_mask_value["COOKIES"] = BrowsingDataRemover::REMOVE_COOKIES; + string_to_mask_value["COOKIES"] = BrowsingDataRemover::REMOVE_SITE_DATA; string_to_mask_value["PASSWORDS"] = BrowsingDataRemover::REMOVE_PASSWORDS; string_to_mask_value["FORM_DATA"] = BrowsingDataRemover::REMOVE_FORM_DATA; string_to_mask_value["CACHE"] = BrowsingDataRemover::REMOVE_CACHE; diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc index 76a2305..b759d1d 100644 --- a/chrome/browser/browsing_data_remover.cc +++ b/chrome/browser/browsing_data_remover.cc @@ -22,6 +22,7 @@ #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/password_manager/password_store.h" #include "chrome/browser/plugin_data_remover.h" +#include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_host/web_cache_manager.h" @@ -33,6 +34,7 @@ #include "chrome/browser/sessions/tab_restore_service_factory.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/common/chrome_notification_types.h" +#include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "content/browser/browser_thread.h" #include "content/browser/download/download_manager.h" @@ -76,6 +78,9 @@ 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, @@ -99,6 +104,9 @@ 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() { @@ -196,17 +204,22 @@ void BrowsingDataRemover::Remove(int remove_mask) { base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread, base::Unretained(this), base::Unretained(rq_context))); } + } - // REMOVE_COOKIES is actually "cookies and other site data" so we make sure - // to remove other data such local databases, STS state, etc. These only can + if (remove_mask & REMOVE_LOCAL_STORAGE) { + // Remove data such as local databases, STS state, etc. These only can // be removed if a WEBKIT thread exists, so check that first: if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT)) { // We assume the end time is now. profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); } + } - // We'll start by using the quota system to clear out AppCaches, WebSQL DBs, - // and File Systems. + if (remove_mask & REMOVE_INDEXEDDB || remove_mask & REMOVE_WEBSQL || + remove_mask & REMOVE_APPCACHE || remove_mask & REMOVE_FILE_SYSTEMS) { + // TODO(mkwst): At the moment, we don't have the ability to pass a mask into + // QuotaManager. Until then, we'll clear all quota-managed data types if any + // ought to be cleared. quota_manager_ = profile_->GetQuotaManager(); if (quota_manager_) { waiting_for_clear_quota_managed_data_ = true; @@ -216,15 +229,17 @@ void BrowsingDataRemover::Remove(int remove_mask) { this, &BrowsingDataRemover::ClearQuotaManagedDataOnIOThread)); } + } - if (profile_->GetTransportSecurityState()) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - NewRunnableMethod( - profile_->GetTransportSecurityState(), - &net::TransportSecurityState::DeleteSince, - delete_begin_)); - } + if (remove_mask & REMOVE_LSO_DATA && *clear_plugin_lso_data_enabled_) { + UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); + + waiting_for_clear_lso_data_ = true; + if (!plugin_data_remover_.get()) + plugin_data_remover_ = new PluginDataRemover(profile_); + base::WaitableEvent* event = + plugin_data_remover_->StartRemoving(delete_begin_); + watcher_.StartWatching(event, this); } if (remove_mask & REMOVE_PASSWORDS) { @@ -275,15 +290,14 @@ void BrowsingDataRemover::Remove(int remove_mask) { } } - if (remove_mask & REMOVE_LSO_DATA) { - UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); - - waiting_for_clear_lso_data_ = true; - if (!plugin_data_remover_.get()) - plugin_data_remover_ = new PluginDataRemover(profile_); - base::WaitableEvent* event = - plugin_data_remover_->StartRemoving(delete_begin_); - watcher_.StartWatching(event, this); + // Also delete cached TransportSecurityState data. + if (profile_->GetTransportSecurityState()) { + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + NewRunnableMethod( + profile_->GetTransportSecurityState(), + &net::TransportSecurityState::DeleteSince, + delete_begin_)); } NotifyAndDeleteIfDone(); diff --git a/chrome/browser/browsing_data_remover.h b/chrome/browser/browsing_data_remover.h index 48c99da..2a955fc 100644 --- a/chrome/browser/browsing_data_remover.h +++ b/chrome/browser/browsing_data_remover.h @@ -12,6 +12,7 @@ #include "base/observer_list.h" #include "base/synchronization/waitable_event_watcher.h" #include "base/time.h" +#include "chrome/browser/prefs/pref_member.h" #include "content/browser/appcache/chrome_appcache_service.h" #include "content/browser/cancelable_request.h" #include "content/common/notification_observer.h" @@ -56,14 +57,25 @@ class BrowsingDataRemover : public NotificationObserver, // Mask used for Remove. enum RemoveDataMask { - // In addition to visits, this removes keywords and the last session. - REMOVE_HISTORY = 1 << 0, - REMOVE_DOWNLOADS = 1 << 1, + REMOVE_APPCACHE = 1 << 0, + REMOVE_CACHE = 1 << 1, REMOVE_COOKIES = 1 << 2, - REMOVE_PASSWORDS = 1 << 3, - REMOVE_FORM_DATA = 1 << 4, - REMOVE_CACHE = 1 << 5, - REMOVE_LSO_DATA = 1 << 6, + REMOVE_DOWNLOADS = 1 << 3, + REMOVE_FILE_SYSTEMS = 1 << 4, + REMOVE_FORM_DATA = 1 << 5, + // In addition to visits, REMOVE_HISTORY removes keywords and last session. + REMOVE_HISTORY = 1 << 6, + REMOVE_INDEXEDDB = 1 << 7, + REMOVE_LOCAL_STORAGE = 1 << 8, + REMOVE_LSO_DATA = 1 << 9, + REMOVE_PASSWORDS = 1 << 10, + REMOVE_WEBSQL = 1 << 11, + + // "Site data" includes cookies, appcache, file systems, indexedDBs, local + // storage, webSQL, and LSO data. + REMOVE_SITE_DATA = REMOVE_APPCACHE | REMOVE_COOKIES | REMOVE_FILE_SYSTEMS | + REMOVE_INDEXEDDB | REMOVE_LOCAL_STORAGE | + REMOVE_LSO_DATA | REMOVE_WEBSQL }; // Observer is notified when the removal is done. Done means keywords have @@ -247,6 +259,9 @@ 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 073025a..ad501dc 100644 --- a/chrome/browser/browsing_data_remover_unittest.cc +++ b/chrome/browser/browsing_data_remover_unittest.cc @@ -11,6 +11,8 @@ #include "base/platform_file.h" #include "chrome/browser/extensions/mock_extension_special_storage_policy.h" #include "chrome/browser/history/history.h" +#include "chrome/common/pref_names.h" +#include "chrome/test/base/testing_pref_service.h" #include "chrome/test/base/testing_profile.h" #include "net/base/cookie_monster.h" #include "net/url_request/url_request_context.h" @@ -235,6 +237,7 @@ class BrowsingDataRemoverTest : public testing::Test { file_thread_(BrowserThread::FILE, &message_loop_), io_thread_(BrowserThread::IO, &message_loop_), profile_(new TestingProfile()) { + profile_->GetPrefs()->SetBoolean(prefs::kClearPluginLSODataEnabled, false); } virtual ~BrowsingDataRemoverTest() { @@ -303,7 +306,7 @@ TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) { ASSERT_TRUE(tester->ContainsCookie()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_COOKIES, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); EXPECT_FALSE(tester->ContainsCookie()); } @@ -345,7 +348,7 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverBoth) { tester->PopulateTestQuotaManagedData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_COOKIES, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -367,7 +370,7 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { tester->PopulateTestQuotaManagedTemporaryData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_COOKIES, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -389,7 +392,7 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { tester->PopulateTestQuotaManagedPersistentData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_COOKIES, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -411,7 +414,7 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { GetMockManager(); // Creates the QuotaManager instance. BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_COOKIES, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -433,7 +436,7 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { tester->PopulateTestQuotaManagedData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, - BrowsingDataRemover::REMOVE_COOKIES, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -455,7 +458,7 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { tester->PopulateTestQuotaManagedData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, - BrowsingDataRemover::REMOVE_COOKIES, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); @@ -483,7 +486,7 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { tester->PopulateTestQuotaManagedData(GetMockManager()); BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, - BrowsingDataRemover::REMOVE_COOKIES, tester.get()); + BrowsingDataRemover::REMOVE_SITE_DATA, tester.get()); EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, quota::kStorageTypeTemporary)); diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 5235b0a..1c8d9ce 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -729,7 +729,7 @@ void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) { BrowsingDataRemover* remover = new BrowsingDataRemover(profile, BrowsingDataRemover::EVERYTHING, base::Time()); - int remove_mask = BrowsingDataRemover::REMOVE_COOKIES; + int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; remover->Remove(remove_mask); // BrowsingDataRemover takes care of deleting itself when done. } diff --git a/chrome/browser/extensions/extension_clear_api.cc b/chrome/browser/extensions/extension_clear_api.cc index 0ad4901..f2fc800 100644 --- a/chrome/browser/extensions/extension_clear_api.cc +++ b/chrome/browser/extensions/extension_clear_api.cc @@ -71,13 +71,9 @@ int ParseRemovalMask(base::DictionaryValue* value) { GetRemovalMask |= BrowsingDataRemover::REMOVE_PASSWORDS; // When we talk users about "cookies", we mean not just cookies, but pretty - // much everything associated with an origin. To that end, we explicitly - // include the REMOVE_LSO_DATA mask here, and BrowsingDataRemover interprets - // the REMOVE_COOKIES mask internally as "cookies and site data". - if (DataRemovalRequested(value, keys::kCookiesKey)) { - GetRemovalMask |= BrowsingDataRemover::REMOVE_COOKIES; - GetRemovalMask |= BrowsingDataRemover::REMOVE_LSO_DATA; - } + // much everything associated with an origin. + if (DataRemovalRequested(value, keys::kCookiesKey)) + GetRemovalMask |= BrowsingDataRemover::REMOVE_SITE_DATA; return GetRemovalMask; } @@ -133,8 +129,7 @@ int ClearCacheFunction::GetRemovalMask() const { } int ClearCookiesFunction::GetRemovalMask() const { - return BrowsingDataRemover::REMOVE_COOKIES | - BrowsingDataRemover::REMOVE_LSO_DATA; + return BrowsingDataRemover::REMOVE_SITE_DATA; } int ClearDownloadsFunction::GetRemovalMask() const { diff --git a/chrome/browser/ui/webui/chromeos/login/enterprise_oauth_enrollment_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/enterprise_oauth_enrollment_screen_handler.cc index c67b807..549e906 100644 --- a/chrome/browser/ui/webui/chromeos/login/enterprise_oauth_enrollment_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/enterprise_oauth_enrollment_screen_handler.cc @@ -300,13 +300,10 @@ void EnterpriseOAuthEnrollmentScreenHandler::ResetAuth() { oauth_fetcher_.reset(); // Clear page state. - int remove_mask = - BrowsingDataRemover::REMOVE_COOKIES | - BrowsingDataRemover::REMOVE_LSO_DATA; (new BrowsingDataRemover( Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()), BrowsingDataRemover::EVERYTHING, - base::Time()))->Remove(remove_mask); + base::Time()))->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); } diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc index bc9b02b..d442b77 100644 --- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc @@ -484,8 +484,7 @@ void SigninScreenHandler::StartClearingCookies() { BrowsingDataRemover::EVERYTHING, base::Time()); remover->AddObserver(this); - remover->Remove(BrowsingDataRemover::REMOVE_COOKIES | - BrowsingDataRemover::REMOVE_LSO_DATA); + remover->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); } } // namespace chromeos 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 4ba2295..91ca136f 100644 --- a/chrome/browser/ui/webui/options/clear_browser_data_handler.cc +++ b/chrome/browser/ui/webui/options/clear_browser_data_handler.cc @@ -100,11 +100,8 @@ 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_COOKIES; - if (*clear_plugin_lso_data_enabled_) - remove_mask |= BrowsingDataRemover::REMOVE_LSO_DATA; - } + if (prefs->GetBoolean(prefs::kDeleteCookies)) + remove_mask |= BrowsingDataRemover::REMOVE_SITE_DATA; if (prefs->GetBoolean(prefs::kDeletePasswords)) remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; if (prefs->GetBoolean(prefs::kDeleteFormData)) diff --git a/chrome_frame/delete_chrome_history.cc b/chrome_frame/delete_chrome_history.cc index 419cfc9..e2476af 100644 --- a/chrome_frame/delete_chrome_history.cc +++ b/chrome_frame/delete_chrome_history.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -80,7 +80,7 @@ STDMETHODIMP DeleteChromeHistory::DeleteBrowsingHistory(DWORD flags) { } if (flags & DELETE_BROWSING_HISTORY_COOKIES) - remove_mask_ |= BrowsingDataRemover::REMOVE_COOKIES; + remove_mask_ |= BrowsingDataRemover::REMOVE_SITE_DATA; if (flags & DELETE_BROWSING_HISTORY_TIF) remove_mask_ |= BrowsingDataRemover::REMOVE_CACHE; if (flags & DELETE_BROWSING_HISTORY_FORMDATA) |