diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-25 13:50:48 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-25 13:50:48 +0000 |
commit | 8f9aefdd9324680937c83b2137ecba8584322245 (patch) | |
tree | 7ace3e1ab52d41b24f8f268c8e29592253019ac9 /chrome/browser/cookies_tree_model.h | |
parent | 099fdcd5ff79ae6815f052060a605ad9a3454ad5 (diff) | |
download | chromium_src-8f9aefdd9324680937c83b2137ecba8584322245.zip chromium_src-8f9aefdd9324680937c83b2137ecba8584322245.tar.gz chromium_src-8f9aefdd9324680937c83b2137ecba8584322245.tar.bz2 |
Adds local storage nodes to cookie tree model and cookies view.
BUG=none
TEST=The show cookie dialog box should have a new node "local storage" when appropriate. When selected, it should display details of local storage (name, size on disk, last modified) in the details frame.
Review URL: http://codereview.chromium.org/523139
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37001 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cookies_tree_model.h')
-rw-r--r-- | chrome/browser/cookies_tree_model.h | 105 |
1 files changed, 94 insertions, 11 deletions
diff --git a/chrome/browser/cookies_tree_model.h b/chrome/browser/cookies_tree_model.h index 11b7f8a..8a4bd60 100644 --- a/chrome/browser/cookies_tree_model.h +++ b/chrome/browser/cookies_tree_model.h @@ -10,9 +10,12 @@ #include "app/tree_node_model.h" #include "base/scoped_ptr.h" +#include "chrome/browser/browsing_data_local_storage_helper.h" #include "net/base/cookie_monster.h" class CookiesTreeModel; +class CookieTreeLocalStorageNode; +class CookieTreeLocalStoragesNode; class CookieTreeCookieNode; class CookieTreeCookiesNode; class CookieTreeOriginNode; @@ -33,18 +36,27 @@ class CookieTreeNode : public TreeNode<CookieTreeNode> { TYPE_ROOT, // This is used for CookieTreeRootNode 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. + TYPE_COOKIE, // This is used for CookieTreeCookieNode nodes. + TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. + TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. }; DetailedInfo(const std::wstring& origin, NodeType node_type, - const net::CookieMonster::CookieListPair* cookie) + const net::CookieMonster::CookieListPair* cookie, + const BrowsingDataLocalStorageHelper::LocalStorageInfo* + local_storage_info) : origin(origin), node_type(node_type), - cookie(cookie) {} + cookie(cookie), + local_storage_info(local_storage_info) { + if (node_type == TYPE_LOCAL_STORAGE) + DCHECK(local_storage_info); + } std::wstring origin; NodeType node_type; const net::CookieMonster::CookieListPair* cookie; + const BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info; }; CookieTreeNode() {} @@ -79,7 +91,7 @@ class CookieTreeRootNode : public CookieTreeNode { // CookieTreeNode methods: virtual CookiesTreeModel* GetModel() const { return model_; } virtual DetailedInfo GetDetailedInfo() const { - return DetailedInfo(std::wstring(), DetailedInfo::TYPE_ROOT, NULL); + return DetailedInfo(std::wstring(), DetailedInfo::TYPE_ROOT, NULL, NULL); } private: @@ -92,16 +104,19 @@ class CookieTreeRootNode : public CookieTreeNode { class CookieTreeOriginNode : public CookieTreeNode { public: explicit CookieTreeOriginNode(const std::wstring& origin) - : CookieTreeNode(origin), cookies_child_(NULL) {} + : CookieTreeNode(origin), cookies_child_(NULL), + local_storages_child_(NULL) {} virtual ~CookieTreeOriginNode() {} // CookieTreeNode methods: virtual DetailedInfo GetDetailedInfo() const { - return DetailedInfo(GetTitle(), DetailedInfo::TYPE_ORIGIN, NULL); + return DetailedInfo(GetTitle(), DetailedInfo::TYPE_ORIGIN, NULL, NULL); } // CookieTreeOriginNode methods: CookieTreeCookiesNode* GetOrCreateCookiesNode(); + CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); + private: // A pointer to the COOKIES node. Eventually we will also have database, @@ -111,6 +126,7 @@ class CookieTreeOriginNode : public CookieTreeNode { // DATABASES etc node seems less preferable than storing an extra pointer per // origin. CookieTreeCookiesNode* cookies_child_; + CookieTreeLocalStoragesNode* local_storages_child_; DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); }; @@ -124,7 +140,7 @@ class CookieTreeCookiesNode : public CookieTreeNode { // CookieTreeNode methods: virtual DetailedInfo GetDetailedInfo() const { return DetailedInfo(GetParent()->GetTitle(), DetailedInfo::TYPE_COOKIES, - NULL); + NULL, NULL); } // CookieTreeCookiesNode methods: @@ -147,7 +163,7 @@ class CookieTreeCookieNode : public CookieTreeNode { virtual void DeleteStoredObjects(); virtual DetailedInfo GetDetailedInfo() const { return DetailedInfo(GetParent()->GetParent()->GetTitle(), - DetailedInfo::TYPE_COOKIE, cookie_); + DetailedInfo::TYPE_COOKIE, cookie_, NULL); } private: @@ -165,11 +181,66 @@ class CookieTreeCookieNode : public CookieTreeNode { DISALLOW_COPY_AND_ASSIGN(CookieTreeCookieNode); }; +// CookieTreeLocalStoragesNode ------------------------------------------------- +class CookieTreeLocalStoragesNode : public CookieTreeNode { + public: + CookieTreeLocalStoragesNode(); + virtual ~CookieTreeLocalStoragesNode() {} + + // CookieTreeNode methods: + virtual DetailedInfo GetDetailedInfo() const { + return DetailedInfo(GetParent()->GetTitle(), + DetailedInfo::TYPE_LOCAL_STORAGES, + NULL, + NULL); + } + + // CookieTreeStoragesNode methods: + void AddLocalStorageNode(CookieTreeLocalStorageNode* child); + + private: + DISALLOW_COPY_AND_ASSIGN(CookieTreeLocalStoragesNode); +}; + +class CookieTreeLocalStorageNode : public CookieTreeNode { + public: + friend class CookieTreeLocalStoragesNode; + + // Does not take ownership of local_storage_info, and local_storage_info + // should remain valid at least as long as the CookieTreeStorageNode is valid. + explicit CookieTreeLocalStorageNode( + BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info); + virtual ~CookieTreeLocalStorageNode() {} + + // CookieTreeStorageNode methods: + virtual void DeleteStoredObjects(); + virtual DetailedInfo GetDetailedInfo() const { + return DetailedInfo(GetParent()->GetParent()->GetTitle(), + DetailedInfo::TYPE_LOCAL_STORAGE, NULL, + local_storage_info_); + } + + private: + // Comparator functor, takes CookieTreeNode so that we can use it in + // lower_bound using children()'s iterators, which are CookieTreeNode*. + class CookieNodeComparator { + public: + bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); + }; + + // local_storage_info_ is not owned by the node, and is expected to remain + // valid as long as the CookieTreeLocalStorageNode is valid. + BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info_; + + DISALLOW_COPY_AND_ASSIGN(CookieTreeLocalStorageNode); +}; class CookiesTreeModel : public TreeNodeModel<CookieTreeNode> { public: - explicit CookiesTreeModel(Profile* profile); - virtual ~CookiesTreeModel() {} + CookiesTreeModel( + Profile* profile, + BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper); + virtual ~CookiesTreeModel(); // TreeModel methods: // Returns the set of icons for the nodes in the tree. You only need override @@ -185,6 +256,8 @@ class CookiesTreeModel : public TreeNodeModel<CookieTreeNode> { void DeleteCookie(const net::CookieMonster::CookieListPair& cookie); void DeleteAllCookies(); void DeleteCookieNode(CookieTreeNode* cookie_node); + void DeleteLocalStorage(const FilePath& file_path); + void DeleteAllLocalStorage(); // Filter the origins to only display matched results. void UpdateSearchResults(const std::wstring& filter); @@ -192,18 +265,28 @@ class CookiesTreeModel : public TreeNodeModel<CookieTreeNode> { private: enum CookieIconIndex { ORIGIN = 0, - COOKIE = 1 + COOKIE = 1, + LOCAL_STORAGE = 2, }; typedef net::CookieMonster::CookieList CookieList; typedef std::vector<net::CookieMonster::CookieListPair*> CookiePtrList; + typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> + LocalStorageInfoList; void LoadCookies(); void LoadCookiesWithFilter(const std::wstring& filter); + void OnStorageModelInfoLoaded(const LocalStorageInfoList& local_storage_info); + + void PopulateLocalStorageInfoWithFilter(const std::wstring& filter); + // The profile from which this model sources cookies. Profile* profile_; CookieList all_cookies_; + scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; + LocalStorageInfoList local_storage_info_list_; + DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); }; |