diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-20 18:50:00 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-20 18:50:00 +0000 |
commit | c4152d3f59beb637b0696a592e356131ef5bde74 (patch) | |
tree | 48dbe8941bfa41af31f4b60d86316447d750e673 /chrome/browser/cookies_tree_model.h | |
parent | d7534d5e16158e750ccb23792bc6855d49c6e2d2 (diff) | |
download | chromium_src-c4152d3f59beb637b0696a592e356131ef5bde74.zip chromium_src-c4152d3f59beb637b0696a592e356131ef5bde74.tar.gz chromium_src-c4152d3f59beb637b0696a592e356131ef5bde74.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.
Landing for Marcus
Original CL: http://codereview.chromium.org/523139/show
Review URL: http://codereview.chromium.org/546081
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cookies_tree_model.h')
-rw-r--r-- | chrome/browser/cookies_tree_model.h | 101 |
1 files changed, 91 insertions, 10 deletions
diff --git a/chrome/browser/cookies_tree_model.h b/chrome/browser/cookies_tree_model.h index 11b7f8a..45c7585 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,64 @@ 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() {} + virtual ~CookiesTreeModel(); // TreeModel methods: // Returns the set of icons for the nodes in the tree. You only need override @@ -185,6 +254,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 +263,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_model_; + LocalStorageInfoList local_storage_info_list_; + DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); }; |