OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_COOKIES_TREE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
6 #define CHROME_BROWSER_COOKIES_TREE_MODEL_H_ | 6 #define CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // TODO(viettrungluu): This header file #includes far too much and has too much | 9 // TODO(viettrungluu): This header file #includes far too much and has too much |
10 // inline code (which shouldn't be inline). | 10 // inline code (which shouldn't be inline). |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 class CookieTreeLocalStorageNode; | 44 class CookieTreeLocalStorageNode; |
45 class CookieTreeLocalStoragesNode; | 45 class CookieTreeLocalStoragesNode; |
46 class CookieTreeServerBoundCertNode; | 46 class CookieTreeServerBoundCertNode; |
47 class CookieTreeServerBoundCertsNode; | 47 class CookieTreeServerBoundCertsNode; |
48 class CookieTreeQuotaNode; | 48 class CookieTreeQuotaNode; |
49 class CookieTreeSessionStorageNode; | 49 class CookieTreeSessionStorageNode; |
50 class CookieTreeSessionStoragesNode; | 50 class CookieTreeSessionStoragesNode; |
51 class CookieTreeIndexedDBNode; | 51 class CookieTreeIndexedDBNode; |
52 class CookieTreeIndexedDBsNode; | 52 class CookieTreeIndexedDBsNode; |
53 class CookieTreeOriginNode; | 53 class CookieTreeOriginNode; |
54 class CookieTreeAppNode; | |
markusheintz_
2012/06/13 23:40:39
nit: It looks like this list of forward declaratio
nasko
2012/06/14 18:46:42
Done.
| |
55 class LocalDataContainer; | |
56 | |
57 // Friendly typedefs for the multiple types of lists used in the model. | |
58 namespace { | |
59 typedef std::map<string16, LocalDataContainer*> ContainerMap; | |
60 typedef std::list<net::CookieMonster::CanonicalCookie> CookieList; | |
markusheintz_
2012/06/13 23:40:39
This typedef is not necessary. The cookie monster
nasko
2012/06/14 18:46:42
Just moved code around. If I change it to the net:
| |
61 typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo> DatabaseInfoList; | |
62 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> | |
63 LocalStorageInfoList; | |
64 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> | |
65 SessionStorageInfoList; | |
66 typedef std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> | |
67 IndexedDBInfoList; | |
68 typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo> | |
69 FileSystemInfoList; | |
70 typedef std::list<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoArray; | |
markusheintz_
2012/06/13 23:40:39
nit: s/QuotaInfoArray/QuotaInfoList
1) To be cons
nasko
2012/06/14 18:46:42
All of these were just existing code being moved a
| |
71 typedef net::ServerBoundCertStore::ServerBoundCertList ServerBoundCertList; | |
72 | |
73 typedef std::map<GURL, std::list<appcache::AppCacheInfo> > AppCacheInfoMap; | |
74 } | |
54 | 75 |
55 // CookieTreeNode ------------------------------------------------------------- | 76 // CookieTreeNode ------------------------------------------------------------- |
56 // The base node type in the Cookies, Databases, and Local Storage options | 77 // The base node type in the Cookies, Databases, and Local Storage options |
57 // view, from which all other types are derived. Specialized from TreeNode in | 78 // view, from which all other types are derived. Specialized from TreeNode in |
58 // that it has a notion of deleting objects stored in the profile, and being | 79 // that it has a notion of deleting objects stored in the profile, and being |
59 // able to have its children do the same. | 80 // able to have its children do the same. |
60 class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { | 81 class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { |
61 public: | 82 public: |
62 // Used to pull out information for the InfoView (the details display below | 83 // Used to pull out information for the InfoView (the details display below |
63 // the tree control.) | 84 // the tree control.) |
64 struct DetailedInfo { | 85 struct DetailedInfo { |
65 // NodeType corresponds to the various CookieTreeNode types. | 86 // NodeType corresponds to the various CookieTreeNode types. |
66 enum NodeType { | 87 enum NodeType { |
67 TYPE_NONE, | 88 TYPE_NONE, |
68 TYPE_ROOT, // This is used for CookieTreeRootNode nodes. | 89 TYPE_ROOT, // This is used for CookieTreeRootNode nodes. |
90 TYPE_APP, // This is used for CookieTreeAppNode nodes. | |
markusheintz_
2012/06/13 23:40:39
nit: Add one more space before the comment in this
nasko
2012/06/14 18:46:42
Done.
| |
69 TYPE_ORIGIN, // This is used for CookieTreeOriginNode nodes. | 91 TYPE_ORIGIN, // This is used for CookieTreeOriginNode nodes. |
70 TYPE_COOKIES, // This is used for CookieTreeCookiesNode nodes. | 92 TYPE_COOKIES, // This is used for CookieTreeCookiesNode nodes. |
71 TYPE_COOKIE, // This is used for CookieTreeCookieNode nodes. | 93 TYPE_COOKIE, // This is used for CookieTreeCookieNode nodes. |
72 TYPE_DATABASES, // This is used for CookieTreeDatabasesNode. | 94 TYPE_DATABASES, // This is used for CookieTreeDatabasesNode. |
73 TYPE_DATABASE, // This is used for CookieTreeDatabaseNode. | 95 TYPE_DATABASE, // This is used for CookieTreeDatabaseNode. |
74 TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. | 96 TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. |
75 TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. | 97 TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. |
76 TYPE_SESSION_STORAGES, // This is used for CookieTreeSessionStoragesNode. | 98 TYPE_SESSION_STORAGES, // This is used for CookieTreeSessionStoragesNode. |
77 TYPE_SESSION_STORAGE, // This is used for CookieTreeSessionStorageNode. | 99 TYPE_SESSION_STORAGE, // This is used for CookieTreeSessionStorageNode. |
78 TYPE_APPCACHES, // This is used for CookieTreeAppCachesNode. | 100 TYPE_APPCACHES, // This is used for CookieTreeAppCachesNode. |
(...skipping 21 matching lines...) Expand all Loading... | |
100 file_system_info(NULL), | 122 file_system_info(NULL), |
101 quota_info(NULL), | 123 quota_info(NULL), |
102 server_bound_cert(NULL) {} | 124 server_bound_cert(NULL) {} |
103 | 125 |
104 DetailedInfo& Init(NodeType type) { | 126 DetailedInfo& Init(NodeType type) { |
105 DCHECK_EQ(TYPE_NONE, node_type); | 127 DCHECK_EQ(TYPE_NONE, node_type); |
106 node_type = type; | 128 node_type = type; |
107 return *this; | 129 return *this; |
108 } | 130 } |
109 | 131 |
132 DetailedInfo& InitApp(const string16& app_name, const string16& app_id) { | |
133 Init(TYPE_APP); | |
134 this->app_name = app_name; | |
135 this->app_id = app_id; | |
136 return *this; | |
137 } | |
138 | |
110 DetailedInfo& InitCookie( | 139 DetailedInfo& InitCookie( |
111 const net::CookieMonster::CanonicalCookie* cookie) { | 140 const net::CookieMonster::CanonicalCookie* cookie) { |
112 Init(TYPE_COOKIE); | 141 Init(TYPE_COOKIE); |
113 this->cookie = cookie; | 142 this->cookie = cookie; |
114 return *this; | 143 return *this; |
115 } | 144 } |
116 | 145 |
117 DetailedInfo& InitDatabase( | 146 DetailedInfo& InitDatabase( |
118 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info) { | 147 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info) { |
119 Init(TYPE_DATABASE); | 148 Init(TYPE_DATABASE); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 return *this; | 193 return *this; |
165 } | 194 } |
166 | 195 |
167 DetailedInfo& InitServerBoundCert( | 196 DetailedInfo& InitServerBoundCert( |
168 const net::ServerBoundCertStore::ServerBoundCert* server_bound_cert) { | 197 const net::ServerBoundCertStore::ServerBoundCert* server_bound_cert) { |
169 Init(TYPE_SERVER_BOUND_CERT); | 198 Init(TYPE_SERVER_BOUND_CERT); |
170 this->server_bound_cert = server_bound_cert; | 199 this->server_bound_cert = server_bound_cert; |
171 return *this; | 200 return *this; |
172 } | 201 } |
173 | 202 |
203 string16 app_name; | |
204 string16 app_id; | |
174 string16 origin; | 205 string16 origin; |
175 NodeType node_type; | 206 NodeType node_type; |
176 const net::CookieMonster::CanonicalCookie* cookie; | 207 const net::CookieMonster::CanonicalCookie* cookie; |
177 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info; | 208 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info; |
178 const BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info; | 209 const BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info; |
179 const BrowsingDataLocalStorageHelper::LocalStorageInfo* | 210 const BrowsingDataLocalStorageHelper::LocalStorageInfo* |
180 session_storage_info; | 211 session_storage_info; |
181 const appcache::AppCacheInfo* appcache_info; | 212 const appcache::AppCacheInfo* appcache_info; |
182 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info; | 213 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info; |
183 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info; | 214 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info; |
(...skipping 16 matching lines...) Expand all Loading... | |
200 // Returns a struct with detailed information used to populate the details | 231 // Returns a struct with detailed information used to populate the details |
201 // part of the view. | 232 // part of the view. |
202 virtual DetailedInfo GetDetailedInfo() const = 0; | 233 virtual DetailedInfo GetDetailedInfo() const = 0; |
203 | 234 |
204 protected: | 235 protected: |
205 class NodeTitleComparator { | 236 class NodeTitleComparator { |
206 public: | 237 public: |
207 bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); | 238 bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); |
208 }; | 239 }; |
209 | 240 |
241 class AppNodeComparator { | |
242 public: | |
243 bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); | |
244 }; | |
245 | |
210 void AddChildSortedByTitle(CookieTreeNode* new_child); | 246 void AddChildSortedByTitle(CookieTreeNode* new_child); |
211 | 247 |
212 private: | 248 private: |
213 | 249 |
214 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode); | 250 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode); |
215 }; | 251 }; |
216 | 252 |
217 // CookieTreeRootNode --------------------------------------------------------- | 253 // CookieTreeRootNode --------------------------------------------------------- |
218 // The node at the root of the CookieTree that gets inserted into the view. | 254 // The node at the root of the CookieTree that gets inserted into the view. |
219 class CookieTreeRootNode : public CookieTreeNode { | 255 class CookieTreeRootNode : public CookieTreeNode { |
220 public: | 256 public: |
221 explicit CookieTreeRootNode(CookiesTreeModel* model); | 257 explicit CookieTreeRootNode(CookiesTreeModel* model); |
222 virtual ~CookieTreeRootNode(); | 258 virtual ~CookieTreeRootNode(); |
223 | 259 |
224 CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); | 260 CookieTreeAppNode* GetOrCreateAppNode(const string16& app_name, |
261 const string16& app_id); | |
225 | 262 |
226 // CookieTreeNode methods: | 263 // CookieTreeNode methods: |
227 virtual CookiesTreeModel* GetModel() const OVERRIDE; | 264 virtual CookiesTreeModel* GetModel() const OVERRIDE; |
228 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 265 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
229 | 266 |
230 private: | 267 private: |
231 CookiesTreeModel* model_; | 268 CookiesTreeModel* model_; |
232 | 269 |
233 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); | 270 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); |
234 }; | 271 }; |
235 | 272 |
273 // CookieTreeAppNode ------------------------------------------------------- | |
markusheintz_
2012/06/13 23:40:39
nit: Add some more '-' to make this line as long a
nasko
2012/06/14 18:46:42
Done.
| |
274 class CookieTreeAppNode : public CookieTreeNode { | |
275 public: | |
276 explicit CookieTreeAppNode(const string16& app_name, const string16& app_id); | |
277 virtual ~CookieTreeAppNode(); | |
278 | |
279 CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); | |
280 | |
281 // CookieTreeNode methods: | |
282 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | |
283 | |
284 const string16 app_id() const { return app_id_; } | |
markusheintz_
2012/06/13 23:40:39
I think you can return a const reference here: con
nasko
2012/06/14 18:46:42
Done.
| |
285 | |
286 private: | |
287 string16 app_name_; | |
288 string16 app_id_; | |
markusheintz_
2012/06/13 23:40:39
nit: Please add an empty line here.
nasko
2012/06/14 18:46:42
Done.
| |
289 DISALLOW_COPY_AND_ASSIGN(CookieTreeAppNode); | |
290 }; | |
291 | |
236 // CookieTreeOriginNode ------------------------------------------------------- | 292 // CookieTreeOriginNode ------------------------------------------------------- |
237 class CookieTreeOriginNode : public CookieTreeNode { | 293 class CookieTreeOriginNode : public CookieTreeNode { |
238 public: | 294 public: |
239 // Returns the origin node's title to use for a given URL. | 295 // Returns the origin node's title to use for a given URL. |
240 static std::wstring TitleForUrl(const GURL& url); | 296 static std::wstring TitleForUrl(const GURL& url); |
241 | 297 |
242 explicit CookieTreeOriginNode(const GURL& url); | 298 explicit CookieTreeOriginNode(const GURL& url); |
243 virtual ~CookieTreeOriginNode(); | 299 virtual ~CookieTreeOriginNode(); |
244 | 300 |
245 // CookieTreeNode methods: | 301 // CookieTreeNode methods: |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 663 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
608 | 664 |
609 void AddServerBoundCertNode(CookieTreeServerBoundCertNode* child) { | 665 void AddServerBoundCertNode(CookieTreeServerBoundCertNode* child) { |
610 AddChildSortedByTitle(child); | 666 AddChildSortedByTitle(child); |
611 } | 667 } |
612 | 668 |
613 private: | 669 private: |
614 DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); | 670 DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); |
615 }; | 671 }; |
616 | 672 |
673 class CookiesTreeModelDelegate { | |
markusheintz_
2012/06/13 23:40:39
Please document this class (interface). Thanks.
nasko
2012/06/14 18:46:42
Done.
| |
674 public: | |
markusheintz_
2012/06/13 23:40:39
All public methods should be documented. Please do
nasko
2012/06/14 18:46:42
As discussed, I'm just moving those around and the
| |
675 virtual void PopulateAppCacheInfoWithFilter(const string16* app, | |
markusheintz_
2012/06/13 23:40:39
Is |app| the app name of the app id? maybe you cou
nasko
2012/06/14 18:46:42
Yes, there is a reason for the pointer. I want to
markusheintz_
2012/06/19 20:01:33
Just to refresh my memory when is it again possibl
nasko
2012/06/19 22:22:40
In the case where we refresh the tree model from W
| |
676 const std::wstring& filter) {} | |
markusheintz_
2012/06/13 23:40:39
Here and below: Please don't use std::wstring. Rep
nasko
2012/06/14 18:46:42
I'll move those over to string16.
| |
677 virtual void PopulateCookieInfoWithFilter(const string16* app, | |
678 const std::wstring& filter) {} | |
679 virtual void PopulateDatabaseInfoWithFilter(const string16* app, | |
680 const std::wstring& filter) {} | |
markusheintz_
2012/06/13 23:40:39
Please don't use std::wstring. wstring is replaced
nasko
2012/06/14 18:46:42
See the above.
| |
681 virtual void PopulateLocalStorageInfoWithFilter(const string16* app, | |
682 const std::wstring& filter) {} | |
683 virtual void PopulateSessionStorageInfoWithFilter( | |
684 const string16* app, const std::wstring& filter) {} | |
685 virtual void PopulateIndexedDBInfoWithFilter(const string16* app, | |
686 const std::wstring& filter) {} | |
687 virtual void PopulateFileSystemInfoWithFilter(const string16* app, | |
688 const std::wstring& filter) {} | |
689 virtual void PopulateQuotaInfoWithFilter(const string16* app, | |
690 const std::wstring& filter) {} | |
691 virtual void PopulateServerBoundCertInfoWithFilter( | |
692 const string16* app, const std::wstring& filter) {} | |
693 }; | |
694 | |
617 // CookiesTreeModel ----------------------------------------------------------- | 695 // CookiesTreeModel ----------------------------------------------------------- |
618 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { | 696 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode>, |
697 public CookiesTreeModelDelegate { | |
619 public: | 698 public: |
699 CookiesTreeModel(ContainerMap& apps_map, bool use_cookie_source); | |
700 virtual ~CookiesTreeModel(); | |
701 | |
620 // Because non-cookie nodes are fetched in a background thread, they are not | 702 // Because non-cookie nodes are fetched in a background thread, they are not |
621 // present at the time the Model is created. The Model then notifies its | 703 // present at the time the Model is created. The Model then notifies its |
622 // observers for every item added from databases, local storage, and | 704 // observers for every item added from databases, local storage, and |
623 // appcache. We extend the Observer interface to add notifications before and | 705 // appcache. We extend the Observer interface to add notifications before and |
624 // after these batch inserts. | 706 // after these batch inserts. |
625 class Observer : public ui::TreeModelObserver { | 707 class Observer : public ui::TreeModelObserver { |
626 public: | 708 public: |
627 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} | 709 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} |
628 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} | 710 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} |
629 }; | 711 }; |
630 | 712 |
631 CookiesTreeModel( | |
632 BrowsingDataCookieHelper* cookie_helper, | |
633 BrowsingDataDatabaseHelper* database_helper, | |
634 BrowsingDataLocalStorageHelper* local_storage_helper, | |
635 BrowsingDataLocalStorageHelper* session_storage_helper, | |
636 BrowsingDataAppCacheHelper* appcache_helper, | |
637 BrowsingDataIndexedDBHelper* indexed_db_helper, | |
638 BrowsingDataFileSystemHelper* file_system_helper, | |
639 BrowsingDataQuotaHelper* quota_helper, | |
640 BrowsingDataServerBoundCertHelper* server_bound_cert_helper, | |
641 bool use_cookie_source); | |
642 virtual ~CookiesTreeModel(); | |
643 | |
644 // ui::TreeModel methods: | 713 // ui::TreeModel methods: |
645 // Returns the set of icons for the nodes in the tree. You only need override | 714 // Returns the set of icons for the nodes in the tree. You only need override |
646 // this if you don't want to use the default folder icons. | 715 // this if you don't want to use the default folder icons. |
647 virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) OVERRIDE; | 716 virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) OVERRIDE; |
648 | 717 |
649 // Returns the index of the icon to use for |node|. Return -1 to use the | 718 // Returns the index of the icon to use for |node|. Return -1 to use the |
650 // default icon. The index is relative to the list of icons returned from | 719 // default icon. The index is relative to the list of icons returned from |
651 // GetIcons. | 720 // GetIcons. |
652 virtual int GetIconIndex(ui::TreeModelNode* node) OVERRIDE; | 721 virtual int GetIconIndex(ui::TreeModelNode* node) OVERRIDE; |
653 | 722 |
654 // CookiesTreeModel methods: | 723 // CookiesTreeModel methods: |
655 void DeleteAllStoredObjects(); | 724 void DeleteAllStoredObjects(); |
725 void DeleteStoredObjectsForApp(const string16& app); | |
markusheintz_
2012/06/13 23:40:39
Please document the method and replace app with ap
nasko
2012/06/14 18:46:42
Done.
| |
656 void DeleteCookieNode(CookieTreeNode* cookie_node); | 726 void DeleteCookieNode(CookieTreeNode* cookie_node); |
657 | 727 |
658 // Filter the origins to only display matched results. | 728 // Filter the origins to only display matched results. |
659 void UpdateSearchResults(const std::wstring& filter); | 729 void UpdateSearchResults(const std::wstring& filter); |
660 | 730 |
661 // Manages CookiesTreeModel::Observers. This will also call | 731 // Manages CookiesTreeModel::Observers. This will also call |
662 // TreeNodeModel::AddObserver so that it gets all the proper notifications. | 732 // TreeNodeModel::AddObserver so that it gets all the proper notifications. |
663 // Note that the converse is not true: simply adding a TreeModelObserver will | 733 // Note that the converse is not true: simply adding a TreeModelObserver will |
664 // not get CookiesTreeModel::Observer notifications. | 734 // not get CookiesTreeModel::Observer notifications. |
665 virtual void AddCookiesTreeObserver(Observer* observer); | 735 virtual void AddCookiesTreeObserver(Observer* observer); |
666 virtual void RemoveCookiesTreeObserver(Observer* observer); | 736 virtual void RemoveCookiesTreeObserver(Observer* observer); |
667 | 737 |
markusheintz_
2012/06/13 23:40:39
nit: Add "// CookiesTreeModelDelegate methods:"
nasko
2012/06/14 18:46:42
Done.
| |
738 virtual void PopulateAppCacheInfoWithFilter( | |
markusheintz_
2012/06/13 23:40:39
In all method signatures:
s/app/app_id
nasko
2012/06/14 18:46:42
Done.
| |
739 const string16* app, const std::wstring& filter) OVERRIDE; | |
740 virtual void PopulateCookieInfoWithFilter( | |
741 const string16* app, const std::wstring& filter) OVERRIDE; | |
742 virtual void PopulateDatabaseInfoWithFilter( | |
743 const string16* app, const std::wstring& filter) OVERRIDE; | |
744 virtual void PopulateLocalStorageInfoWithFilter( | |
745 const string16* app, const std::wstring& filter) OVERRIDE; | |
746 virtual void PopulateSessionStorageInfoWithFilter( | |
747 const string16* app, const std::wstring& filter) OVERRIDE; | |
748 virtual void PopulateIndexedDBInfoWithFilter( | |
749 const string16* app, const std::wstring& filter) OVERRIDE; | |
750 virtual void PopulateFileSystemInfoWithFilter( | |
751 const string16* app, const std::wstring& filter) OVERRIDE; | |
752 virtual void PopulateQuotaInfoWithFilter( | |
753 const string16* app, const std::wstring& filter) OVERRIDE; | |
754 virtual void PopulateServerBoundCertInfoWithFilter( | |
755 const string16* app, const std::wstring& filter) OVERRIDE; | |
756 | |
757 BrowsingDataCookieHelper* GetCookieHelper(const string16& app_id); | |
758 LocalDataContainer* GetLocalDataContainer(const string16& app_id); | |
759 | |
668 private: | 760 private: |
669 enum CookieIconIndex { | 761 enum CookieIconIndex { |
670 ORIGIN = 0, | 762 ORIGIN = 0, |
671 COOKIE = 1, | 763 COOKIE = 1, |
672 DATABASE = 2 | 764 DATABASE = 2 |
673 }; | 765 }; |
674 typedef std::list<net::CookieMonster::CanonicalCookie> CookieList; | |
675 typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo> | |
676 DatabaseInfoList; | |
677 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> | |
678 LocalStorageInfoList; | |
679 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> | |
680 SessionStorageInfoList; | |
681 typedef std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> | |
682 IndexedDBInfoList; | |
683 typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo> | |
684 FileSystemInfoList; | |
685 typedef std::list<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoArray; | |
686 typedef net::ServerBoundCertStore::ServerBoundCertList ServerBoundCertList; | |
687 | 766 |
767 void NotifyObserverBeginBatch(); | |
768 void NotifyObserverEndBatch(); | |
769 | |
770 // Map of app ids to LocalDataContainer objects to use when retrieving | |
771 // locally stored data. | |
772 ContainerMap app_data_map_; | |
773 | |
774 // The CookiesTreeModel maintains a separate list of observers that are | |
775 // specifically of the type CookiesTreeModel::Observer. | |
776 ObserverList<Observer> cookies_observer_list_; | |
777 | |
778 // If true, use the CanonicalCookie::Source attribute to group cookies. | |
779 // Otherwise, use the CanonicalCookie::Domain attribute. | |
780 bool use_cookie_source_; | |
781 | |
782 // If this is non-zero, then this model is batching updates (there's a lot of | |
783 // notifications coming down the pipe). This is an integer is used to balance | |
784 // calls to Begin/EndBatch() if they're called in a nested manner. | |
785 int batch_update_; | |
786 }; | |
787 | |
788 // LocalDataContainer --------------------------------------------------------- | |
789 class LocalDataContainer { | |
markusheintz_
2012/06/13 23:40:39
Please document the class by adding a comment.
nasko
2012/06/14 18:46:42
Done.
| |
790 public: | |
791 LocalDataContainer( | |
792 const string16& app_name, | |
793 const string16& app_id, | |
794 BrowsingDataCookieHelper* cookie_helper, | |
795 BrowsingDataDatabaseHelper* database_helper, | |
796 BrowsingDataLocalStorageHelper* local_storage_helper, | |
797 BrowsingDataLocalStorageHelper* session_storage_helper, | |
798 BrowsingDataAppCacheHelper* appcache_helper, | |
799 BrowsingDataIndexedDBHelper* indexed_db_helper, | |
800 BrowsingDataFileSystemHelper* file_system_helper, | |
801 BrowsingDataQuotaHelper* quota_helper, | |
802 BrowsingDataServerBoundCertHelper* server_bound_cert_helper); | |
803 virtual ~LocalDataContainer(); | |
804 | |
805 void Init(CookiesTreeModelDelegate* d); | |
806 | |
807 string16 app_name() { return app_name_; } | |
808 string16 app_id() { return app_id_; } | |
809 | |
810 private: | |
688 void OnAppCacheModelInfoLoaded(); | 811 void OnAppCacheModelInfoLoaded(); |
689 void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list); | 812 void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list); |
690 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); | 813 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); |
691 void OnLocalStorageModelInfoLoaded( | 814 void OnLocalStorageModelInfoLoaded( |
692 const LocalStorageInfoList& local_storage_info); | 815 const LocalStorageInfoList& local_storage_info); |
693 void OnSessionStorageModelInfoLoaded( | 816 void OnSessionStorageModelInfoLoaded( |
694 const LocalStorageInfoList& local_storage_info); | 817 const LocalStorageInfoList& local_storage_info); |
695 void OnIndexedDBModelInfoLoaded( | 818 void OnIndexedDBModelInfoLoaded( |
696 const IndexedDBInfoList& indexed_db_info); | 819 const IndexedDBInfoList& indexed_db_info); |
697 void OnFileSystemModelInfoLoaded( | 820 void OnFileSystemModelInfoLoaded( |
698 const FileSystemInfoList& file_system_info); | 821 const FileSystemInfoList& file_system_info); |
699 void OnQuotaModelInfoLoaded(const QuotaInfoArray& quota_info); | 822 void OnQuotaModelInfoLoaded(const QuotaInfoArray& quota_info); |
700 void OnServerBoundCertModelInfoLoaded(const ServerBoundCertList& cert_list); | 823 void OnServerBoundCertModelInfoLoaded(const ServerBoundCertList& cert_list); |
701 | 824 |
702 void PopulateAppCacheInfoWithFilter(const std::wstring& filter); | 825 string16 app_name_; |
703 void PopulateCookieInfoWithFilter(const std::wstring& filter); | 826 string16 app_id_; |
704 void PopulateDatabaseInfoWithFilter(const std::wstring& filter); | |
705 void PopulateLocalStorageInfoWithFilter(const std::wstring& filter); | |
706 void PopulateSessionStorageInfoWithFilter(const std::wstring& filter); | |
707 void PopulateIndexedDBInfoWithFilter(const std::wstring& filter); | |
708 void PopulateFileSystemInfoWithFilter(const std::wstring& filter); | |
709 void PopulateQuotaInfoWithFilter(const std::wstring& filter); | |
710 void PopulateServerBoundCertInfoWithFilter(const std::wstring& filter); | |
711 | |
712 void NotifyObserverBeginBatch(); | |
713 void NotifyObserverEndBatch(); | |
714 | 827 |
715 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; | 828 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; |
716 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; | 829 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; |
717 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; | 830 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; |
718 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; | 831 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; |
719 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; | 832 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; |
720 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; | 833 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; |
721 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; | 834 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; |
722 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; | 835 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; |
723 scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_; | 836 scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_; |
724 | 837 |
725 std::map<GURL, std::list<appcache::AppCacheInfo> > appcache_info_; | 838 AppCacheInfoMap appcache_info_; |
726 CookieList cookie_list_; | 839 CookieList cookie_list_; |
727 DatabaseInfoList database_info_list_; | 840 DatabaseInfoList database_info_list_; |
728 LocalStorageInfoList local_storage_info_list_; | 841 LocalStorageInfoList local_storage_info_list_; |
729 LocalStorageInfoList session_storage_info_list_; | 842 LocalStorageInfoList session_storage_info_list_; |
730 IndexedDBInfoList indexed_db_info_list_; | 843 IndexedDBInfoList indexed_db_info_list_; |
731 FileSystemInfoList file_system_info_list_; | 844 FileSystemInfoList file_system_info_list_; |
732 QuotaInfoArray quota_info_list_; | 845 QuotaInfoArray quota_info_list_; |
733 ServerBoundCertList server_bound_cert_list_; | 846 ServerBoundCertList server_bound_cert_list_; |
734 | 847 |
735 // The CookiesTreeModel maintains a separate list of observers that are | 848 // A delegate, which must outlive this object. The update callbacks use the |
736 // specifically of the type CookiesTreeModel::Observer. | 849 // delegate to deliver the updated data to the CookieTreeModel. |
737 ObserverList<Observer> cookies_observer_list_; | 850 CookiesTreeModelDelegate* delegate_; |
738 | 851 |
739 // If this is non-zero, then this model is batching updates (there's a lot of | 852 base::WeakPtrFactory<LocalDataContainer> weak_ptr_factory_; |
740 // notifications coming down the pipe). This is an integer is used to balance | |
741 // calls to Begin/EndBatch() if they're called in a nested manner. | |
742 int batch_update_; | |
743 | 853 |
744 // If true, use the CanonicalCookie::Source attribute to group cookies. | 854 friend class CookiesTreeModel; |
745 // Otherwise, use the CanonicalCookie::Domain attribute. | |
746 bool use_cookie_source_; | |
747 | |
748 base::WeakPtrFactory<CookiesTreeModel> weak_ptr_factory_; | |
749 | |
750 friend class CookieTreeAppCacheNode; | 855 friend class CookieTreeAppCacheNode; |
751 friend class CookieTreeCookieNode; | 856 friend class CookieTreeCookieNode; |
752 friend class CookieTreeDatabaseNode; | 857 friend class CookieTreeDatabaseNode; |
753 friend class CookieTreeLocalStorageNode; | 858 friend class CookieTreeLocalStorageNode; |
754 friend class CookieTreeSessionStorageNode; | 859 friend class CookieTreeSessionStorageNode; |
755 friend class CookieTreeIndexedDBNode; | 860 friend class CookieTreeIndexedDBNode; |
756 friend class CookieTreeFileSystemNode; | 861 friend class CookieTreeFileSystemNode; |
757 friend class CookieTreeQuotaNode; | 862 friend class CookieTreeQuotaNode; |
758 friend class CookieTreeServerBoundCertNode; | 863 friend class CookieTreeServerBoundCertNode; |
759 | 864 |
760 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); | 865 DISALLOW_COPY_AND_ASSIGN(LocalDataContainer); |
761 }; | 866 }; |
762 | 867 |
763 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ | 868 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
OLD | NEW |