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). |
11 | 11 |
12 #include <list> | 12 #include <list> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
19 #include "base/string16.h" | 19 #include "base/string16.h" |
20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
21 #include "chrome/browser/browsing_data_appcache_helper.h" | 21 #include "chrome/browser/browsing_data_appcache_helper.h" |
22 #include "chrome/browser/browsing_data_database_helper.h" | 22 #include "chrome/browser/browsing_data_database_helper.h" |
23 #include "chrome/browser/browsing_data_file_system_helper.h" | 23 #include "chrome/browser/browsing_data_file_system_helper.h" |
24 #include "chrome/browser/browsing_data_indexed_db_helper.h" | 24 #include "chrome/browser/browsing_data_indexed_db_helper.h" |
25 #include "chrome/browser/browsing_data_local_storage_helper.h" | 25 #include "chrome/browser/browsing_data_local_storage_helper.h" |
26 #include "chrome/browser/browsing_data_quota_helper.h" | 26 #include "chrome/browser/browsing_data_quota_helper.h" |
27 #include "chrome/browser/local_data_container.h" | |
27 #include "chrome/common/content_settings.h" | 28 #include "chrome/common/content_settings.h" |
28 #include "net/base/server_bound_cert_store.h" | 29 #include "net/base/server_bound_cert_store.h" |
29 #include "net/cookies/cookie_monster.h" | 30 #include "net/cookies/cookie_monster.h" |
30 #include "ui/base/models/tree_node_model.h" | 31 #include "ui/base/models/tree_node_model.h" |
31 | 32 |
32 class BrowsingDataCookieHelper; | 33 class BrowsingDataCookieHelper; |
33 class BrowsingDataServerBoundCertHelper; | 34 class BrowsingDataServerBoundCertHelper; |
34 class CookieSettings; | 35 class CookieSettings; |
35 class CookiesTreeModel; | 36 class CookiesTreeModel; |
36 class CookieTreeAppCacheNode; | 37 class CookieTreeAppCacheNode; |
37 class CookieTreeAppCachesNode; | 38 class CookieTreeAppCachesNode; |
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 |
52 class CookieTreeIndexedDBsNode; | |
53 class CookieTreeOriginNode; | |
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.) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 file_system_info(NULL), | 102 file_system_info(NULL), |
101 quota_info(NULL), | 103 quota_info(NULL), |
102 server_bound_cert(NULL) {} | 104 server_bound_cert(NULL) {} |
103 | 105 |
104 DetailedInfo& Init(NodeType type) { | 106 DetailedInfo& Init(NodeType type) { |
105 DCHECK_EQ(TYPE_NONE, node_type); | 107 DCHECK_EQ(TYPE_NONE, node_type); |
106 node_type = type; | 108 node_type = type; |
107 return *this; | 109 return *this; |
108 } | 110 } |
109 | 111 |
112 DetailedInfo& InitOrigin(const std::string& app_id, | |
113 const std::string& app_name) { | |
114 Init(TYPE_ORIGIN); | |
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 std::string app_name; | |
185 std::string 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 11 matching lines...) Expand all Loading... | |
195 virtual void DeleteStoredObjects(); | 207 virtual void DeleteStoredObjects(); |
196 | 208 |
197 // Gets a pointer back to the associated model for the tree we are in. | 209 // Gets a pointer back to the associated model for the tree we are in. |
198 virtual CookiesTreeModel* GetModel() const; | 210 virtual CookiesTreeModel* GetModel() const; |
199 | 211 |
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: |
217 // This class implements comparison by title of a CookieTreeNode. It is | |
218 // used to insert nodes in alphabetical order. | |
205 class NodeTitleComparator { | 219 class NodeTitleComparator { |
206 public: | 220 public: |
207 bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); | 221 bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); |
208 }; | 222 }; |
209 | 223 |
210 void AddChildSortedByTitle(CookieTreeNode* new_child); | 224 void AddChildSortedByTitle(CookieTreeNode* new_child); |
211 | 225 |
212 private: | 226 private: |
213 | 227 |
214 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode); | 228 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode); |
215 }; | 229 }; |
216 | 230 |
217 // CookieTreeRootNode --------------------------------------------------------- | 231 // CookieTreeRootNode --------------------------------------------------------- |
218 // The node at the root of the CookieTree that gets inserted into the view. | 232 // The node at the root of the CookieTree that gets inserted into the view. |
219 class CookieTreeRootNode : public CookieTreeNode { | 233 class CookieTreeRootNode : public CookieTreeNode { |
220 public: | 234 public: |
221 explicit CookieTreeRootNode(CookiesTreeModel* model); | 235 explicit CookieTreeRootNode(CookiesTreeModel* model); |
222 virtual ~CookieTreeRootNode(); | 236 virtual ~CookieTreeRootNode(); |
223 | 237 |
224 CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); | 238 CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url, |
239 const std::string& app_id, | |
240 const std::string& app_name); | |
225 | 241 |
226 // CookieTreeNode methods: | 242 // CookieTreeNode methods: |
227 virtual CookiesTreeModel* GetModel() const OVERRIDE; | 243 virtual CookiesTreeModel* GetModel() const OVERRIDE; |
228 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 244 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
229 | 245 |
230 private: | 246 private: |
231 CookiesTreeModel* model_; | 247 CookiesTreeModel* model_; |
232 | 248 |
233 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); | 249 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); |
234 }; | 250 }; |
235 | 251 |
236 // CookieTreeOriginNode ------------------------------------------------------- | 252 // CookieTreeOriginNode ------------------------------------------------------- |
237 class CookieTreeOriginNode : public CookieTreeNode { | 253 class CookieTreeOriginNode : public CookieTreeNode { |
238 public: | 254 public: |
239 // Returns the origin node's title to use for a given URL. | 255 // Returns the origin node's title to use for a given URL. |
240 static std::wstring TitleForUrl(const GURL& url); | 256 static string16 TitleForUrl(const GURL& url, |
257 const std::string& app_id, | |
258 const std::string& app_name); | |
241 | 259 |
242 explicit CookieTreeOriginNode(const GURL& url); | 260 explicit CookieTreeOriginNode(const GURL& url, |
261 const std::string& app_id, | |
262 const std::string& app_name); | |
243 virtual ~CookieTreeOriginNode(); | 263 virtual ~CookieTreeOriginNode(); |
244 | 264 |
245 // CookieTreeNode methods: | 265 // CookieTreeNode methods: |
246 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 266 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
247 | 267 |
248 // CookieTreeOriginNode methods: | 268 // CookieTreeOriginNode methods: |
249 CookieTreeCookiesNode* GetOrCreateCookiesNode(); | 269 CookieTreeCookiesNode* GetOrCreateCookiesNode(); |
250 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); | 270 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); |
251 CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); | 271 CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); |
252 CookieTreeSessionStoragesNode* GetOrCreateSessionStoragesNode(); | 272 CookieTreeSessionStoragesNode* GetOrCreateSessionStoragesNode(); |
253 CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); | 273 CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); |
254 CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode(); | 274 CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode(); |
255 CookieTreeFileSystemsNode* GetOrCreateFileSystemsNode(); | 275 CookieTreeFileSystemsNode* GetOrCreateFileSystemsNode(); |
256 CookieTreeServerBoundCertsNode* GetOrCreateServerBoundCertsNode(); | 276 CookieTreeServerBoundCertsNode* GetOrCreateServerBoundCertsNode(); |
257 CookieTreeQuotaNode* UpdateOrCreateQuotaNode( | 277 CookieTreeQuotaNode* UpdateOrCreateQuotaNode( |
258 std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info); | 278 std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info); |
259 | 279 |
260 // Creates an content exception for this origin of type | 280 // Creates an content exception for this origin of type |
261 // CONTENT_SETTINGS_TYPE_COOKIES. | 281 // CONTENT_SETTINGS_TYPE_COOKIES. |
262 void CreateContentException(CookieSettings* cookie_settings, | 282 void CreateContentException(CookieSettings* cookie_settings, |
263 ContentSetting setting) const; | 283 ContentSetting setting) const; |
264 | 284 |
265 // True if a content exception can be created for this origin. | 285 // True if a content exception can be created for this origin. |
266 bool CanCreateContentException() const; | 286 bool CanCreateContentException() const; |
267 | 287 |
288 const std::string& app_id() const { return app_id_; } | |
289 const std::string& app_name() const { return app_name_; } | |
290 const std::string GetHost() const; | |
291 | |
268 private: | 292 private: |
269 // Pointers to the cookies, databases, local and session storage and appcache | 293 // 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 | 294 // 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 | 295 // 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 | 296 // them to see if they are a COOKIES, APPCACHES, DATABASES etc node seems |
273 // less preferable than storing an extra pointer per origin. | 297 // less preferable than storing an extra pointer per origin. |
274 CookieTreeCookiesNode* cookies_child_; | 298 CookieTreeCookiesNode* cookies_child_; |
275 CookieTreeDatabasesNode* databases_child_; | 299 CookieTreeDatabasesNode* databases_child_; |
276 CookieTreeLocalStoragesNode* local_storages_child_; | 300 CookieTreeLocalStoragesNode* local_storages_child_; |
277 CookieTreeSessionStoragesNode* session_storages_child_; | 301 CookieTreeSessionStoragesNode* session_storages_child_; |
278 CookieTreeAppCachesNode* appcaches_child_; | 302 CookieTreeAppCachesNode* appcaches_child_; |
279 CookieTreeIndexedDBsNode* indexed_dbs_child_; | 303 CookieTreeIndexedDBsNode* indexed_dbs_child_; |
280 CookieTreeFileSystemsNode* file_systems_child_; | 304 CookieTreeFileSystemsNode* file_systems_child_; |
281 CookieTreeQuotaNode* quota_child_; | 305 CookieTreeQuotaNode* quota_child_; |
282 CookieTreeServerBoundCertsNode* server_bound_certs_child_; | 306 CookieTreeServerBoundCertsNode* server_bound_certs_child_; |
283 | 307 |
308 std::string app_id_; | |
309 std::string app_name_; | |
310 | |
284 // The URL for which this node was initially created. | 311 // The URL for which this node was initially created. |
285 GURL url_; | 312 GURL url_; |
286 | 313 |
287 DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); | 314 DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); |
288 }; | 315 }; |
289 | 316 |
290 // CookieTreeCookieNode ------------------------------------------------------ | 317 // CookieTreeCookieNode ------------------------------------------------------ |
291 class CookieTreeCookieNode : public CookieTreeNode { | 318 class CookieTreeCookieNode : public CookieTreeNode { |
292 public: | 319 public: |
293 friend class CookieTreeCookiesNode; | 320 friend class CookieTreeCookiesNode; |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 634 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
608 | 635 |
609 void AddServerBoundCertNode(CookieTreeServerBoundCertNode* child) { | 636 void AddServerBoundCertNode(CookieTreeServerBoundCertNode* child) { |
610 AddChildSortedByTitle(child); | 637 AddChildSortedByTitle(child); |
611 } | 638 } |
612 | 639 |
613 private: | 640 private: |
614 DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); | 641 DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); |
615 }; | 642 }; |
616 | 643 |
644 // CookiesTreeModelDelegate --------------------------------------------------- | |
645 // This is a delegate definition class. It is used by the CookiesTreeModel | |
646 // to pass a pointer to itself to each of the LocalDataContainer objects, so | |
647 // when resource fetching is complete, the objects can call back to the model | |
648 // and update it. The CookiesTreeModel instance must outlive the | |
649 // LocalDataContainer instances. | |
650 class CookiesTreeModelDelegate { | |
651 public: | |
652 virtual void PopulateAppCacheInfoWithFilter( | |
653 const std::string* app_id, const string16& filter) = 0; | |
654 virtual void PopulateCookieInfoWithFilter( | |
655 const std::string* app_id, const string16& filter) = 0; | |
656 virtual void PopulateDatabaseInfoWithFilter( | |
657 const std::string* app_id, const string16& filter) = 0; | |
658 virtual void PopulateLocalStorageInfoWithFilter( | |
659 const std::string* app_id, const string16& filter) = 0; | |
660 virtual void PopulateSessionStorageInfoWithFilter( | |
661 const std::string* app_id, const string16& filter) = 0; | |
662 virtual void PopulateIndexedDBInfoWithFilter( | |
663 const std::string* app_id, const string16& filter) = 0; | |
664 virtual void PopulateFileSystemInfoWithFilter( | |
665 const std::string* app_id, const string16& filter) = 0; | |
666 virtual void PopulateQuotaInfoWithFilter( | |
667 const std::string* app_id, const string16& filter) = 0; | |
668 virtual void PopulateServerBoundCertInfoWithFilter( | |
669 const std::string* app_id, const string16& filter) = 0; | |
670 | |
671 protected: | |
672 virtual ~CookiesTreeModelDelegate() {} | |
673 }; | |
674 | |
617 // CookiesTreeModel ----------------------------------------------------------- | 675 // CookiesTreeModel ----------------------------------------------------------- |
618 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { | 676 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode>, |
677 public CookiesTreeModelDelegate { | |
Bernhard Bauer
2012/06/26 21:03:55
Wait, CookiesTreeModel is a CookiesTreeModelDelega
nasko
2012/06/26 22:33:16
Done.
| |
619 public: | 678 public: |
679 CookiesTreeModel(const ContainerMap& apps_map, bool use_cookie_source); | |
680 virtual ~CookiesTreeModel(); | |
681 | |
620 // Because non-cookie nodes are fetched in a background thread, they are not | 682 // 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 | 683 // present at the time the Model is created. The Model then notifies its |
622 // observers for every item added from databases, local storage, and | 684 // observers for every item added from databases, local storage, and |
623 // appcache. We extend the Observer interface to add notifications before and | 685 // appcache. We extend the Observer interface to add notifications before and |
624 // after these batch inserts. | 686 // after these batch inserts. |
625 class Observer : public ui::TreeModelObserver { | 687 class Observer : public ui::TreeModelObserver { |
626 public: | 688 public: |
627 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} | 689 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} |
628 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} | 690 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} |
629 }; | 691 }; |
630 | 692 |
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: | 693 // ui::TreeModel methods: |
645 // Returns the set of icons for the nodes in the tree. You only need override | 694 // 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. | 695 // this if you don't want to use the default folder icons. |
647 virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) OVERRIDE; | 696 virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) OVERRIDE; |
648 | 697 |
649 // Returns the index of the icon to use for |node|. Return -1 to use the | 698 // 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 | 699 // default icon. The index is relative to the list of icons returned from |
651 // GetIcons. | 700 // GetIcons. |
652 virtual int GetIconIndex(ui::TreeModelNode* node) OVERRIDE; | 701 virtual int GetIconIndex(ui::TreeModelNode* node) OVERRIDE; |
653 | 702 |
654 // CookiesTreeModel methods: | 703 // CookiesTreeModel methods: |
655 void DeleteAllStoredObjects(); | 704 void DeleteAllStoredObjects(); |
705 | |
706 // Deletes a specific node in the tree, identified by |cookie_node|, and its | |
707 // subtree. | |
656 void DeleteCookieNode(CookieTreeNode* cookie_node); | 708 void DeleteCookieNode(CookieTreeNode* cookie_node); |
657 | 709 |
658 // Filter the origins to only display matched results. | 710 // Filter the origins to only display matched results. |
659 void UpdateSearchResults(const std::wstring& filter); | 711 void UpdateSearchResults(const string16& filter); |
660 | 712 |
661 // Manages CookiesTreeModel::Observers. This will also call | 713 // Manages CookiesTreeModel::Observers. This will also call |
662 // TreeNodeModel::AddObserver so that it gets all the proper notifications. | 714 // TreeNodeModel::AddObserver so that it gets all the proper notifications. |
663 // Note that the converse is not true: simply adding a TreeModelObserver will | 715 // Note that the converse is not true: simply adding a TreeModelObserver will |
664 // not get CookiesTreeModel::Observer notifications. | 716 // not get CookiesTreeModel::Observer notifications. |
665 virtual void AddCookiesTreeObserver(Observer* observer); | 717 virtual void AddCookiesTreeObserver(Observer* observer); |
666 virtual void RemoveCookiesTreeObserver(Observer* observer); | 718 virtual void RemoveCookiesTreeObserver(Observer* observer); |
667 | 719 |
720 // CookiesTreeModelDelegate methods: | |
721 virtual void PopulateAppCacheInfoWithFilter( | |
722 const std::string* app_id, const string16& filter) OVERRIDE; | |
723 virtual void PopulateCookieInfoWithFilter( | |
724 const std::string* app_id, const string16& filter) OVERRIDE; | |
725 virtual void PopulateDatabaseInfoWithFilter( | |
726 const std::string* app_id, const string16& filter) OVERRIDE; | |
727 virtual void PopulateLocalStorageInfoWithFilter( | |
728 const std::string* app_id, const string16& filter) OVERRIDE; | |
729 virtual void PopulateSessionStorageInfoWithFilter( | |
730 const std::string* app_id, const string16& filter) OVERRIDE; | |
731 virtual void PopulateIndexedDBInfoWithFilter( | |
732 const std::string* app_id, const string16& filter) OVERRIDE; | |
733 virtual void PopulateFileSystemInfoWithFilter( | |
734 const std::string* app_id, const string16& filter) OVERRIDE; | |
735 virtual void PopulateQuotaInfoWithFilter( | |
736 const std::string* app_id, const string16& filter) OVERRIDE; | |
737 virtual void PopulateServerBoundCertInfoWithFilter( | |
738 const std::string* app_id, const string16& filter) OVERRIDE; | |
739 | |
740 BrowsingDataCookieHelper* GetCookieHelper(const std::string& app_id); | |
741 LocalDataContainer* GetLocalDataContainer(const std::string& app_id); | |
742 | |
668 private: | 743 private: |
669 enum CookieIconIndex { | 744 enum CookieIconIndex { |
670 ORIGIN = 0, | 745 ORIGIN = 0, |
671 COOKIE = 1, | 746 COOKIE = 1, |
672 DATABASE = 2 | 747 DATABASE = 2 |
673 }; | 748 }; |
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 | 749 |
712 void NotifyObserverBeginBatch(); | 750 void NotifyObserverBeginBatch(); |
713 void NotifyObserverEndBatch(); | 751 void NotifyObserverEndBatch(); |
714 | 752 |
715 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; | 753 // Map of app ids to LocalDataContainer objects to use when retrieving |
716 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; | 754 // locally stored data. |
717 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; | 755 ContainerMap app_data_map_; |
718 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; | |
719 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; | |
720 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; | |
721 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; | |
722 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; | |
723 scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_; | |
724 | |
725 std::map<GURL, std::list<appcache::AppCacheInfo> > appcache_info_; | |
726 CookieList cookie_list_; | |
727 DatabaseInfoList database_info_list_; | |
728 LocalStorageInfoList local_storage_info_list_; | |
729 LocalStorageInfoList session_storage_info_list_; | |
730 IndexedDBInfoList indexed_db_info_list_; | |
731 FileSystemInfoList file_system_info_list_; | |
732 QuotaInfoArray quota_info_list_; | |
733 ServerBoundCertList server_bound_cert_list_; | |
734 | 756 |
735 // The CookiesTreeModel maintains a separate list of observers that are | 757 // The CookiesTreeModel maintains a separate list of observers that are |
736 // specifically of the type CookiesTreeModel::Observer. | 758 // specifically of the type CookiesTreeModel::Observer. |
737 ObserverList<Observer> cookies_observer_list_; | 759 ObserverList<Observer> cookies_observer_list_; |
738 | 760 |
761 // If true, use the CanonicalCookie::Source attribute to group cookies. | |
762 // Otherwise, use the CanonicalCookie::Domain attribute. | |
763 bool use_cookie_source_; | |
Bernhard Bauer
2012/06/26 21:03:55
|group_by_cookie_source_|?
nasko
2012/06/26 22:33:16
This was just moved around, but I think it is a go
| |
764 | |
739 // If this is non-zero, then this model is batching updates (there's a lot of | 765 // If this is non-zero, then this model is batching updates (there's a lot of |
740 // notifications coming down the pipe). This is an integer is used to balance | 766 // 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. | 767 // calls to Begin/EndBatch() if they're called in a nested manner. |
742 int batch_update_; | 768 int batch_update_; |
743 | |
744 // If true, use the CanonicalCookie::Source attribute to group cookies. | |
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; | |
751 friend class CookieTreeCookieNode; | |
752 friend class CookieTreeDatabaseNode; | |
753 friend class CookieTreeLocalStorageNode; | |
754 friend class CookieTreeSessionStorageNode; | |
755 friend class CookieTreeIndexedDBNode; | |
756 friend class CookieTreeFileSystemNode; | |
757 friend class CookieTreeQuotaNode; | |
758 friend class CookieTreeServerBoundCertNode; | |
759 | |
760 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); | |
761 }; | 769 }; |
762 | 770 |
763 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ | 771 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
OLD | NEW |