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 17 matching lines...) Expand all Loading... |
28 #include "net/base/server_bound_cert_store.h" | 28 #include "net/base/server_bound_cert_store.h" |
29 #include "net/cookies/cookie_monster.h" | 29 #include "net/cookies/cookie_monster.h" |
30 #include "ui/base/models/tree_node_model.h" | 30 #include "ui/base/models/tree_node_model.h" |
31 | 31 |
32 class BrowsingDataCookieHelper; | 32 class BrowsingDataCookieHelper; |
33 class BrowsingDataServerBoundCertHelper; | 33 class BrowsingDataServerBoundCertHelper; |
34 class CookieSettings; | 34 class CookieSettings; |
35 class CookiesTreeModel; | 35 class CookiesTreeModel; |
36 class CookieTreeAppCacheNode; | 36 class CookieTreeAppCacheNode; |
37 class CookieTreeAppCachesNode; | 37 class CookieTreeAppCachesNode; |
| 38 class CookieTreeAppNode; |
38 class CookieTreeCookieNode; | 39 class CookieTreeCookieNode; |
39 class CookieTreeCookiesNode; | 40 class CookieTreeCookiesNode; |
40 class CookieTreeDatabaseNode; | 41 class CookieTreeDatabaseNode; |
41 class CookieTreeDatabasesNode; | 42 class CookieTreeDatabasesNode; |
| 43 class CookieTreeFileSystemNode; |
42 class CookieTreeFileSystemsNode; | 44 class CookieTreeFileSystemsNode; |
43 class CookieTreeFileSystemNode; | 45 class CookieTreeIndexedDBNode; |
| 46 class CookieTreeIndexedDBsNode; |
44 class CookieTreeLocalStorageNode; | 47 class CookieTreeLocalStorageNode; |
45 class CookieTreeLocalStoragesNode; | 48 class CookieTreeLocalStoragesNode; |
| 49 class CookieTreeOriginNode; |
| 50 class CookieTreeQuotaNode; |
46 class CookieTreeServerBoundCertNode; | 51 class CookieTreeServerBoundCertNode; |
47 class CookieTreeServerBoundCertsNode; | 52 class CookieTreeServerBoundCertsNode; |
48 class CookieTreeQuotaNode; | |
49 class CookieTreeSessionStorageNode; | 53 class CookieTreeSessionStorageNode; |
50 class CookieTreeSessionStoragesNode; | 54 class CookieTreeSessionStoragesNode; |
51 class CookieTreeIndexedDBNode; | 55 class LocalDataContainer; |
52 class CookieTreeIndexedDBsNode; | 56 |
53 class CookieTreeOriginNode; | 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; |
| 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> QuotaInfoList; |
| 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. |
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 ---------------------------------------------------------- |
| 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_; } |
| 285 |
| 286 private: |
| 287 string16 app_name_; |
| 288 string16 app_id_; |
| 289 |
| 290 DISALLOW_COPY_AND_ASSIGN(CookieTreeAppNode); |
| 291 }; |
| 292 |
236 // CookieTreeOriginNode ------------------------------------------------------- | 293 // CookieTreeOriginNode ------------------------------------------------------- |
237 class CookieTreeOriginNode : public CookieTreeNode { | 294 class CookieTreeOriginNode : public CookieTreeNode { |
238 public: | 295 public: |
239 // Returns the origin node's title to use for a given URL. | 296 // Returns the origin node's title to use for a given URL. |
240 static std::wstring TitleForUrl(const GURL& url); | 297 static string16 TitleForUrl(const GURL& url); |
241 | 298 |
242 explicit CookieTreeOriginNode(const GURL& url); | 299 explicit CookieTreeOriginNode(const GURL& url); |
243 virtual ~CookieTreeOriginNode(); | 300 virtual ~CookieTreeOriginNode(); |
244 | 301 |
245 // CookieTreeNode methods: | 302 // CookieTreeNode methods: |
246 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 303 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
247 | 304 |
248 // CookieTreeOriginNode methods: | 305 // CookieTreeOriginNode methods: |
249 CookieTreeCookiesNode* GetOrCreateCookiesNode(); | 306 CookieTreeCookiesNode* GetOrCreateCookiesNode(); |
250 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); | 307 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 | 663 |
607 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 664 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
608 | 665 |
609 void AddServerBoundCertNode(CookieTreeServerBoundCertNode* child) { | 666 void AddServerBoundCertNode(CookieTreeServerBoundCertNode* child) { |
610 AddChildSortedByTitle(child); | 667 AddChildSortedByTitle(child); |
611 } | 668 } |
612 | 669 |
613 private: | 670 private: |
614 DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); | 671 DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); |
615 }; | 672 }; |
| 673 // CookiesTreeModelDelegate --------------------------------------------------- |
| 674 // This is a delegate definition class. It is used by the CookiesTreeModel |
| 675 // to pass a pointer to itself to each of the LocalDataContainer objects, so |
| 676 // when resource fetching is complete, the objects can call back to the model |
| 677 // and update it. The CookiesTreeModel instance must outlive the |
| 678 // LocalDataContainer instances. |
| 679 class CookiesTreeModelDelegate { |
| 680 public: |
| 681 virtual void PopulateAppCacheInfoWithFilter(const string16* app, |
| 682 const string16& filter) {} |
| 683 virtual void PopulateCookieInfoWithFilter(const string16* app, |
| 684 const string16& filter) {} |
| 685 virtual void PopulateDatabaseInfoWithFilter(const string16* app, |
| 686 const string16& filter) {} |
| 687 virtual void PopulateLocalStorageInfoWithFilter(const string16* app, |
| 688 const string16& filter) {} |
| 689 virtual void PopulateSessionStorageInfoWithFilter( |
| 690 const string16* app, const string16& filter) {} |
| 691 virtual void PopulateIndexedDBInfoWithFilter(const string16* app, |
| 692 const string16& filter) {} |
| 693 virtual void PopulateFileSystemInfoWithFilter(const string16* app, |
| 694 const string16& filter) {} |
| 695 virtual void PopulateQuotaInfoWithFilter(const string16* app, |
| 696 const string16& filter) {} |
| 697 virtual void PopulateServerBoundCertInfoWithFilter( |
| 698 const string16* app, const string16& filter) {} |
| 699 }; |
616 | 700 |
617 // CookiesTreeModel ----------------------------------------------------------- | 701 // CookiesTreeModel ----------------------------------------------------------- |
618 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { | 702 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode>, |
| 703 public CookiesTreeModelDelegate { |
619 public: | 704 public: |
| 705 CookiesTreeModel(ContainerMap& apps_map, bool use_cookie_source); |
| 706 virtual ~CookiesTreeModel(); |
| 707 |
620 // Because non-cookie nodes are fetched in a background thread, they are not | 708 // 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 | 709 // present at the time the Model is created. The Model then notifies its |
622 // observers for every item added from databases, local storage, and | 710 // observers for every item added from databases, local storage, and |
623 // appcache. We extend the Observer interface to add notifications before and | 711 // appcache. We extend the Observer interface to add notifications before and |
624 // after these batch inserts. | 712 // after these batch inserts. |
625 class Observer : public ui::TreeModelObserver { | 713 class Observer : public ui::TreeModelObserver { |
626 public: | 714 public: |
627 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} | 715 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} |
628 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} | 716 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} |
629 }; | 717 }; |
630 | 718 |
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: | 719 // ui::TreeModel methods: |
645 // Returns the set of icons for the nodes in the tree. You only need override | 720 // 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. | 721 // this if you don't want to use the default folder icons. |
647 virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) OVERRIDE; | 722 virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) OVERRIDE; |
648 | 723 |
649 // Returns the index of the icon to use for |node|. Return -1 to use the | 724 // 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 | 725 // default icon. The index is relative to the list of icons returned from |
651 // GetIcons. | 726 // GetIcons. |
652 virtual int GetIconIndex(ui::TreeModelNode* node) OVERRIDE; | 727 virtual int GetIconIndex(ui::TreeModelNode* node) OVERRIDE; |
653 | 728 |
654 // CookiesTreeModel methods: | 729 // CookiesTreeModel methods: |
655 void DeleteAllStoredObjects(); | 730 void DeleteAllStoredObjects(); |
| 731 |
| 732 // Deletes all the stored objects for a specific app, identified by |app_id|. |
| 733 void DeleteStoredObjectsForApp(const string16& app_id); |
656 void DeleteCookieNode(CookieTreeNode* cookie_node); | 734 void DeleteCookieNode(CookieTreeNode* cookie_node); |
657 | 735 |
658 // Filter the origins to only display matched results. | 736 // Filter the origins to only display matched results. |
659 void UpdateSearchResults(const std::wstring& filter); | 737 void UpdateSearchResults(const string16& filter); |
660 | 738 |
661 // Manages CookiesTreeModel::Observers. This will also call | 739 // Manages CookiesTreeModel::Observers. This will also call |
662 // TreeNodeModel::AddObserver so that it gets all the proper notifications. | 740 // TreeNodeModel::AddObserver so that it gets all the proper notifications. |
663 // Note that the converse is not true: simply adding a TreeModelObserver will | 741 // Note that the converse is not true: simply adding a TreeModelObserver will |
664 // not get CookiesTreeModel::Observer notifications. | 742 // not get CookiesTreeModel::Observer notifications. |
665 virtual void AddCookiesTreeObserver(Observer* observer); | 743 virtual void AddCookiesTreeObserver(Observer* observer); |
666 virtual void RemoveCookiesTreeObserver(Observer* observer); | 744 virtual void RemoveCookiesTreeObserver(Observer* observer); |
667 | 745 |
| 746 // CookiesTreeModelDelegate methods: |
| 747 virtual void PopulateAppCacheInfoWithFilter( |
| 748 const string16* app_id, const string16& filter) OVERRIDE; |
| 749 virtual void PopulateCookieInfoWithFilter( |
| 750 const string16* app_id, const string16& filter) OVERRIDE; |
| 751 virtual void PopulateDatabaseInfoWithFilter( |
| 752 const string16* app_id, const string16& filter) OVERRIDE; |
| 753 virtual void PopulateLocalStorageInfoWithFilter( |
| 754 const string16* app_id, const string16& filter) OVERRIDE; |
| 755 virtual void PopulateSessionStorageInfoWithFilter( |
| 756 const string16* app_id, const string16& filter) OVERRIDE; |
| 757 virtual void PopulateIndexedDBInfoWithFilter( |
| 758 const string16* app_id, const string16& filter) OVERRIDE; |
| 759 virtual void PopulateFileSystemInfoWithFilter( |
| 760 const string16* app_id, const string16& filter) OVERRIDE; |
| 761 virtual void PopulateQuotaInfoWithFilter( |
| 762 const string16* app_id, const string16& filter) OVERRIDE; |
| 763 virtual void PopulateServerBoundCertInfoWithFilter( |
| 764 const string16* app_id, const string16& filter) OVERRIDE; |
| 765 |
| 766 BrowsingDataCookieHelper* GetCookieHelper(const string16& app_id); |
| 767 LocalDataContainer* GetLocalDataContainer(const string16& app_id); |
| 768 |
668 private: | 769 private: |
669 enum CookieIconIndex { | 770 enum CookieIconIndex { |
670 ORIGIN = 0, | 771 ORIGIN = 0, |
671 COOKIE = 1, | 772 COOKIE = 1, |
672 DATABASE = 2 | 773 DATABASE = 2 |
673 }; | 774 }; |
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 | 775 |
| 776 void NotifyObserverBeginBatch(); |
| 777 void NotifyObserverEndBatch(); |
| 778 |
| 779 // Map of app ids to LocalDataContainer objects to use when retrieving |
| 780 // locally stored data. |
| 781 ContainerMap app_data_map_; |
| 782 |
| 783 // The CookiesTreeModel maintains a separate list of observers that are |
| 784 // specifically of the type CookiesTreeModel::Observer. |
| 785 ObserverList<Observer> cookies_observer_list_; |
| 786 |
| 787 // If true, use the CanonicalCookie::Source attribute to group cookies. |
| 788 // Otherwise, use the CanonicalCookie::Domain attribute. |
| 789 bool use_cookie_source_; |
| 790 |
| 791 // If this is non-zero, then this model is batching updates (there's a lot of |
| 792 // notifications coming down the pipe). This is an integer is used to balance |
| 793 // calls to Begin/EndBatch() if they're called in a nested manner. |
| 794 int batch_update_; |
| 795 }; |
| 796 |
| 797 // LocalDataContainer --------------------------------------------------------- |
| 798 // This class is a wrapper around all the BrowsingData*Helper classes. Because |
| 799 // isolated applications have separate storage, we need different helper |
| 800 // instances. As such, this class contains the app name and id, along with the |
| 801 // helpers for all of the data types we need. The browser-wide "app id" will be |
| 802 // the empty string, as no app can have empty id. |
| 803 class LocalDataContainer { |
| 804 public: |
| 805 LocalDataContainer( |
| 806 const string16& app_name, |
| 807 const string16& app_id, |
| 808 BrowsingDataCookieHelper* cookie_helper, |
| 809 BrowsingDataDatabaseHelper* database_helper, |
| 810 BrowsingDataLocalStorageHelper* local_storage_helper, |
| 811 BrowsingDataLocalStorageHelper* session_storage_helper, |
| 812 BrowsingDataAppCacheHelper* appcache_helper, |
| 813 BrowsingDataIndexedDBHelper* indexed_db_helper, |
| 814 BrowsingDataFileSystemHelper* file_system_helper, |
| 815 BrowsingDataQuotaHelper* quota_helper, |
| 816 BrowsingDataServerBoundCertHelper* server_bound_cert_helper); |
| 817 virtual ~LocalDataContainer(); |
| 818 |
| 819 // This method must be called to start the process of fetching the resources. |
| 820 // The delegate passed in is called back to deliver the updates. |
| 821 void Init(CookiesTreeModelDelegate* d); |
| 822 |
| 823 const string16& app_name() { return app_name_; } |
| 824 const string16& app_id() { return app_id_; } |
| 825 |
| 826 private: |
688 void OnAppCacheModelInfoLoaded(); | 827 void OnAppCacheModelInfoLoaded(); |
689 void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list); | 828 void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list); |
690 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); | 829 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); |
691 void OnLocalStorageModelInfoLoaded( | 830 void OnLocalStorageModelInfoLoaded( |
692 const LocalStorageInfoList& local_storage_info); | 831 const LocalStorageInfoList& local_storage_info); |
693 void OnSessionStorageModelInfoLoaded( | 832 void OnSessionStorageModelInfoLoaded( |
694 const LocalStorageInfoList& local_storage_info); | 833 const LocalStorageInfoList& local_storage_info); |
695 void OnIndexedDBModelInfoLoaded( | 834 void OnIndexedDBModelInfoLoaded( |
696 const IndexedDBInfoList& indexed_db_info); | 835 const IndexedDBInfoList& indexed_db_info); |
697 void OnFileSystemModelInfoLoaded( | 836 void OnFileSystemModelInfoLoaded( |
698 const FileSystemInfoList& file_system_info); | 837 const FileSystemInfoList& file_system_info); |
699 void OnQuotaModelInfoLoaded(const QuotaInfoArray& quota_info); | 838 void OnQuotaModelInfoLoaded(const QuotaInfoList& quota_info); |
700 void OnServerBoundCertModelInfoLoaded(const ServerBoundCertList& cert_list); | 839 void OnServerBoundCertModelInfoLoaded(const ServerBoundCertList& cert_list); |
701 | 840 |
702 void PopulateAppCacheInfoWithFilter(const std::wstring& filter); | 841 string16 app_name_; |
703 void PopulateCookieInfoWithFilter(const std::wstring& filter); | 842 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 | 843 |
715 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; | 844 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; |
716 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; | 845 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; |
717 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; | 846 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; |
718 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; | 847 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; |
719 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; | 848 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; |
720 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; | 849 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; |
721 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; | 850 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; |
722 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; | 851 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; |
723 scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_; | 852 scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_; |
724 | 853 |
725 std::map<GURL, std::list<appcache::AppCacheInfo> > appcache_info_; | 854 AppCacheInfoMap appcache_info_; |
726 CookieList cookie_list_; | 855 CookieList cookie_list_; |
727 DatabaseInfoList database_info_list_; | 856 DatabaseInfoList database_info_list_; |
728 LocalStorageInfoList local_storage_info_list_; | 857 LocalStorageInfoList local_storage_info_list_; |
729 LocalStorageInfoList session_storage_info_list_; | 858 LocalStorageInfoList session_storage_info_list_; |
730 IndexedDBInfoList indexed_db_info_list_; | 859 IndexedDBInfoList indexed_db_info_list_; |
731 FileSystemInfoList file_system_info_list_; | 860 FileSystemInfoList file_system_info_list_; |
732 QuotaInfoArray quota_info_list_; | 861 QuotaInfoList quota_info_list_; |
733 ServerBoundCertList server_bound_cert_list_; | 862 ServerBoundCertList server_bound_cert_list_; |
734 | 863 |
735 // The CookiesTreeModel maintains a separate list of observers that are | 864 // A delegate, which must outlive this object. The update callbacks use the |
736 // specifically of the type CookiesTreeModel::Observer. | 865 // delegate to deliver the updated data to the CookieTreeModel. |
737 ObserverList<Observer> cookies_observer_list_; | 866 CookiesTreeModelDelegate* delegate_; |
738 | 867 |
739 // If this is non-zero, then this model is batching updates (there's a lot of | 868 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 | 869 |
744 // If true, use the CanonicalCookie::Source attribute to group cookies. | 870 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; | 871 friend class CookieTreeAppCacheNode; |
751 friend class CookieTreeCookieNode; | 872 friend class CookieTreeCookieNode; |
752 friend class CookieTreeDatabaseNode; | 873 friend class CookieTreeDatabaseNode; |
753 friend class CookieTreeLocalStorageNode; | 874 friend class CookieTreeLocalStorageNode; |
754 friend class CookieTreeSessionStorageNode; | 875 friend class CookieTreeSessionStorageNode; |
755 friend class CookieTreeIndexedDBNode; | 876 friend class CookieTreeIndexedDBNode; |
756 friend class CookieTreeFileSystemNode; | 877 friend class CookieTreeFileSystemNode; |
757 friend class CookieTreeQuotaNode; | 878 friend class CookieTreeQuotaNode; |
758 friend class CookieTreeServerBoundCertNode; | 879 friend class CookieTreeServerBoundCertNode; |
759 | 880 |
760 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); | 881 DISALLOW_COPY_AND_ASSIGN(LocalDataContainer); |
761 }; | 882 }; |
762 | 883 |
763 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ | 884 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
OLD | NEW |