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; |
| 55 class LocalDataContainer; |
54 | 56 |
55 // CookieTreeNode ------------------------------------------------------------- | 57 // CookieTreeNode ------------------------------------------------------------- |
56 // The base node type in the Cookies, Databases, and Local Storage options | 58 // 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 | 59 // 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 | 60 // that it has a notion of deleting objects stored in the profile, and being |
59 // able to have its children do the same. | 61 // able to have its children do the same. |
60 class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { | 62 class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { |
61 public: | 63 public: |
62 // Used to pull out information for the InfoView (the details display below | 64 // Used to pull out information for the InfoView (the details display below |
63 // the tree control.) | 65 // the tree control.) |
64 struct DetailedInfo { | 66 struct DetailedInfo { |
65 // NodeType corresponds to the various CookieTreeNode types. | 67 // NodeType corresponds to the various CookieTreeNode types. |
66 enum NodeType { | 68 enum NodeType { |
67 TYPE_NONE, | 69 TYPE_NONE, |
68 TYPE_ROOT, // This is used for CookieTreeRootNode nodes. | 70 TYPE_ROOT, // This is used for CookieTreeRootNode nodes. |
| 71 TYPE_APP, // This is used for CookieTreeAppNode nodes. |
69 TYPE_ORIGIN, // This is used for CookieTreeOriginNode nodes. | 72 TYPE_ORIGIN, // This is used for CookieTreeOriginNode nodes. |
70 TYPE_COOKIES, // This is used for CookieTreeCookiesNode nodes. | 73 TYPE_COOKIES, // This is used for CookieTreeCookiesNode nodes. |
71 TYPE_COOKIE, // This is used for CookieTreeCookieNode nodes. | 74 TYPE_COOKIE, // This is used for CookieTreeCookieNode nodes. |
72 TYPE_DATABASES, // This is used for CookieTreeDatabasesNode. | 75 TYPE_DATABASES, // This is used for CookieTreeDatabasesNode. |
73 TYPE_DATABASE, // This is used for CookieTreeDatabaseNode. | 76 TYPE_DATABASE, // This is used for CookieTreeDatabaseNode. |
74 TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. | 77 TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. |
75 TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. | 78 TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. |
76 TYPE_SESSION_STORAGES, // This is used for CookieTreeSessionStoragesNode. | 79 TYPE_SESSION_STORAGES, // This is used for CookieTreeSessionStoragesNode. |
77 TYPE_SESSION_STORAGE, // This is used for CookieTreeSessionStorageNode. | 80 TYPE_SESSION_STORAGE, // This is used for CookieTreeSessionStorageNode. |
78 TYPE_APPCACHES, // This is used for CookieTreeAppCachesNode. | 81 TYPE_APPCACHES, // This is used for CookieTreeAppCachesNode. |
(...skipping 21 matching lines...) Expand all Loading... |
100 file_system_info(NULL), | 103 file_system_info(NULL), |
101 quota_info(NULL), | 104 quota_info(NULL), |
102 server_bound_cert(NULL) {} | 105 server_bound_cert(NULL) {} |
103 | 106 |
104 DetailedInfo& Init(NodeType type) { | 107 DetailedInfo& Init(NodeType type) { |
105 DCHECK_EQ(TYPE_NONE, node_type); | 108 DCHECK_EQ(TYPE_NONE, node_type); |
106 node_type = type; | 109 node_type = type; |
107 return *this; | 110 return *this; |
108 } | 111 } |
109 | 112 |
| 113 DetailedInfo& InitApp(const string16& app_name, const string16& app_id) { |
| 114 Init(TYPE_APP); |
| 115 this->app_name = app_name; |
| 116 this->app_id = app_id; |
| 117 return *this; |
| 118 } |
| 119 |
110 DetailedInfo& InitCookie( | 120 DetailedInfo& InitCookie( |
111 const net::CookieMonster::CanonicalCookie* cookie) { | 121 const net::CookieMonster::CanonicalCookie* cookie) { |
112 Init(TYPE_COOKIE); | 122 Init(TYPE_COOKIE); |
113 this->cookie = cookie; | 123 this->cookie = cookie; |
114 return *this; | 124 return *this; |
115 } | 125 } |
116 | 126 |
117 DetailedInfo& InitDatabase( | 127 DetailedInfo& InitDatabase( |
118 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info) { | 128 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info) { |
119 Init(TYPE_DATABASE); | 129 Init(TYPE_DATABASE); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 return *this; | 174 return *this; |
165 } | 175 } |
166 | 176 |
167 DetailedInfo& InitServerBoundCert( | 177 DetailedInfo& InitServerBoundCert( |
168 const net::ServerBoundCertStore::ServerBoundCert* server_bound_cert) { | 178 const net::ServerBoundCertStore::ServerBoundCert* server_bound_cert) { |
169 Init(TYPE_SERVER_BOUND_CERT); | 179 Init(TYPE_SERVER_BOUND_CERT); |
170 this->server_bound_cert = server_bound_cert; | 180 this->server_bound_cert = server_bound_cert; |
171 return *this; | 181 return *this; |
172 } | 182 } |
173 | 183 |
| 184 string16 app_name; |
| 185 string16 app_id; |
174 string16 origin; | 186 string16 origin; |
175 NodeType node_type; | 187 NodeType node_type; |
176 const net::CookieMonster::CanonicalCookie* cookie; | 188 const net::CookieMonster::CanonicalCookie* cookie; |
177 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info; | 189 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info; |
178 const BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info; | 190 const BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info; |
179 const BrowsingDataLocalStorageHelper::LocalStorageInfo* | 191 const BrowsingDataLocalStorageHelper::LocalStorageInfo* |
180 session_storage_info; | 192 session_storage_info; |
181 const appcache::AppCacheInfo* appcache_info; | 193 const appcache::AppCacheInfo* appcache_info; |
182 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info; | 194 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info; |
183 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info; | 195 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 | 212 // Returns a struct with detailed information used to populate the details |
201 // part of the view. | 213 // part of the view. |
202 virtual DetailedInfo GetDetailedInfo() const = 0; | 214 virtual DetailedInfo GetDetailedInfo() const = 0; |
203 | 215 |
204 protected: | 216 protected: |
205 class NodeTitleComparator { | 217 class NodeTitleComparator { |
206 public: | 218 public: |
207 bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); | 219 bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); |
208 }; | 220 }; |
209 | 221 |
| 222 class AppNodeComparator { |
| 223 public: |
| 224 bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); |
| 225 }; |
| 226 |
210 void AddChildSortedByTitle(CookieTreeNode* new_child); | 227 void AddChildSortedByTitle(CookieTreeNode* new_child); |
211 | 228 |
212 private: | 229 private: |
213 | 230 |
214 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode); | 231 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode); |
215 }; | 232 }; |
216 | 233 |
217 // CookieTreeRootNode --------------------------------------------------------- | 234 // CookieTreeRootNode --------------------------------------------------------- |
218 // The node at the root of the CookieTree that gets inserted into the view. | 235 // The node at the root of the CookieTree that gets inserted into the view. |
219 class CookieTreeRootNode : public CookieTreeNode { | 236 class CookieTreeRootNode : public CookieTreeNode { |
220 public: | 237 public: |
221 explicit CookieTreeRootNode(CookiesTreeModel* model); | 238 explicit CookieTreeRootNode(CookiesTreeModel* model); |
222 virtual ~CookieTreeRootNode(); | 239 virtual ~CookieTreeRootNode(); |
223 | 240 |
224 CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); | 241 //CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); |
| 242 CookieTreeAppNode* GetOrCreateAppNode(const string16& app_name, |
| 243 const string16& app_id); |
225 | 244 |
226 // CookieTreeNode methods: | 245 // CookieTreeNode methods: |
227 virtual CookiesTreeModel* GetModel() const OVERRIDE; | 246 virtual CookiesTreeModel* GetModel() const OVERRIDE; |
228 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 247 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
229 | 248 |
230 private: | 249 private: |
231 CookiesTreeModel* model_; | 250 CookiesTreeModel* model_; |
232 | 251 |
233 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); | 252 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); |
234 }; | 253 }; |
235 | 254 |
| 255 // CookieTreeAppNode ------------------------------------------------------- |
| 256 class CookieTreeAppNode : public CookieTreeNode { |
| 257 public: |
| 258 explicit CookieTreeAppNode(const string16& app_name, const string16& app_id); |
| 259 virtual ~CookieTreeAppNode(); |
| 260 |
| 261 CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); |
| 262 |
| 263 // CookieTreeNode methods: |
| 264 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
| 265 |
| 266 const string16 app_id() const { return app_id_; } |
| 267 |
| 268 private: |
| 269 string16 app_name_; |
| 270 string16 app_id_; |
| 271 DISALLOW_COPY_AND_ASSIGN(CookieTreeAppNode); |
| 272 }; |
| 273 |
236 // CookieTreeOriginNode ------------------------------------------------------- | 274 // CookieTreeOriginNode ------------------------------------------------------- |
237 class CookieTreeOriginNode : public CookieTreeNode { | 275 class CookieTreeOriginNode : public CookieTreeNode { |
238 public: | 276 public: |
239 // Returns the origin node's title to use for a given URL. | 277 // Returns the origin node's title to use for a given URL. |
240 static std::wstring TitleForUrl(const GURL& url); | 278 static std::wstring TitleForUrl(const GURL& url); |
241 | 279 |
242 explicit CookieTreeOriginNode(const GURL& url); | 280 explicit CookieTreeOriginNode(const string16& app_id, const GURL& url); |
243 virtual ~CookieTreeOriginNode(); | 281 virtual ~CookieTreeOriginNode(); |
244 | 282 |
245 // CookieTreeNode methods: | 283 // CookieTreeNode methods: |
246 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 284 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
247 | 285 |
248 // CookieTreeOriginNode methods: | 286 // CookieTreeOriginNode methods: |
249 CookieTreeCookiesNode* GetOrCreateCookiesNode(); | 287 CookieTreeCookiesNode* GetOrCreateCookiesNode(); |
250 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); | 288 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); |
251 CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); | 289 CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); |
252 CookieTreeSessionStoragesNode* GetOrCreateSessionStoragesNode(); | 290 CookieTreeSessionStoragesNode* GetOrCreateSessionStoragesNode(); |
253 CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); | 291 CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); |
254 CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode(); | 292 CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode(); |
255 CookieTreeFileSystemsNode* GetOrCreateFileSystemsNode(); | 293 CookieTreeFileSystemsNode* GetOrCreateFileSystemsNode(); |
256 CookieTreeServerBoundCertsNode* GetOrCreateServerBoundCertsNode(); | 294 CookieTreeServerBoundCertsNode* GetOrCreateServerBoundCertsNode(); |
257 CookieTreeQuotaNode* UpdateOrCreateQuotaNode( | 295 CookieTreeQuotaNode* UpdateOrCreateQuotaNode( |
258 std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info); | 296 std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info); |
259 | 297 |
260 // Creates an content exception for this origin of type | 298 // Creates an content exception for this origin of type |
261 // CONTENT_SETTINGS_TYPE_COOKIES. | 299 // CONTENT_SETTINGS_TYPE_COOKIES. |
262 void CreateContentException(CookieSettings* cookie_settings, | 300 void CreateContentException(CookieSettings* cookie_settings, |
263 ContentSetting setting) const; | 301 ContentSetting setting) const; |
264 | 302 |
265 // True if a content exception can be created for this origin. | 303 // True if a content exception can be created for this origin. |
266 bool CanCreateContentException() const; | 304 bool CanCreateContentException() const; |
267 | 305 |
| 306 const string16 app_id() const { return app_id_; } |
| 307 |
268 private: | 308 private: |
269 // Pointers to the cookies, databases, local and session storage and appcache | 309 // Pointers to the cookies, databases, local and session storage and appcache |
270 // nodes. When we build up the tree we need to quickly get a reference to | 310 // nodes. When we build up the tree we need to quickly get a reference to |
271 // the COOKIES node to add children. Checking each child and interrogating | 311 // the COOKIES node to add children. Checking each child and interrogating |
272 // them to see if they are a COOKIES, APPCACHES, DATABASES etc node seems | 312 // them to see if they are a COOKIES, APPCACHES, DATABASES etc node seems |
273 // less preferable than storing an extra pointer per origin. | 313 // less preferable than storing an extra pointer per origin. |
274 CookieTreeCookiesNode* cookies_child_; | 314 CookieTreeCookiesNode* cookies_child_; |
275 CookieTreeDatabasesNode* databases_child_; | 315 CookieTreeDatabasesNode* databases_child_; |
276 CookieTreeLocalStoragesNode* local_storages_child_; | 316 CookieTreeLocalStoragesNode* local_storages_child_; |
277 CookieTreeSessionStoragesNode* session_storages_child_; | 317 CookieTreeSessionStoragesNode* session_storages_child_; |
278 CookieTreeAppCachesNode* appcaches_child_; | 318 CookieTreeAppCachesNode* appcaches_child_; |
279 CookieTreeIndexedDBsNode* indexed_dbs_child_; | 319 CookieTreeIndexedDBsNode* indexed_dbs_child_; |
280 CookieTreeFileSystemsNode* file_systems_child_; | 320 CookieTreeFileSystemsNode* file_systems_child_; |
281 CookieTreeQuotaNode* quota_child_; | 321 CookieTreeQuotaNode* quota_child_; |
282 CookieTreeServerBoundCertsNode* server_bound_certs_child_; | 322 CookieTreeServerBoundCertsNode* server_bound_certs_child_; |
283 | 323 |
284 // The URL for which this node was initially created. | 324 // The URL for which this node was initially created. |
285 GURL url_; | 325 GURL url_; |
286 | 326 |
| 327 // The app for which this node was created for. |
| 328 string16 app_id_; |
| 329 |
287 DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); | 330 DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); |
288 }; | 331 }; |
289 | 332 |
290 // CookieTreeCookieNode ------------------------------------------------------ | 333 // CookieTreeCookieNode ------------------------------------------------------ |
291 class CookieTreeCookieNode : public CookieTreeNode { | 334 class CookieTreeCookieNode : public CookieTreeNode { |
292 public: | 335 public: |
293 friend class CookieTreeCookiesNode; | 336 friend class CookieTreeCookiesNode; |
294 | 337 |
295 // The cookie should remain valid at least as long as the | 338 // The cookie should remain valid at least as long as the |
296 // CookieTreeCookieNode is valid. | 339 // CookieTreeCookieNode is valid. |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 650 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
608 | 651 |
609 void AddServerBoundCertNode(CookieTreeServerBoundCertNode* child) { | 652 void AddServerBoundCertNode(CookieTreeServerBoundCertNode* child) { |
610 AddChildSortedByTitle(child); | 653 AddChildSortedByTitle(child); |
611 } | 654 } |
612 | 655 |
613 private: | 656 private: |
614 DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); | 657 DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); |
615 }; | 658 }; |
616 | 659 |
| 660 |
| 661 class CookiesTreeModelDelegate { |
| 662 public: |
| 663 //CookiesTreeModelDelegate(); |
| 664 |
| 665 virtual void PopulateAppCacheInfoWithFilter(string16* app, |
| 666 const std::wstring& filter) {} |
| 667 virtual void PopulateCookieInfoWithFilter(string16* app, |
| 668 const std::wstring& filter) {} |
| 669 virtual void PopulateDatabaseInfoWithFilter(string16* app, |
| 670 const std::wstring& filter) {} |
| 671 virtual void PopulateLocalStorageInfoWithFilter(string16* app, |
| 672 const std::wstring& filter) {} |
| 673 virtual void PopulateSessionStorageInfoWithFilter( |
| 674 string16* app, const std::wstring& filter) {} |
| 675 virtual void PopulateIndexedDBInfoWithFilter(string16* app, |
| 676 const std::wstring& filter) {} |
| 677 virtual void PopulateFileSystemInfoWithFilter(string16* app, |
| 678 const std::wstring& filter) {} |
| 679 virtual void PopulateQuotaInfoWithFilter(string16* app, |
| 680 const std::wstring& filter) {} |
| 681 virtual void PopulateServerBoundCertInfoWithFilter( |
| 682 string16* app, const std::wstring& filter) {} |
| 683 }; |
| 684 |
| 685 typedef std::map<string16, LocalDataContainer*> ContainerMap; |
| 686 |
617 // CookiesTreeModel ----------------------------------------------------------- | 687 // CookiesTreeModel ----------------------------------------------------------- |
618 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { | 688 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode>, |
| 689 public CookiesTreeModelDelegate { |
619 public: | 690 public: |
| 691 CookiesTreeModel(ContainerMap& apps_map); |
| 692 virtual ~CookiesTreeModel(); |
| 693 |
620 // Because non-cookie nodes are fetched in a background thread, they are not | 694 // 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 | 695 // present at the time the Model is created. The Model then notifies its |
622 // observers for every item added from databases, local storage, and | 696 // observers for every item added from databases, local storage, and |
623 // appcache. We extend the Observer interface to add notifications before and | 697 // appcache. We extend the Observer interface to add notifications before and |
624 // after these batch inserts. | 698 // after these batch inserts. |
625 class Observer : public ui::TreeModelObserver { | 699 class Observer : public ui::TreeModelObserver { |
626 public: | 700 public: |
627 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} | 701 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} |
628 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} | 702 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} |
629 }; | 703 }; |
630 | 704 |
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: | 705 // ui::TreeModel methods: |
645 // Returns the set of icons for the nodes in the tree. You only need override | 706 // 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. | 707 // this if you don't want to use the default folder icons. |
647 virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) OVERRIDE; | 708 virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) OVERRIDE; |
648 | 709 |
649 // Returns the index of the icon to use for |node|. Return -1 to use the | 710 // 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 | 711 // default icon. The index is relative to the list of icons returned from |
651 // GetIcons. | 712 // GetIcons. |
652 virtual int GetIconIndex(ui::TreeModelNode* node) OVERRIDE; | 713 virtual int GetIconIndex(ui::TreeModelNode* node) OVERRIDE; |
653 | 714 |
654 // CookiesTreeModel methods: | 715 // CookiesTreeModel methods: |
655 void DeleteAllStoredObjects(); | 716 void DeleteAllStoredObjects(); |
656 void DeleteCookieNode(CookieTreeNode* cookie_node); | 717 void DeleteCookieNode(CookieTreeNode* cookie_node); |
657 | 718 |
658 // Filter the origins to only display matched results. | 719 // Filter the origins to only display matched results. |
659 void UpdateSearchResults(const std::wstring& filter); | 720 void UpdateSearchResults(const std::wstring& filter); |
660 | 721 |
661 // Manages CookiesTreeModel::Observers. This will also call | 722 // Manages CookiesTreeModel::Observers. This will also call |
662 // TreeNodeModel::AddObserver so that it gets all the proper notifications. | 723 // TreeNodeModel::AddObserver so that it gets all the proper notifications. |
663 // Note that the converse is not true: simply adding a TreeModelObserver will | 724 // Note that the converse is not true: simply adding a TreeModelObserver will |
664 // not get CookiesTreeModel::Observer notifications. | 725 // not get CookiesTreeModel::Observer notifications. |
665 virtual void AddCookiesTreeObserver(Observer* observer); | 726 virtual void AddCookiesTreeObserver(Observer* observer); |
666 virtual void RemoveCookiesTreeObserver(Observer* observer); | 727 virtual void RemoveCookiesTreeObserver(Observer* observer); |
667 | 728 |
| 729 void PopulateAppCacheInfoWithFilter(string16* app, |
| 730 const std::wstring& filter); |
| 731 void PopulateCookieInfoWithFilter(string16* app, |
| 732 const std::wstring& filter); |
| 733 void PopulateDatabaseInfoWithFilter(string16* app, |
| 734 const std::wstring& filter); |
| 735 void PopulateLocalStorageInfoWithFilter(string16* app, |
| 736 const std::wstring& filter); |
| 737 void PopulateSessionStorageInfoWithFilter(string16* app, |
| 738 const std::wstring& filter); |
| 739 void PopulateIndexedDBInfoWithFilter(string16* app, |
| 740 const std::wstring& filter); |
| 741 void PopulateFileSystemInfoWithFilter(string16* app, |
| 742 const std::wstring& filter); |
| 743 void PopulateQuotaInfoWithFilter(string16* app, |
| 744 const std::wstring& filter); |
| 745 void PopulateServerBoundCertInfoWithFilter(string16* app, |
| 746 const std::wstring& filter); |
| 747 |
| 748 BrowsingDataCookieHelper* GetCookieHelper(const string16& app_id); |
| 749 LocalDataContainer* GetLocalDataContainer(const string16& app_id); |
| 750 |
668 private: | 751 private: |
669 enum CookieIconIndex { | 752 enum CookieIconIndex { |
670 ORIGIN = 0, | 753 ORIGIN = 0, |
671 COOKIE = 1, | 754 COOKIE = 1, |
672 DATABASE = 2 | 755 DATABASE = 2 |
673 }; | 756 }; |
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 | |
688 void OnAppCacheModelInfoLoaded(); | |
689 void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list); | |
690 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); | |
691 void OnLocalStorageModelInfoLoaded( | |
692 const LocalStorageInfoList& local_storage_info); | |
693 void OnSessionStorageModelInfoLoaded( | |
694 const LocalStorageInfoList& local_storage_info); | |
695 void OnIndexedDBModelInfoLoaded( | |
696 const IndexedDBInfoList& indexed_db_info); | |
697 void OnFileSystemModelInfoLoaded( | |
698 const FileSystemInfoList& file_system_info); | |
699 void OnQuotaModelInfoLoaded(const QuotaInfoArray& quota_info); | |
700 void OnServerBoundCertModelInfoLoaded(const ServerBoundCertList& cert_list); | |
701 | |
702 void PopulateAppCacheInfoWithFilter(const std::wstring& filter); | |
703 void PopulateCookieInfoWithFilter(const std::wstring& filter); | |
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 | 757 |
712 void NotifyObserverBeginBatch(); | 758 void NotifyObserverBeginBatch(); |
713 void NotifyObserverEndBatch(); | 759 void NotifyObserverEndBatch(); |
714 | 760 |
715 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; | 761 ContainerMap app_data_map_; |
716 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; | 762 |
717 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; | 763 // The CookiesTreeModel maintains a separate list of observers that are |
718 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; | 764 // specifically of the type CookiesTreeModel::Observer. |
719 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; | 765 ObserverList<Observer> cookies_observer_list_; |
720 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; | 766 |
721 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; | 767 // If true, use the CanonicalCookie::Source attribute to group cookies. |
722 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; | 768 // Otherwise, use the CanonicalCookie::Domain attribute. |
723 scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_; | 769 bool use_cookie_source_; |
| 770 |
| 771 // If this is non-zero, then this model is batching updates (there's a lot of |
| 772 // notifications coming down the pipe). This is an integer is used to balance |
| 773 // calls to Begin/EndBatch() if they're called in a nested manner. |
| 774 int batch_update_; |
| 775 }; |
| 776 |
| 777 typedef std::list<net::CookieMonster::CanonicalCookie> CookieList; |
| 778 typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo> DatabaseInfoList; |
| 779 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
| 780 LocalStorageInfoList; |
| 781 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
| 782 SessionStorageInfoList; |
| 783 typedef std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> IndexedDBInfoList; |
| 784 typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo> |
| 785 FileSystemInfoList; |
| 786 typedef std::list<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoArray; |
| 787 typedef net::ServerBoundCertStore::ServerBoundCertList ServerBoundCertList; |
| 788 |
| 789 |
| 790 // LocalDataContainer --------------------------------------------------------- |
| 791 class LocalDataContainer { |
| 792 public: |
| 793 LocalDataContainer( |
| 794 const string16& app_name, |
| 795 const string16& app_id, |
| 796 BrowsingDataCookieHelper* cookie_helper, |
| 797 BrowsingDataDatabaseHelper* database_helper, |
| 798 BrowsingDataLocalStorageHelper* local_storage_helper, |
| 799 BrowsingDataLocalStorageHelper* session_storage_helper, |
| 800 BrowsingDataAppCacheHelper* appcache_helper, |
| 801 BrowsingDataIndexedDBHelper* indexed_db_helper, |
| 802 BrowsingDataFileSystemHelper* file_system_helper, |
| 803 BrowsingDataQuotaHelper* quota_helper, |
| 804 BrowsingDataServerBoundCertHelper* server_bound_cert_helper, |
| 805 bool use_cookie_source); |
| 806 virtual ~LocalDataContainer(); |
| 807 |
| 808 void Init(CookiesTreeModelDelegate* d); |
| 809 |
| 810 string16 app_name() { return app_name_; } |
| 811 string16 app_id() { return app_id_; } |
| 812 |
| 813 BrowsingDataCookieHelper* cookie_helper() { return cookie_helper_; } |
724 | 814 |
725 std::map<GURL, std::list<appcache::AppCacheInfo> > appcache_info_; | 815 std::map<GURL, std::list<appcache::AppCacheInfo> > appcache_info_; |
726 CookieList cookie_list_; | 816 CookieList cookie_list_; |
727 DatabaseInfoList database_info_list_; | 817 DatabaseInfoList database_info_list_; |
728 LocalStorageInfoList local_storage_info_list_; | 818 LocalStorageInfoList local_storage_info_list_; |
729 LocalStorageInfoList session_storage_info_list_; | 819 LocalStorageInfoList session_storage_info_list_; |
730 IndexedDBInfoList indexed_db_info_list_; | 820 IndexedDBInfoList indexed_db_info_list_; |
731 FileSystemInfoList file_system_info_list_; | 821 FileSystemInfoList file_system_info_list_; |
732 QuotaInfoArray quota_info_list_; | 822 QuotaInfoArray quota_info_list_; |
733 ServerBoundCertList server_bound_cert_list_; | 823 ServerBoundCertList server_bound_cert_list_; |
734 | 824 |
735 // The CookiesTreeModel maintains a separate list of observers that are | 825 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; |
736 // specifically of the type CookiesTreeModel::Observer. | 826 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; |
737 ObserverList<Observer> cookies_observer_list_; | 827 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; |
| 828 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; |
| 829 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; |
| 830 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; |
| 831 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; |
| 832 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; |
| 833 scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_; |
738 | 834 |
739 // If this is non-zero, then this model is batching updates (there's a lot of | 835 private: |
740 // notifications coming down the pipe). This is an integer is used to balance | 836 void OnAppCacheModelInfoLoaded(); |
741 // calls to Begin/EndBatch() if they're called in a nested manner. | 837 void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list); |
742 int batch_update_; | 838 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); |
| 839 void OnLocalStorageModelInfoLoaded( |
| 840 const LocalStorageInfoList& local_storage_info); |
| 841 void OnSessionStorageModelInfoLoaded( |
| 842 const LocalStorageInfoList& local_storage_info); |
| 843 void OnIndexedDBModelInfoLoaded( |
| 844 const IndexedDBInfoList& indexed_db_info); |
| 845 void OnFileSystemModelInfoLoaded( |
| 846 const FileSystemInfoList& file_system_info); |
| 847 void OnQuotaModelInfoLoaded(const QuotaInfoArray& quota_info); |
| 848 void OnServerBoundCertModelInfoLoaded(const ServerBoundCertList& cert_list); |
743 | 849 |
744 // If true, use the CanonicalCookie::Source attribute to group cookies. | 850 string16 app_name_; |
745 // Otherwise, use the CanonicalCookie::Domain attribute. | 851 string16 app_id_; |
746 bool use_cookie_source_; | 852 CookiesTreeModelDelegate* delegate_; |
747 | 853 |
748 base::WeakPtrFactory<CookiesTreeModel> weak_ptr_factory_; | |
749 | 854 |
| 855 base::WeakPtrFactory<LocalDataContainer> weak_ptr_factory_; |
| 856 |
| 857 /* |
750 friend class CookieTreeAppCacheNode; | 858 friend class CookieTreeAppCacheNode; |
751 friend class CookieTreeCookieNode; | 859 friend class CookieTreeCookieNode; |
752 friend class CookieTreeDatabaseNode; | 860 friend class CookieTreeDatabaseNode; |
753 friend class CookieTreeLocalStorageNode; | 861 friend class CookieTreeLocalStorageNode; |
754 friend class CookieTreeSessionStorageNode; | 862 friend class CookieTreeSessionStorageNode; |
755 friend class CookieTreeIndexedDBNode; | 863 friend class CookieTreeIndexedDBNode; |
756 friend class CookieTreeFileSystemNode; | 864 friend class CookieTreeFileSystemNode; |
757 friend class CookieTreeQuotaNode; | 865 friend class CookieTreeQuotaNode; |
758 friend class CookieTreeServerBoundCertNode; | 866 friend class CookieTreeServerBoundCertNode; |
759 | 867 friend class CookieTreeModel; |
760 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); | 868 */ |
| 869 DISALLOW_COPY_AND_ASSIGN(LocalDataContainer); |
761 }; | 870 }; |
762 | 871 |
763 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ | 872 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
OLD | NEW |