| Index: chrome/browser/browsing_data/browsing_data_remover_impl.h
|
| diff --git a/chrome/browser/browsing_data/browsing_data_remover.h b/chrome/browser/browsing_data/browsing_data_remover_impl.h
|
| similarity index 56%
|
| copy from chrome/browser/browsing_data/browsing_data_remover.h
|
| copy to chrome/browser/browsing_data/browsing_data_remover_impl.h
|
| index 2286ce6dc550b0017345ef4eb8dd105fd445b39d..36204ebce9b772fa6c810448d2a3d2ad236c15fb 100644
|
| --- a/chrome/browser/browsing_data/browsing_data_remover.h
|
| +++ b/chrome/browser/browsing_data/browsing_data_remover_impl.h
|
| @@ -2,15 +2,14 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_
|
| -#define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_
|
| +#ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_IMPL_H_
|
| +#define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_IMPL_H_
|
|
|
| #include <stdint.h>
|
|
|
| #include <queue>
|
| #include <set>
|
|
|
| -#include "base/callback_forward.h"
|
| #include "base/gtest_prod_util.h"
|
| #include "base/macros.h"
|
| #include "base/memory/weak_ptr.h"
|
| @@ -18,7 +17,7 @@
|
| #include "base/synchronization/waitable_event_watcher.h"
|
| #include "base/time/time.h"
|
| #include "build/build_config.h"
|
| -#include "chrome/browser/browsing_data/browsing_data_remover_delegate.h"
|
| +#include "chrome/browser/browsing_data/browsing_data_remover.h"
|
| #include "chrome/common/features.h"
|
| #include "components/keyed_service/core/keyed_service.h"
|
| #include "ppapi/features/features.h"
|
| @@ -35,144 +34,10 @@ class PluginDataRemover;
|
| class StoragePartition;
|
| }
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// BrowsingDataRemover is responsible for removing data related to browsing:
|
| -// visits in url database, downloads, cookies ...
|
| -//
|
| -// USAGE:
|
| -//
|
| -// 0. Instantiation.
|
| -//
|
| -// BrowsingDataRemover remover =
|
| -// BrowsingDataRemoverFactory::GetForBrowserContext(browser_context);
|
| -//
|
| -// 1. No observer.
|
| -//
|
| -// remover->Remove(base::Time(), base::Time::Max(), REMOVE_COOKIES, ALL);
|
| -//
|
| -// 2. Using an observer to report when one's own removal task is finished.
|
| -//
|
| -// class CookiesDeleter : public BrowsingDataRemover::Observer {
|
| -// CookiesDeleter() { remover->AddObserver(this); }
|
| -// ~CookiesDeleter() { remover->RemoveObserver(this); }
|
| -//
|
| -// void DeleteCookies() {
|
| -// remover->RemoveAndReply(base::Time(), base::Time::Max(),
|
| -// REMOVE_COOKIES, ALL, this);
|
| -// }
|
| -//
|
| -// void OnBrowsingDataRemoverDone() {
|
| -// LOG(INFO) << "Cookies were deleted.";
|
| -// }
|
| -// }
|
| -//
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -
|
| -class BrowsingDataRemover : public KeyedService {
|
| +class BrowsingDataRemoverImpl :
|
| + public BrowsingDataRemover,
|
| + public KeyedService {
|
| public:
|
| - // Mask used for Remove.
|
| - enum RemoveDataMask {
|
| - REMOVE_APPCACHE = 1 << 0,
|
| - REMOVE_CACHE = 1 << 1,
|
| - REMOVE_COOKIES = 1 << 2,
|
| - REMOVE_DOWNLOADS = 1 << 3,
|
| - REMOVE_FILE_SYSTEMS = 1 << 4,
|
| - REMOVE_FORM_DATA = 1 << 5,
|
| - // In addition to visits, REMOVE_HISTORY removes keywords, last session and
|
| - // passwords UI statistics.
|
| - REMOVE_HISTORY = 1 << 6,
|
| - REMOVE_INDEXEDDB = 1 << 7,
|
| - REMOVE_LOCAL_STORAGE = 1 << 8,
|
| - REMOVE_PLUGIN_DATA = 1 << 9,
|
| - REMOVE_PASSWORDS = 1 << 10,
|
| - REMOVE_WEBSQL = 1 << 11,
|
| - REMOVE_CHANNEL_IDS = 1 << 12,
|
| - REMOVE_MEDIA_LICENSES = 1 << 13,
|
| - REMOVE_SERVICE_WORKERS = 1 << 14,
|
| - REMOVE_SITE_USAGE_DATA = 1 << 15,
|
| - // REMOVE_NOCHECKS intentionally does not check if the browser context is
|
| - // prohibited from deleting history or downloads.
|
| - REMOVE_NOCHECKS = 1 << 16,
|
| - REMOVE_CACHE_STORAGE = 1 << 17,
|
| -#if BUILDFLAG(ANDROID_JAVA_UI)
|
| - REMOVE_WEBAPP_DATA = 1 << 18,
|
| -#endif
|
| - REMOVE_DURABLE_PERMISSION = 1 << 19,
|
| -
|
| - // The following flag is used only in tests. In normal usage, hosted app
|
| - // data is controlled by the REMOVE_COOKIES flag, applied to the
|
| - // protected-web origin.
|
| - REMOVE_HOSTED_APP_DATA_TESTONLY = 1 << 31,
|
| -
|
| - // "Site data" includes cookies, appcache, file systems, indexedDBs, local
|
| - // storage, webSQL, service workers, cache storage, plugin data, web app
|
| - // data (on Android) and statistics about passwords.
|
| - REMOVE_SITE_DATA = REMOVE_APPCACHE | REMOVE_COOKIES | REMOVE_FILE_SYSTEMS |
|
| - REMOVE_INDEXEDDB |
|
| - REMOVE_LOCAL_STORAGE |
|
| - REMOVE_PLUGIN_DATA |
|
| - REMOVE_SERVICE_WORKERS |
|
| - REMOVE_CACHE_STORAGE |
|
| - REMOVE_WEBSQL |
|
| - REMOVE_CHANNEL_IDS |
|
| -#if BUILDFLAG(ANDROID_JAVA_UI)
|
| - REMOVE_WEBAPP_DATA |
|
| -#endif
|
| - REMOVE_SITE_USAGE_DATA |
|
| - REMOVE_DURABLE_PERMISSION,
|
| -
|
| - // Datatypes protected by Important Sites.
|
| - IMPORTANT_SITES_DATATYPES = REMOVE_SITE_DATA |
|
| - REMOVE_CACHE,
|
| -
|
| - // Datatypes that can be deleted partially per URL / origin / domain,
|
| - // whichever makes sense.
|
| - FILTERABLE_DATATYPES = REMOVE_SITE_DATA |
|
| - REMOVE_CACHE |
|
| - REMOVE_DOWNLOADS,
|
| -
|
| - // Includes all the available remove options. Meant to be used by clients
|
| - // that wish to wipe as much data as possible from a Profile, to make it
|
| - // look like a new Profile.
|
| - REMOVE_ALL = REMOVE_SITE_DATA | REMOVE_CACHE | REMOVE_DOWNLOADS |
|
| - REMOVE_FORM_DATA |
|
| - REMOVE_HISTORY |
|
| - REMOVE_PASSWORDS |
|
| - REMOVE_MEDIA_LICENSES,
|
| -
|
| - // Includes all available remove options. Meant to be used when the Profile
|
| - // is scheduled to be deleted, and all possible data should be wiped from
|
| - // disk as soon as possible.
|
| - REMOVE_WIPE_PROFILE = REMOVE_ALL | REMOVE_NOCHECKS,
|
| - };
|
| -
|
| - // Important sites protect a small set of sites from the deletion of certain
|
| - // datatypes. Therefore, those datatypes must be filterable by
|
| - // url/origin/domain.
|
| - static_assert(0 == (IMPORTANT_SITES_DATATYPES & ~FILTERABLE_DATATYPES),
|
| - "All important sites datatypes must be filterable.");
|
| -
|
| - // A helper enum to report the deletion of cookies and/or cache. Do not
|
| - // reorder the entries, as this enum is passed to UMA.
|
| - enum CookieOrCacheDeletionChoice {
|
| - NEITHER_COOKIES_NOR_CACHE,
|
| - ONLY_COOKIES,
|
| - ONLY_CACHE,
|
| - BOTH_COOKIES_AND_CACHE,
|
| - MAX_CHOICE_VALUE
|
| - };
|
| -
|
| - // Observer is notified when its own removal task is done.
|
| - class Observer {
|
| - public:
|
| - // Called when a removal task is finished. Note that every removal task can
|
| - // only have one observer attached to it, and only that one is called.
|
| - virtual void OnBrowsingDataRemoverDone() = 0;
|
| -
|
| - protected:
|
| - virtual ~Observer() {}
|
| - };
|
| -
|
| // The completion inhibitor can artificially delay completion of the browsing
|
| // data removal process. It is used during testing to simulate scenarios in
|
| // which the deletion stalls or takes a very long time.
|
| @@ -182,7 +47,7 @@ class BrowsingDataRemover : public KeyedService {
|
| // and will be prevented from completing until after the callback
|
| // |continue_to_completion| is run.
|
| virtual void OnBrowsingDataRemoverWouldComplete(
|
| - BrowsingDataRemover* remover,
|
| + BrowsingDataRemoverImpl* remover,
|
| const base::Closure& continue_to_completion) = 0;
|
|
|
| protected:
|
| @@ -215,7 +80,7 @@ class BrowsingDataRemover : public KeyedService {
|
| base::WeakPtrFactory<SubTask> weak_ptr_factory_;
|
| };
|
|
|
| - // Is the BrowsingDataRemover currently in the process of removing data?
|
| + // Is the BrowsingDataRemoverImpl currently in the process of removing data?
|
| bool is_removing() { return is_removing_; }
|
|
|
| // Sets a CompletionInhibitor, which will be notified each time an instance is
|
| @@ -227,54 +92,41 @@ class BrowsingDataRemover : public KeyedService {
|
| completion_inhibitor_ = inhibitor;
|
| }
|
|
|
| - // Called by the embedder to provide the delegate that will take care of
|
| - // deleting embedder-specific data.
|
| - void set_embedder_delegate(
|
| - std::unique_ptr<BrowsingDataRemoverDelegate> embedder_delegate) {
|
| - embedder_delegate_ = std::move(embedder_delegate);
|
| - }
|
| + // BrowsingDataRemover implementation:
|
| + void SetEmbedderDelegate(
|
| + std::unique_ptr<BrowsingDataRemoverDelegate> embedder_delegate) override;
|
| + BrowsingDataRemoverDelegate* GetEmbedderDelegate() const override;
|
|
|
| - BrowsingDataRemoverDelegate* get_embedder_delegate() const {
|
| - return embedder_delegate_.get();
|
| - }
|
| -
|
| - // Removes browsing data within the given |time_range|, with datatypes being
|
| - // specified by |remove_mask| and origin types by |origin_type_mask|.
|
| void Remove(const base::Time& delete_begin,
|
| const base::Time& delete_end,
|
| int remove_mask,
|
| - int origin_type_mask);
|
| -
|
| - // A version of the above that in addition informs the |observer| when the
|
| - // removal task is finished.
|
| + int origin_type_mask) override;
|
| void RemoveAndReply(const base::Time& delete_begin,
|
| const base::Time& delete_end,
|
| int remove_mask,
|
| int origin_type_mask,
|
| - Observer* observer);
|
| -
|
| - // Like Remove(), but in case of URL-keyed only removes data whose URL match
|
| - // |filter_builder| (e.g. are on certain origin or domain).
|
| - // RemoveWithFilter() currently only works with FILTERABLE_DATATYPES.
|
| + Observer* observer) override;
|
| void RemoveWithFilter(
|
| const base::Time& delete_begin,
|
| const base::Time& delete_end,
|
| int remove_mask,
|
| int origin_type_mask,
|
| - std::unique_ptr<BrowsingDataFilterBuilder> filter_builder);
|
| -
|
| - // A version of the above that in addition informs the |observer| when the
|
| - // removal task is finished.
|
| + std::unique_ptr<BrowsingDataFilterBuilder> filter_builder) override;
|
| void RemoveWithFilterAndReply(
|
| const base::Time& delete_begin,
|
| const base::Time& delete_end,
|
| int remove_mask,
|
| int origin_type_mask,
|
| std::unique_ptr<BrowsingDataFilterBuilder> filter_builder,
|
| - Observer* observer);
|
| + Observer* observer) override;
|
|
|
| - void AddObserver(Observer* observer);
|
| - void RemoveObserver(Observer* observer);
|
| + void AddObserver(Observer* observer) override;
|
| + void RemoveObserver(Observer* observer) override;
|
| +
|
| + const base::Time& GetLastUsedBeginTime() override;
|
| + const base::Time& GetLastUsedEndTime() override;
|
| + int GetLastUsedRemovalMask() override;
|
| + int GetLastUsedOriginTypeMask() override;
|
|
|
| // Used for testing.
|
| void OverrideStoragePartitionForTesting(
|
| @@ -285,20 +137,11 @@ class BrowsingDataRemover : public KeyedService {
|
| scoped_refptr<BrowsingDataFlashLSOHelper> flash_lso_helper);
|
| #endif
|
|
|
| - // Parameters of the last call are exposed to be used by tests. Removal and
|
| - // origin type masks equal to -1 mean that no removal has ever been executed.
|
| - // TODO(msramek): If other consumers than tests are interested in this,
|
| - // consider returning them in OnBrowsingDataRemoverDone() callback.
|
| - const base::Time& GetLastUsedBeginTime();
|
| - const base::Time& GetLastUsedEndTime();
|
| - int GetLastUsedRemovalMask();
|
| - int GetLastUsedOriginTypeMask();
|
| -
|
| protected:
|
| // Use BrowsingDataRemoverFactory::GetForBrowserContext to get an instance of
|
| // this class. The constructor is protected so that the class is mockable.
|
| - BrowsingDataRemover(content::BrowserContext* browser_context);
|
| - ~BrowsingDataRemover() override;
|
| + explicit BrowsingDataRemoverImpl(content::BrowserContext* browser_context);
|
| + ~BrowsingDataRemoverImpl() override;
|
|
|
| // A common reduction of all public Remove[WithFilter][AndReply] methods.
|
| virtual void RemoveInternal(
|
| @@ -447,9 +290,9 @@ class BrowsingDataRemover : public KeyedService {
|
| // We do not own this.
|
| content::StoragePartition* storage_partition_for_testing_ = nullptr;
|
|
|
| - base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_;
|
| + base::WeakPtrFactory<BrowsingDataRemoverImpl> weak_ptr_factory_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover);
|
| + DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverImpl);
|
| };
|
|
|
| -#endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_
|
| +#endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_IMPL_H_
|
|
|