| Index: chrome/browser/cookies_tree_model.h
|
| diff --git a/chrome/browser/cookies_tree_model.h b/chrome/browser/cookies_tree_model.h
|
| index e99fa7f5188930d2aab740e58e49744c74e18ac8..ed6309db2399fb55da541c9d28d5f5b6ecba6423 100644
|
| --- a/chrome/browser/cookies_tree_model.h
|
| +++ b/chrome/browser/cookies_tree_model.h
|
| @@ -24,6 +24,7 @@
|
| #include "chrome/browser/browsing_data_indexed_db_helper.h"
|
| #include "chrome/browser/browsing_data_local_storage_helper.h"
|
| #include "chrome/browser/browsing_data_quota_helper.h"
|
| +#include "chrome/browser/local_data_container.h"
|
| #include "chrome/common/content_settings.h"
|
| #include "net/base/server_bound_cert_store.h"
|
| #include "net/cookies/cookie_monster.h"
|
| @@ -39,18 +40,19 @@ class CookieTreeCookieNode;
|
| class CookieTreeCookiesNode;
|
| class CookieTreeDatabaseNode;
|
| class CookieTreeDatabasesNode;
|
| -class CookieTreeFileSystemsNode;
|
| class CookieTreeFileSystemNode;
|
| +class CookieTreeFileSystemsNode;
|
| +class CookieTreeIndexedDBNode;
|
| +class CookieTreeIndexedDBsNode;
|
| class CookieTreeLocalStorageNode;
|
| class CookieTreeLocalStoragesNode;
|
| +class CookieTreeOriginNode;
|
| +class CookieTreeQuotaNode;
|
| class CookieTreeServerBoundCertNode;
|
| class CookieTreeServerBoundCertsNode;
|
| -class CookieTreeQuotaNode;
|
| class CookieTreeSessionStorageNode;
|
| class CookieTreeSessionStoragesNode;
|
| -class CookieTreeIndexedDBNode;
|
| -class CookieTreeIndexedDBsNode;
|
| -class CookieTreeOriginNode;
|
| +
|
|
|
| // CookieTreeNode -------------------------------------------------------------
|
| // The base node type in the Cookies, Databases, and Local Storage options
|
| @@ -66,6 +68,7 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> {
|
| enum NodeType {
|
| TYPE_NONE,
|
| TYPE_ROOT, // This is used for CookieTreeRootNode nodes.
|
| + TYPE_APP, // This is used for CookieTreeAppNode nodes.
|
| TYPE_ORIGIN, // This is used for CookieTreeOriginNode nodes.
|
| TYPE_COOKIES, // This is used for CookieTreeCookiesNode nodes.
|
| TYPE_COOKIE, // This is used for CookieTreeCookieNode nodes.
|
| @@ -107,6 +110,14 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> {
|
| return *this;
|
| }
|
|
|
| + DetailedInfo& InitApp(const std::string& app_name,
|
| + const std::string& app_id) {
|
| + Init(TYPE_APP);
|
| + this->app_name = app_name;
|
| + this->app_id = app_id;
|
| + return *this;
|
| + }
|
| +
|
| DetailedInfo& InitCookie(
|
| const net::CookieMonster::CanonicalCookie* cookie) {
|
| Init(TYPE_COOKIE);
|
| @@ -171,6 +182,8 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> {
|
| return *this;
|
| }
|
|
|
| + std::string app_name;
|
| + std::string app_id;
|
| string16 origin;
|
| NodeType node_type;
|
| const net::CookieMonster::CanonicalCookie* cookie;
|
| @@ -202,11 +215,19 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> {
|
| virtual DetailedInfo GetDetailedInfo() const = 0;
|
|
|
| protected:
|
| + // This class implements comparison by title of a CookieTreeNode. It is
|
| + // used to insert nodes in alphabetical order.
|
| class NodeTitleComparator {
|
| public:
|
| bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs);
|
| };
|
|
|
| + // This class implements comparison by application id of a CookieTreeAppNode.
|
| + class AppNodeComparator {
|
| + public:
|
| + bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs);
|
| + };
|
| +
|
| void AddChildSortedByTitle(CookieTreeNode* new_child);
|
|
|
| private:
|
| @@ -214,6 +235,27 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> {
|
| DISALLOW_COPY_AND_ASSIGN(CookieTreeNode);
|
| };
|
|
|
| +// CookieTreeAppNode ----------------------------------------------------------
|
| +class CookieTreeAppNode : public CookieTreeNode {
|
| + public:
|
| + explicit CookieTreeAppNode(const std::string& app_name,
|
| + const std::string& app_id);
|
| + virtual ~CookieTreeAppNode();
|
| +
|
| + CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url);
|
| +
|
| + // CookieTreeNode methods:
|
| + virtual DetailedInfo GetDetailedInfo() const OVERRIDE;
|
| +
|
| + const std::string& app_id() const { return app_id_; }
|
| +
|
| + private:
|
| + std::string app_name_;
|
| + std::string app_id_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CookieTreeAppNode);
|
| +};
|
| +
|
| // CookieTreeRootNode ---------------------------------------------------------
|
| // The node at the root of the CookieTree that gets inserted into the view.
|
| class CookieTreeRootNode : public CookieTreeNode {
|
| @@ -221,7 +263,10 @@ class CookieTreeRootNode : public CookieTreeNode {
|
| explicit CookieTreeRootNode(CookiesTreeModel* model);
|
| virtual ~CookieTreeRootNode();
|
|
|
| - CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url);
|
| + // Creates a new CookieTreeAppNode, based on the app id and name. If a node,
|
| + // already exists in the tree, it returns a pointer to it.
|
| + CookieTreeAppNode* GetOrCreateAppNode(const std::string& app_name,
|
| + const std::string& app_id);
|
|
|
| // CookieTreeNode methods:
|
| virtual CookiesTreeModel* GetModel() const OVERRIDE;
|
| @@ -237,7 +282,7 @@ class CookieTreeRootNode : public CookieTreeNode {
|
| class CookieTreeOriginNode : public CookieTreeNode {
|
| public:
|
| // Returns the origin node's title to use for a given URL.
|
| - static std::wstring TitleForUrl(const GURL& url);
|
| + static string16 TitleForUrl(const GURL& url);
|
|
|
| explicit CookieTreeOriginNode(const GURL& url);
|
| virtual ~CookieTreeOriginNode();
|
| @@ -614,9 +659,41 @@ class CookieTreeServerBoundCertsNode : public CookieTreeNode {
|
| DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode);
|
| };
|
|
|
| +// CookiesTreeModelDelegate ---------------------------------------------------
|
| +// This is a delegate definition class. It is used by the CookiesTreeModel
|
| +// to pass a pointer to itself to each of the LocalDataContainer objects, so
|
| +// when resource fetching is complete, the objects can call back to the model
|
| +// and update it. The CookiesTreeModel instance must outlive the
|
| +// LocalDataContainer instances.
|
| +class CookiesTreeModelDelegate {
|
| + public:
|
| + virtual void PopulateAppCacheInfoWithFilter(const std::string* app_id,
|
| + const string16& filter) = 0;
|
| + virtual void PopulateCookieInfoWithFilter(const std::string* app_id,
|
| + const string16& filter) = 0;
|
| + virtual void PopulateDatabaseInfoWithFilter(const std::string* app_id,
|
| + const string16& filter) = 0;
|
| + virtual void PopulateLocalStorageInfoWithFilter(const std::string* app_id,
|
| + const string16& filter) = 0;
|
| + virtual void PopulateSessionStorageInfoWithFilter(
|
| + const std::string* app_id, const string16& filter) = 0;
|
| + virtual void PopulateIndexedDBInfoWithFilter(const std::string* app_id,
|
| + const string16& filter) = 0;
|
| + virtual void PopulateFileSystemInfoWithFilter(const std::string* app_id,
|
| + const string16& filter) = 0;
|
| + virtual void PopulateQuotaInfoWithFilter(const std::string* app_id,
|
| + const string16& filter) = 0;
|
| + virtual void PopulateServerBoundCertInfoWithFilter(
|
| + const std::string* app_id, const string16& filter) = 0;
|
| +};
|
| +
|
| // CookiesTreeModel -----------------------------------------------------------
|
| -class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
|
| +class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode>,
|
| + public CookiesTreeModelDelegate {
|
| public:
|
| + CookiesTreeModel(const ContainerMap& apps_map, bool use_cookie_source);
|
| + virtual ~CookiesTreeModel();
|
| +
|
| // Because non-cookie nodes are fetched in a background thread, they are not
|
| // present at the time the Model is created. The Model then notifies its
|
| // observers for every item added from databases, local storage, and
|
| @@ -628,19 +705,6 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
|
| virtual void TreeModelEndBatch(CookiesTreeModel* model) {}
|
| };
|
|
|
| - CookiesTreeModel(
|
| - BrowsingDataCookieHelper* cookie_helper,
|
| - BrowsingDataDatabaseHelper* database_helper,
|
| - BrowsingDataLocalStorageHelper* local_storage_helper,
|
| - BrowsingDataLocalStorageHelper* session_storage_helper,
|
| - BrowsingDataAppCacheHelper* appcache_helper,
|
| - BrowsingDataIndexedDBHelper* indexed_db_helper,
|
| - BrowsingDataFileSystemHelper* file_system_helper,
|
| - BrowsingDataQuotaHelper* quota_helper,
|
| - BrowsingDataServerBoundCertHelper* server_bound_cert_helper,
|
| - bool use_cookie_source);
|
| - virtual ~CookiesTreeModel();
|
| -
|
| // ui::TreeModel methods:
|
| // Returns the set of icons for the nodes in the tree. You only need override
|
| // this if you don't want to use the default folder icons.
|
| @@ -653,10 +717,13 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
|
|
|
| // CookiesTreeModel methods:
|
| void DeleteAllStoredObjects();
|
| +
|
| + // Deletes all the stored objects for a specific app, identified by |app_id|.
|
| + void DeleteStoredObjectsForApp(const std::string& app_id);
|
| void DeleteCookieNode(CookieTreeNode* cookie_node);
|
|
|
| // Filter the origins to only display matched results.
|
| - void UpdateSearchResults(const std::wstring& filter);
|
| + void UpdateSearchResults(const string16& filter);
|
|
|
| // Manages CookiesTreeModel::Observers. This will also call
|
| // TreeNodeModel::AddObserver so that it gets all the proper notifications.
|
| @@ -665,99 +732,55 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
|
| virtual void AddCookiesTreeObserver(Observer* observer);
|
| virtual void RemoveCookiesTreeObserver(Observer* observer);
|
|
|
| + // CookiesTreeModelDelegate methods:
|
| + virtual void PopulateAppCacheInfoWithFilter(
|
| + const std::string* app_id, const string16& filter) OVERRIDE;
|
| + virtual void PopulateCookieInfoWithFilter(
|
| + const std::string* app_id, const string16& filter) OVERRIDE;
|
| + virtual void PopulateDatabaseInfoWithFilter(
|
| + const std::string* app_id, const string16& filter) OVERRIDE;
|
| + virtual void PopulateLocalStorageInfoWithFilter(
|
| + const std::string* app_id, const string16& filter) OVERRIDE;
|
| + virtual void PopulateSessionStorageInfoWithFilter(
|
| + const std::string* app_id, const string16& filter) OVERRIDE;
|
| + virtual void PopulateIndexedDBInfoWithFilter(
|
| + const std::string* app_id, const string16& filter) OVERRIDE;
|
| + virtual void PopulateFileSystemInfoWithFilter(
|
| + const std::string* app_id, const string16& filter) OVERRIDE;
|
| + virtual void PopulateQuotaInfoWithFilter(
|
| + const std::string* app_id, const string16& filter) OVERRIDE;
|
| + virtual void PopulateServerBoundCertInfoWithFilter(
|
| + const std::string* app_id, const string16& filter) OVERRIDE;
|
| +
|
| + BrowsingDataCookieHelper* GetCookieHelper(const std::string& app_id);
|
| + LocalDataContainer* GetLocalDataContainer(const std::string& app_id);
|
| +
|
| private:
|
| enum CookieIconIndex {
|
| ORIGIN = 0,
|
| COOKIE = 1,
|
| DATABASE = 2
|
| };
|
| - typedef std::list<net::CookieMonster::CanonicalCookie> CookieList;
|
| - typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo>
|
| - DatabaseInfoList;
|
| - typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>
|
| - LocalStorageInfoList;
|
| - typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>
|
| - SessionStorageInfoList;
|
| - typedef std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo>
|
| - IndexedDBInfoList;
|
| - typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo>
|
| - FileSystemInfoList;
|
| - typedef std::list<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoArray;
|
| - typedef net::ServerBoundCertStore::ServerBoundCertList ServerBoundCertList;
|
| -
|
| - void OnAppCacheModelInfoLoaded();
|
| - void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list);
|
| - void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info);
|
| - void OnLocalStorageModelInfoLoaded(
|
| - const LocalStorageInfoList& local_storage_info);
|
| - void OnSessionStorageModelInfoLoaded(
|
| - const LocalStorageInfoList& local_storage_info);
|
| - void OnIndexedDBModelInfoLoaded(
|
| - const IndexedDBInfoList& indexed_db_info);
|
| - void OnFileSystemModelInfoLoaded(
|
| - const FileSystemInfoList& file_system_info);
|
| - void OnQuotaModelInfoLoaded(const QuotaInfoArray& quota_info);
|
| - void OnServerBoundCertModelInfoLoaded(const ServerBoundCertList& cert_list);
|
| -
|
| - void PopulateAppCacheInfoWithFilter(const std::wstring& filter);
|
| - void PopulateCookieInfoWithFilter(const std::wstring& filter);
|
| - void PopulateDatabaseInfoWithFilter(const std::wstring& filter);
|
| - void PopulateLocalStorageInfoWithFilter(const std::wstring& filter);
|
| - void PopulateSessionStorageInfoWithFilter(const std::wstring& filter);
|
| - void PopulateIndexedDBInfoWithFilter(const std::wstring& filter);
|
| - void PopulateFileSystemInfoWithFilter(const std::wstring& filter);
|
| - void PopulateQuotaInfoWithFilter(const std::wstring& filter);
|
| - void PopulateServerBoundCertInfoWithFilter(const std::wstring& filter);
|
|
|
| void NotifyObserverBeginBatch();
|
| void NotifyObserverEndBatch();
|
|
|
| - scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_;
|
| - scoped_refptr<BrowsingDataCookieHelper> cookie_helper_;
|
| - scoped_refptr<BrowsingDataDatabaseHelper> database_helper_;
|
| - scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_;
|
| - scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_;
|
| - scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_;
|
| - scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_;
|
| - scoped_refptr<BrowsingDataQuotaHelper> quota_helper_;
|
| - scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_;
|
| -
|
| - std::map<GURL, std::list<appcache::AppCacheInfo> > appcache_info_;
|
| - CookieList cookie_list_;
|
| - DatabaseInfoList database_info_list_;
|
| - LocalStorageInfoList local_storage_info_list_;
|
| - LocalStorageInfoList session_storage_info_list_;
|
| - IndexedDBInfoList indexed_db_info_list_;
|
| - FileSystemInfoList file_system_info_list_;
|
| - QuotaInfoArray quota_info_list_;
|
| - ServerBoundCertList server_bound_cert_list_;
|
| + // Map of app ids to LocalDataContainer objects to use when retrieving
|
| + // locally stored data.
|
| + ContainerMap app_data_map_;
|
|
|
| // The CookiesTreeModel maintains a separate list of observers that are
|
| // specifically of the type CookiesTreeModel::Observer.
|
| ObserverList<Observer> cookies_observer_list_;
|
|
|
| - // If this is non-zero, then this model is batching updates (there's a lot of
|
| - // notifications coming down the pipe). This is an integer is used to balance
|
| - // calls to Begin/EndBatch() if they're called in a nested manner.
|
| - int batch_update_;
|
| -
|
| // If true, use the CanonicalCookie::Source attribute to group cookies.
|
| // Otherwise, use the CanonicalCookie::Domain attribute.
|
| bool use_cookie_source_;
|
|
|
| - base::WeakPtrFactory<CookiesTreeModel> weak_ptr_factory_;
|
| -
|
| - friend class CookieTreeAppCacheNode;
|
| - friend class CookieTreeCookieNode;
|
| - friend class CookieTreeDatabaseNode;
|
| - friend class CookieTreeLocalStorageNode;
|
| - friend class CookieTreeSessionStorageNode;
|
| - friend class CookieTreeIndexedDBNode;
|
| - friend class CookieTreeFileSystemNode;
|
| - friend class CookieTreeQuotaNode;
|
| - friend class CookieTreeServerBoundCertNode;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel);
|
| + // If this is non-zero, then this model is batching updates (there's a lot of
|
| + // notifications coming down the pipe). This is an integer is used to balance
|
| + // calls to Begin/EndBatch() if they're called in a nested manner.
|
| + int batch_update_;
|
| };
|
|
|
| #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_
|
|
|