| // Copyright 2012 The Chromium Authors |
| // 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_LOCAL_DATA_CONTAINER_H_ |
| #define CHROME_BROWSER_BROWSING_DATA_LOCAL_DATA_CONTAINER_H_ |
| |
| #include <list> |
| #include <map> |
| #include <vector> |
| |
| #include "base/memory/raw_ptr.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/weak_ptr.h" |
| #include "components/browsing_data/content/browsing_data_quota_helper.h" |
| #include "components/browsing_data/content/cookie_helper.h" |
| #include "components/browsing_data/content/local_shared_objects_container.h" |
| #include "components/browsing_data/content/local_storage_helper.h" |
| |
| class CookiesTreeModel; |
| class LocalDataContainer; |
| |
| namespace content { |
| class StoragePartition; |
| struct StorageUsageInfo; |
| } |
| |
| namespace net { |
| class CanonicalCookie; |
| } |
| |
| // This class is a wrapper around all the browsing_data::*Helper classes. |
| class LocalDataContainer { |
| public: |
| // Friendly typedefs for the multiple types of lists used in the model. |
| using CookieList = std::list<net::CanonicalCookie>; |
| using LocalStorageInfoList = std::list<content::StorageUsageInfo>; |
| using SessionStorageInfoList = std::list<content::StorageUsageInfo>; |
| using QuotaInfoList = std::list<BrowsingDataQuotaHelper::QuotaInfo>; |
| |
| static std::unique_ptr<LocalDataContainer> |
| CreateFromLocalSharedObjectsContainer( |
| const browsing_data::LocalSharedObjectsContainer& shared_objects); |
| |
| static std::unique_ptr<LocalDataContainer> CreateFromStoragePartition( |
| content::StoragePartition* storage_partition, |
| browsing_data::CookieHelper::IsDeletionDisabledCallback |
| is_cookie_deletion_disabled_callback); |
| |
| LocalDataContainer( |
| scoped_refptr<browsing_data::CookieHelper> cookie_helper, |
| scoped_refptr<browsing_data::LocalStorageHelper> local_storage_helper, |
| scoped_refptr<browsing_data::LocalStorageHelper> session_storage_helper, |
| scoped_refptr<BrowsingDataQuotaHelper> quota_helper); |
| |
| LocalDataContainer(const LocalDataContainer&) = delete; |
| LocalDataContainer& operator=(const LocalDataContainer&) = delete; |
| |
| virtual ~LocalDataContainer(); |
| |
| // This method must be called to start the process of fetching the resources. |
| // The delegate passed in is called back to deliver the updates. |
| void Init(CookiesTreeModel* delegate); |
| |
| private: |
| friend class CookiesTreeModel; |
| friend class CookieTreeCookieNode; |
| friend class CookieTreeLocalStorageNode; |
| friend class CookieTreeSessionStorageNode; |
| friend class CookieTreeQuotaNode; |
| |
| // Callback methods to be invoked when fetching the data is complete. |
| void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list); |
| void OnLocalStorageModelInfoLoaded( |
| const LocalStorageInfoList& local_storage_info); |
| void OnSessionStorageModelInfoLoaded( |
| const LocalStorageInfoList& local_storage_info); |
| void OnQuotaModelInfoLoaded(const QuotaInfoList& quota_info); |
| |
| // Pointers to the helper objects, needed to retreive all the types of locally |
| // stored data. |
| scoped_refptr<browsing_data::CookieHelper> cookie_helper_; |
| scoped_refptr<browsing_data::LocalStorageHelper> local_storage_helper_; |
| scoped_refptr<browsing_data::LocalStorageHelper> session_storage_helper_; |
| scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; |
| |
| // Storage for all the data that was retrieved through the helper objects. |
| // The collected data is used for (re)creating the CookiesTreeModel. |
| CookieList cookie_list_; |
| LocalStorageInfoList local_storage_info_list_; |
| LocalStorageInfoList session_storage_info_list_; |
| QuotaInfoList quota_info_list_; |
| |
| // A delegate, which must outlive this object. The update callbacks use the |
| // delegate to deliver the updated data to the CookieTreeModel. |
| raw_ptr<CookiesTreeModel> model_ = nullptr; |
| |
| base::WeakPtrFactory<LocalDataContainer> weak_ptr_factory_{this}; |
| }; |
| |
| #endif // CHROME_BROWSER_BROWSING_DATA_LOCAL_DATA_CONTAINER_H_ |