Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1059)

Side by Side Diff: chrome/browser/cookies_tree_model.h

Issue 10636019: Adding Application Data dialog for isolated apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some fixes and refactoring Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
617 // CookiesTreeModel ----------------------------------------------------------- 644 // CookiesTreeModel -----------------------------------------------------------
618 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { 645 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
619 public: 646 public:
647 CookiesTreeModel(const ContainerMap& apps_map, bool group_by_cookie_source);
648 virtual ~CookiesTreeModel();
649
620 // Because non-cookie nodes are fetched in a background thread, they are not 650 // 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 651 // present at the time the Model is created. The Model then notifies its
622 // observers for every item added from databases, local storage, and 652 // observers for every item added from databases, local storage, and
623 // appcache. We extend the Observer interface to add notifications before and 653 // appcache. We extend the Observer interface to add notifications before and
624 // after these batch inserts. 654 // after these batch inserts.
625 class Observer : public ui::TreeModelObserver { 655 class Observer : public ui::TreeModelObserver {
626 public: 656 public:
627 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} 657 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {}
628 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} 658 virtual void TreeModelEndBatch(CookiesTreeModel* model) {}
629 }; 659 };
630 660
631 CookiesTreeModel( 661 // This class defines the scope for batch updates. It can be created as a
632 BrowsingDataCookieHelper* cookie_helper, 662 // local variable and the destructor will terminate the batch update, if one
633 BrowsingDataDatabaseHelper* database_helper, 663 // has been started.
634 BrowsingDataLocalStorageHelper* local_storage_helper, 664 class ScopedBatchUpdateNotifier {
635 BrowsingDataLocalStorageHelper* session_storage_helper, 665 public:
636 BrowsingDataAppCacheHelper* appcache_helper, 666 ScopedBatchUpdateNotifier(CookiesTreeModel* model,
637 BrowsingDataIndexedDBHelper* indexed_db_helper, 667 CookieTreeNode* node);
638 BrowsingDataFileSystemHelper* file_system_helper, 668 ~ScopedBatchUpdateNotifier();
639 BrowsingDataQuotaHelper* quota_helper, 669
640 BrowsingDataServerBoundCertHelper* server_bound_cert_helper, 670 void StartBatchUpdate();
641 bool use_cookie_source); 671
642 virtual ~CookiesTreeModel(); 672 private:
673 CookiesTreeModel* model_;
674 CookieTreeNode* node_;
675 bool batch_in_progress_;
676 };
643 677
644 // ui::TreeModel methods: 678 // ui::TreeModel methods:
645 // Returns the set of icons for the nodes in the tree. You only need override 679 // 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. 680 // this if you don't want to use the default folder icons.
647 virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) OVERRIDE; 681 virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) OVERRIDE;
648 682
649 // Returns the index of the icon to use for |node|. Return -1 to use the 683 // 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 684 // default icon. The index is relative to the list of icons returned from
651 // GetIcons. 685 // GetIcons.
652 virtual int GetIconIndex(ui::TreeModelNode* node) OVERRIDE; 686 virtual int GetIconIndex(ui::TreeModelNode* node) OVERRIDE;
653 687
654 // CookiesTreeModel methods: 688 // CookiesTreeModel methods:
655 void DeleteAllStoredObjects(); 689 void DeleteAllStoredObjects();
690
691 // Deletes a specific node in the tree, identified by |cookie_node|, and its
692 // subtree.
656 void DeleteCookieNode(CookieTreeNode* cookie_node); 693 void DeleteCookieNode(CookieTreeNode* cookie_node);
657 694
658 // Filter the origins to only display matched results. 695 // Filter the origins to only display matched results.
659 void UpdateSearchResults(const std::wstring& filter); 696 void UpdateSearchResults(const string16& filter);
660 697
661 // Manages CookiesTreeModel::Observers. This will also call 698 // Manages CookiesTreeModel::Observers. This will also call
662 // TreeNodeModel::AddObserver so that it gets all the proper notifications. 699 // TreeNodeModel::AddObserver so that it gets all the proper notifications.
663 // Note that the converse is not true: simply adding a TreeModelObserver will 700 // Note that the converse is not true: simply adding a TreeModelObserver will
664 // not get CookiesTreeModel::Observer notifications. 701 // not get CookiesTreeModel::Observer notifications.
665 virtual void AddCookiesTreeObserver(Observer* observer); 702 virtual void AddCookiesTreeObserver(Observer* observer);
666 virtual void RemoveCookiesTreeObserver(Observer* observer); 703 virtual void RemoveCookiesTreeObserver(Observer* observer);
667 704
705 // Methods that update the model based on the data retrieved by the browsing
706 // data helpers.
707 void PopulateAppCacheInfo(LocalDataContainer* container);
708 void PopulateCookieInfo(LocalDataContainer* container);
709 void PopulateDatabaseInfo(LocalDataContainer* container);
710 void PopulateLocalStorageInfo(LocalDataContainer* container);
711 void PopulateSessionStorageInfo(LocalDataContainer* container);
712 void PopulateIndexedDBInfo(LocalDataContainer* container);
713 void PopulateFileSystemInfo(LocalDataContainer* container);
714 void PopulateQuotaInfo(LocalDataContainer* container);
715 void PopulateServerBoundCertInfo(LocalDataContainer* container);
716
717 BrowsingDataCookieHelper* GetCookieHelper(const std::string& app_id);
718 LocalDataContainer* GetLocalDataContainer(const std::string& app_id);
719
668 private: 720 private:
669 enum CookieIconIndex { 721 enum CookieIconIndex {
670 ORIGIN = 0, 722 ORIGIN = 0,
671 COOKIE = 1, 723 COOKIE = 1,
672 DATABASE = 2 724 DATABASE = 2
673 }; 725 };
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 726
712 void NotifyObserverBeginBatch(); 727 void NotifyObserverBeginBatch();
713 void NotifyObserverEndBatch(); 728 void NotifyObserverEndBatch();
714 729
715 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; 730 void PopulateAppCacheInfoWithFilter(LocalDataContainer* container,
716 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; 731 ScopedBatchUpdateNotifier& notifier,
Bernhard Bauer 2012/07/09 17:34:47 Could you pass in |notifier| as a pointer?
nasko 2012/07/09 18:17:34 Done.
717 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; 732 const string16& filter);
718 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; 733 void PopulateCookieInfoWithFilter(LocalDataContainer* container,
719 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; 734 ScopedBatchUpdateNotifier& notifier,
720 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; 735 const string16& filter);
721 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; 736 void PopulateDatabaseInfoWithFilter(LocalDataContainer* container,
722 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; 737 ScopedBatchUpdateNotifier& notifier,
723 scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_; 738 const string16& filter);
739 void PopulateLocalStorageInfoWithFilter(LocalDataContainer* container,
740 ScopedBatchUpdateNotifier& notifier,
741 const string16& filter);
742 void PopulateSessionStorageInfoWithFilter(LocalDataContainer* container,
743 ScopedBatchUpdateNotifier& notifier,
744 const string16& filter);
745 void PopulateIndexedDBInfoWithFilter(LocalDataContainer* container,
746 ScopedBatchUpdateNotifier& notifier,
747 const string16& filter);
748 void PopulateFileSystemInfoWithFilter(LocalDataContainer* container,
749 ScopedBatchUpdateNotifier& notifier,
750 const string16& filter);
751 void PopulateQuotaInfoWithFilter(LocalDataContainer* container,
752 ScopedBatchUpdateNotifier& notifier,
753 const string16& filter);
754 void PopulateServerBoundCertInfoWithFilter(
755 LocalDataContainer* container,
756 ScopedBatchUpdateNotifier& notifier,
757 const string16& filter);
724 758
725 std::map<GURL, std::list<appcache::AppCacheInfo> > appcache_info_; 759 // Map of app ids to LocalDataContainer objects to use when retrieving
726 CookieList cookie_list_; 760 // locally stored data.
727 DatabaseInfoList database_info_list_; 761 ContainerMap app_data_map_;
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 762
735 // The CookiesTreeModel maintains a separate list of observers that are 763 // The CookiesTreeModel maintains a separate list of observers that are
736 // specifically of the type CookiesTreeModel::Observer. 764 // specifically of the type CookiesTreeModel::Observer.
737 ObserverList<Observer> cookies_observer_list_; 765 ObserverList<Observer> cookies_observer_list_;
738 766
767 // If true, use the CanonicalCookie::Source attribute to group cookies.
768 // Otherwise, use the CanonicalCookie::Domain attribute.
769 bool group_by_cookie_source_;
770
739 // If this is non-zero, then this model is batching updates (there's a lot of 771 // 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 772 // 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. 773 // calls to Begin/EndBatch() if they're called in a nested manner.
742 int batch_update_; 774 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 }; 775 };
762 776
763 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ 777 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698