cookies_tree_model.h revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2010 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_COOKIES_TREE_MODEL_H_ 6#define CHROME_BROWSER_COOKIES_TREE_MODEL_H_ 7#pragma once 8 9// TODO(viettrungluu): This header file #includes far too much and has too much 10// inline code (which shouldn't be inline). 11 12#include <string> 13#include <vector> 14 15#include "app/tree_node_model.h" 16#include "base/observer_list.h" 17#include "base/ref_counted.h" 18#include "base/string16.h" 19#include "base/utf_string_conversions.h" 20#include "chrome/browser/browsing_data_appcache_helper.h" 21#include "chrome/browser/browsing_data_database_helper.h" 22#include "chrome/browser/browsing_data_indexed_db_helper.h" 23#include "chrome/browser/browsing_data_local_storage_helper.h" 24#include "net/base/cookie_monster.h" 25 26class CookiesTreeModel; 27class CookieTreeAppCacheNode; 28class CookieTreeAppCachesNode; 29class CookieTreeCookieNode; 30class CookieTreeCookiesNode; 31class CookieTreeDatabaseNode; 32class CookieTreeDatabasesNode; 33class CookieTreeLocalStorageNode; 34class CookieTreeLocalStoragesNode; 35class CookieTreeSessionStorageNode; 36class CookieTreeSessionStoragesNode; 37class CookieTreeIndexedDBNode; 38class CookieTreeIndexedDBsNode; 39class CookieTreeOriginNode; 40 41// CookieTreeNode ------------------------------------------------------------- 42// The base node type in the Cookies, Databases, and Local Storage options 43// view, from which all other types are derived. Specialized from TreeNode in 44// that it has a notion of deleting objects stored in the profile, and being 45// able to have its children do the same. 46class CookieTreeNode : public TreeNode<CookieTreeNode> { 47 public: 48 // Used to pull out information for the InfoView (the details display below 49 // the tree control.) 50 struct DetailedInfo { 51 // NodeType corresponds to the various CookieTreeNode types. 52 enum NodeType { 53 TYPE_ROOT, // This is used for CookieTreeRootNode nodes. 54 TYPE_ORIGIN, // This is used for CookieTreeOriginNode nodes. 55 TYPE_COOKIES, // This is used for CookieTreeCookiesNode nodes. 56 TYPE_COOKIE, // This is used for CookieTreeCookieNode nodes. 57 TYPE_DATABASES, // This is used for CookieTreeDatabasesNode. 58 TYPE_DATABASE, // This is used for CookieTreeDatabaseNode. 59 TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. 60 TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. 61 TYPE_SESSION_STORAGES, // This is used for CookieTreeSessionStoragesNode. 62 TYPE_SESSION_STORAGE, // This is used for CookieTreeSessionStorageNode. 63 TYPE_APPCACHES, // This is used for CookieTreeAppCachesNode. 64 TYPE_APPCACHE, // This is used for CookieTreeAppCacheNode. 65 TYPE_INDEXED_DBS, // This is used for CookieTreeIndexedDBsNode. 66 TYPE_INDEXED_DB, // This is used for CookieTreeIndexedDBNode. 67 }; 68 69 // TODO(viettrungluu): Figure out whether we want to store |origin| as a 70 // |string16| or a (UTF-8) |std::string|, and convert. Remove constructor 71 // taking an |std::wstring|. 72 DetailedInfo(const string16& origin, NodeType node_type, 73 const net::CookieMonster::CanonicalCookie* cookie, 74 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info, 75 const BrowsingDataLocalStorageHelper::LocalStorageInfo* 76 local_storage_info, 77 const BrowsingDataLocalStorageHelper::LocalStorageInfo* 78 session_storage_info, 79 const appcache::AppCacheInfo* appcache_info, 80 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info) 81 : origin(UTF16ToWideHack(origin)), 82 node_type(node_type), 83 cookie(cookie), 84 database_info(database_info), 85 local_storage_info(local_storage_info), 86 session_storage_info(session_storage_info), 87 appcache_info(appcache_info), 88 indexed_db_info(indexed_db_info) { 89 DCHECK((node_type != TYPE_DATABASE) || database_info); 90 DCHECK((node_type != TYPE_LOCAL_STORAGE) || local_storage_info); 91 DCHECK((node_type != TYPE_SESSION_STORAGE) || session_storage_info); 92 DCHECK((node_type != TYPE_APPCACHE) || appcache_info); 93 DCHECK((node_type != TYPE_INDEXED_DB) || indexed_db_info); 94 } 95#if !defined(WCHAR_T_IS_UTF16) 96 DetailedInfo(const std::wstring& origin, NodeType node_type, 97 const net::CookieMonster::CanonicalCookie* cookie, 98 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info, 99 const BrowsingDataLocalStorageHelper::LocalStorageInfo* 100 local_storage_info, 101 const BrowsingDataLocalStorageHelper::LocalStorageInfo* 102 session_storage_info, 103 const appcache::AppCacheInfo* appcache_info, 104 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info) 105 : origin(origin), 106 node_type(node_type), 107 cookie(cookie), 108 database_info(database_info), 109 local_storage_info(local_storage_info), 110 session_storage_info(session_storage_info), 111 appcache_info(appcache_info), 112 indexed_db_info(indexed_db_info) { 113 DCHECK((node_type != TYPE_DATABASE) || database_info); 114 DCHECK((node_type != TYPE_LOCAL_STORAGE) || local_storage_info); 115 DCHECK((node_type != TYPE_SESSION_STORAGE) || session_storage_info); 116 DCHECK((node_type != TYPE_APPCACHE) || appcache_info); 117 DCHECK((node_type != TYPE_INDEXED_DB) || indexed_db_info); 118 } 119#endif 120 121 std::wstring origin; 122 NodeType node_type; 123 const net::CookieMonster::CanonicalCookie* cookie; 124 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info; 125 const BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info; 126 const BrowsingDataLocalStorageHelper::LocalStorageInfo* 127 session_storage_info; 128 const appcache::AppCacheInfo* appcache_info; 129 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info; 130 }; 131 132 CookieTreeNode() {} 133 explicit CookieTreeNode(const string16& title) 134 : TreeNode<CookieTreeNode>(title) {} 135 virtual ~CookieTreeNode() {} 136 137 // Delete backend storage for this node, and any children nodes. (E.g. delete 138 // the cookie from CookieMonster, clear the database, and so forth.) 139 virtual void DeleteStoredObjects(); 140 141 // Gets a pointer back to the associated model for the tree we are in. 142 virtual CookiesTreeModel* GetModel() const; 143 144 // Returns a struct with detailed information used to populate the details 145 // part of the view. 146 virtual DetailedInfo GetDetailedInfo() const = 0; 147 148 protected: 149 class NodeTitleComparator { 150 public: 151 bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); 152 }; 153 154 void AddChildSortedByTitle(CookieTreeNode* new_child); 155 156 private: 157 158 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode); 159}; 160 161// CookieTreeRootNode --------------------------------------------------------- 162// The node at the root of the CookieTree that gets inserted into the view. 163class CookieTreeRootNode : public CookieTreeNode { 164 public: 165 explicit CookieTreeRootNode(CookiesTreeModel* model) : model_(model) {} 166 virtual ~CookieTreeRootNode() {} 167 168 CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); 169 170 // CookieTreeNode methods: 171 virtual CookiesTreeModel* GetModel() const { return model_; } 172 virtual DetailedInfo GetDetailedInfo() const { 173 return DetailedInfo(string16(), 174 DetailedInfo::TYPE_ROOT, 175 NULL, NULL, NULL, NULL, NULL, NULL); 176 } 177 private: 178 179 CookiesTreeModel* model_; 180 181 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); 182}; 183 184// CookieTreeOriginNode ------------------------------------------------------- 185class CookieTreeOriginNode : public CookieTreeNode { 186 public: 187 // Returns the origin node's title to use for a given URL. 188 static std::wstring TitleForUrl(const GURL& url); 189 190 explicit CookieTreeOriginNode(const GURL& url); 191 virtual ~CookieTreeOriginNode() {} 192 193 // CookieTreeNode methods: 194 virtual DetailedInfo GetDetailedInfo() const { 195 return DetailedInfo(GetTitle(), 196 DetailedInfo::TYPE_ORIGIN, 197 NULL, NULL, NULL, NULL, NULL, NULL); 198 } 199 200 // CookieTreeOriginNode methods: 201 CookieTreeCookiesNode* GetOrCreateCookiesNode(); 202 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); 203 CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); 204 CookieTreeSessionStoragesNode* GetOrCreateSessionStoragesNode(); 205 CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); 206 CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode(); 207 208 // Creates an content exception for this origin of type 209 // CONTENT_SETTINGS_TYPE_COOKIES. 210 void CreateContentException(HostContentSettingsMap* content_settings, 211 ContentSetting setting) const; 212 213 // True if a content exception can be created for this origin. 214 bool CanCreateContentException() const; 215 216 private: 217 // Pointers to the cookies, databases, local and session storage and appcache 218 // nodes. When we build up the tree we need to quickly get a reference to 219 // the COOKIES node to add children. Checking each child and interrogating 220 // them to see if they are a COOKIES, APPCACHES, DATABASES etc node seems 221 // less preferable than storing an extra pointer per origin. 222 CookieTreeCookiesNode* cookies_child_; 223 CookieTreeDatabasesNode* databases_child_; 224 CookieTreeLocalStoragesNode* local_storages_child_; 225 CookieTreeSessionStoragesNode* session_storages_child_; 226 CookieTreeAppCachesNode* appcaches_child_; 227 CookieTreeIndexedDBsNode* indexed_dbs_child_; 228 229 // The URL for which this node was initially created. 230 GURL url_; 231 232 DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); 233}; 234 235// CookieTreeCookieNode ------------------------------------------------------ 236class CookieTreeCookieNode : public CookieTreeNode { 237 public: 238 friend class CookieTreeCookiesNode; 239 240 // Does not take ownership of cookie, and cookie should remain valid at least 241 // as long as the CookieTreeCookieNode is valid. 242 explicit CookieTreeCookieNode(net::CookieMonster::CanonicalCookie* cookie); 243 virtual ~CookieTreeCookieNode() {} 244 245 // CookieTreeNode methods: 246 virtual void DeleteStoredObjects(); 247 virtual DetailedInfo GetDetailedInfo() const { 248 return DetailedInfo(GetParent()->GetParent()->GetTitle(), 249 DetailedInfo::TYPE_COOKIE, 250 cookie_, NULL, NULL, NULL, NULL, NULL); 251 } 252 253 private: 254 // Cookie_ is not owned by the node, and is expected to remain valid as long 255 // as the CookieTreeCookieNode is valid. 256 net::CookieMonster::CanonicalCookie* cookie_; 257 258 DISALLOW_COPY_AND_ASSIGN(CookieTreeCookieNode); 259}; 260 261class CookieTreeCookiesNode : public CookieTreeNode { 262 public: 263 CookieTreeCookiesNode(); 264 virtual ~CookieTreeCookiesNode() {} 265 266 virtual DetailedInfo GetDetailedInfo() const { 267 return DetailedInfo(GetParent()->GetTitle(), 268 DetailedInfo::TYPE_COOKIES, 269 NULL, NULL, NULL, NULL, NULL, NULL); 270 } 271 272 void AddCookieNode(CookieTreeCookieNode* child) { 273 AddChildSortedByTitle(child); 274 } 275 276 private: 277 DISALLOW_COPY_AND_ASSIGN(CookieTreeCookiesNode); 278}; 279 280// CookieTreeAppCacheNode ----------------------------------------------------- 281class CookieTreeAppCacheNode : public CookieTreeNode { 282 public: 283 friend class CookieTreeAppCachesNode; 284 285 // Does not take ownership of appcache_info, and appcache_info should remain 286 // valid at least as long as the CookieTreeAppCacheNode is valid. 287 explicit CookieTreeAppCacheNode( 288 const appcache::AppCacheInfo* appcache_info); 289 virtual ~CookieTreeAppCacheNode() {} 290 291 virtual void DeleteStoredObjects(); 292 virtual DetailedInfo GetDetailedInfo() const { 293 return DetailedInfo(GetParent()->GetParent()->GetTitle(), 294 DetailedInfo::TYPE_APPCACHE, 295 NULL, NULL, NULL, NULL, appcache_info_, NULL); 296 } 297 298 private: 299 const appcache::AppCacheInfo* appcache_info_; 300 DISALLOW_COPY_AND_ASSIGN(CookieTreeAppCacheNode); 301}; 302 303class CookieTreeAppCachesNode : public CookieTreeNode { 304 public: 305 CookieTreeAppCachesNode(); 306 virtual ~CookieTreeAppCachesNode() {} 307 308 virtual DetailedInfo GetDetailedInfo() const { 309 return DetailedInfo(GetParent()->GetTitle(), 310 DetailedInfo::TYPE_APPCACHES, 311 NULL, NULL, NULL, NULL, NULL, NULL); 312 } 313 314 void AddAppCacheNode(CookieTreeAppCacheNode* child) { 315 AddChildSortedByTitle(child); 316 } 317 318 private: 319 DISALLOW_COPY_AND_ASSIGN(CookieTreeAppCachesNode); 320}; 321 322// CookieTreeDatabaseNode ----------------------------------------------------- 323class CookieTreeDatabaseNode : public CookieTreeNode { 324 public: 325 friend class CookieTreeDatabasesNode; 326 327 // Does not take ownership of database_info, and database_info should remain 328 // valid at least as long as the CookieTreeDatabaseNode is valid. 329 explicit CookieTreeDatabaseNode( 330 BrowsingDataDatabaseHelper::DatabaseInfo* database_info); 331 virtual ~CookieTreeDatabaseNode() {} 332 333 virtual void DeleteStoredObjects(); 334 virtual DetailedInfo GetDetailedInfo() const { 335 return DetailedInfo(GetParent()->GetParent()->GetTitle(), 336 DetailedInfo::TYPE_DATABASE, 337 NULL, database_info_, NULL, NULL, NULL, NULL); 338 } 339 340 private: 341 // database_info_ is not owned by the node, and is expected to remain 342 // valid as long as the CookieTreeDatabaseNode is valid. 343 BrowsingDataDatabaseHelper::DatabaseInfo* database_info_; 344 345 DISALLOW_COPY_AND_ASSIGN(CookieTreeDatabaseNode); 346}; 347 348class CookieTreeDatabasesNode : public CookieTreeNode { 349 public: 350 CookieTreeDatabasesNode(); 351 virtual ~CookieTreeDatabasesNode() {} 352 353 virtual DetailedInfo GetDetailedInfo() const { 354 return DetailedInfo(GetParent()->GetTitle(), 355 DetailedInfo::TYPE_DATABASES, 356 NULL, NULL, NULL, NULL, NULL, NULL); 357 } 358 359 void AddDatabaseNode(CookieTreeDatabaseNode* child) { 360 AddChildSortedByTitle(child); 361 } 362 363 private: 364 DISALLOW_COPY_AND_ASSIGN(CookieTreeDatabasesNode); 365}; 366 367 368// CookieTreeLocalStorageNode ------------------------------------------------- 369class CookieTreeLocalStorageNode : public CookieTreeNode { 370 public: 371 // Does not take ownership of local_storage_info, and local_storage_info 372 // should remain valid at least as long as the CookieTreeLocalStorageNode is 373 // valid. 374 explicit CookieTreeLocalStorageNode( 375 BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info); 376 virtual ~CookieTreeLocalStorageNode() {} 377 378 // CookieTreeNode methods: 379 virtual void DeleteStoredObjects(); 380 virtual DetailedInfo GetDetailedInfo() const { 381 return DetailedInfo(GetParent()->GetParent()->GetTitle(), 382 DetailedInfo::TYPE_LOCAL_STORAGE, 383 NULL, NULL, local_storage_info_, NULL, NULL, NULL); 384 } 385 386 private: 387 // local_storage_info_ is not owned by the node, and is expected to remain 388 // valid as long as the CookieTreeLocalStorageNode is valid. 389 BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info_; 390 391 DISALLOW_COPY_AND_ASSIGN(CookieTreeLocalStorageNode); 392}; 393 394class CookieTreeLocalStoragesNode : public CookieTreeNode { 395 public: 396 CookieTreeLocalStoragesNode(); 397 virtual ~CookieTreeLocalStoragesNode() {} 398 399 virtual DetailedInfo GetDetailedInfo() const { 400 return DetailedInfo(GetParent()->GetTitle(), 401 DetailedInfo::TYPE_LOCAL_STORAGES, 402 NULL, NULL, NULL, NULL, NULL, NULL); 403 } 404 405 void AddLocalStorageNode(CookieTreeLocalStorageNode* child) { 406 AddChildSortedByTitle(child); 407 } 408 409 private: 410 411 DISALLOW_COPY_AND_ASSIGN(CookieTreeLocalStoragesNode); 412}; 413 414 415// CookieTreeSessionStorageNode ----------------------------------------------- 416class CookieTreeSessionStorageNode : public CookieTreeNode { 417 public: 418 // Does not take ownership of session_storage_info, and session_storage_info 419 // should remain valid at least as long as the CookieTreeSessionStorageNode 420 // is valid. 421 explicit CookieTreeSessionStorageNode( 422 BrowsingDataLocalStorageHelper::LocalStorageInfo* session_storage_info); 423 virtual ~CookieTreeSessionStorageNode() {} 424 425 // CookieTreeNode methods: 426 virtual DetailedInfo GetDetailedInfo() const { 427 return DetailedInfo(GetParent()->GetParent()->GetTitle(), 428 DetailedInfo::TYPE_SESSION_STORAGE, 429 NULL, NULL, NULL, session_storage_info_, NULL, NULL); 430 } 431 432 private: 433 // session_storage_info_ is not owned by the node, and is expected to remain 434 // valid as long as the CookieTreeSessionStorageNode is valid. 435 BrowsingDataLocalStorageHelper::LocalStorageInfo* session_storage_info_; 436 437 DISALLOW_COPY_AND_ASSIGN(CookieTreeSessionStorageNode); 438}; 439 440class CookieTreeSessionStoragesNode : public CookieTreeNode { 441 public: 442 CookieTreeSessionStoragesNode(); 443 virtual ~CookieTreeSessionStoragesNode() {} 444 445 virtual DetailedInfo GetDetailedInfo() const { 446 return DetailedInfo(GetParent()->GetTitle(), 447 DetailedInfo::TYPE_SESSION_STORAGES, 448 NULL, NULL, NULL, NULL, NULL, NULL); 449 } 450 451 void AddSessionStorageNode(CookieTreeSessionStorageNode* child) { 452 AddChildSortedByTitle(child); 453 } 454 455 private: 456 457 DISALLOW_COPY_AND_ASSIGN(CookieTreeSessionStoragesNode); 458}; 459 460// CookieTreeIndexedDBNode ----------------------------------------------- 461class CookieTreeIndexedDBNode : public CookieTreeNode { 462 public: 463 // Does not take ownership of session_storage_info, and session_storage_info 464 // should remain valid at least as long as the CookieTreeSessionStorageNode 465 // is valid. 466 explicit CookieTreeIndexedDBNode( 467 BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info); 468 virtual ~CookieTreeIndexedDBNode() {} 469 470 // CookieTreeNode methods: 471 virtual void DeleteStoredObjects(); 472 virtual DetailedInfo GetDetailedInfo() const { 473 return DetailedInfo(GetParent()->GetParent()->GetTitle(), 474 DetailedInfo::TYPE_INDEXED_DB, 475 NULL, NULL, NULL, NULL, NULL, indexed_db_info_); 476 } 477 478 private: 479 // indexed_db_info_ is not owned by the node, and is expected to remain 480 // valid as long as the CookieTreeIndexedDBNode is valid. 481 BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info_; 482 483 DISALLOW_COPY_AND_ASSIGN(CookieTreeIndexedDBNode); 484}; 485 486class CookieTreeIndexedDBsNode : public CookieTreeNode { 487 public: 488 CookieTreeIndexedDBsNode(); 489 virtual ~CookieTreeIndexedDBsNode() {} 490 491 virtual DetailedInfo GetDetailedInfo() const { 492 return DetailedInfo(GetParent()->GetTitle(), 493 DetailedInfo::TYPE_INDEXED_DBS, 494 NULL, NULL, NULL, NULL, NULL, NULL); 495 } 496 497 void AddIndexedDBNode(CookieTreeIndexedDBNode* child) { 498 AddChildSortedByTitle(child); 499 } 500 501 private: 502 DISALLOW_COPY_AND_ASSIGN(CookieTreeIndexedDBsNode); 503}; 504 505 506// CookiesTreeModel ----------------------------------------------------------- 507class CookiesTreeModel : public TreeNodeModel<CookieTreeNode> { 508 public: 509 // Because non-cookie nodes are fetched in a background thread, they are not 510 // present at the time the Model is created. The Model then notifies its 511 // observers for every item added from databases, local storage, and 512 // appcache. We extend the Observer interface to add notifications before and 513 // after these batch inserts. 514 class Observer : public TreeModelObserver { 515 public: 516 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} 517 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} 518 }; 519 520 CookiesTreeModel( 521 net::CookieMonster* cookie_monster_, 522 BrowsingDataDatabaseHelper* database_helper, 523 BrowsingDataLocalStorageHelper* local_storage_helper, 524 BrowsingDataLocalStorageHelper* session_storage_helper, 525 BrowsingDataAppCacheHelper* appcache_helper, 526 BrowsingDataIndexedDBHelper* indexed_db_helper); 527 virtual ~CookiesTreeModel(); 528 529 // TreeModel methods: 530 // Returns the set of icons for the nodes in the tree. You only need override 531 // this if you don't want to use the default folder icons. 532 virtual void GetIcons(std::vector<SkBitmap>* icons); 533 534 // Returns the index of the icon to use for |node|. Return -1 to use the 535 // default icon. The index is relative to the list of icons returned from 536 // GetIcons. 537 virtual int GetIconIndex(TreeModelNode* node); 538 539 // CookiesTreeModel methods: 540 void DeleteAllStoredObjects(); 541 void DeleteCookieNode(CookieTreeNode* cookie_node); 542 543 // Filter the origins to only display matched results. 544 void UpdateSearchResults(const std::wstring& filter); 545 546 // Overload the Add/Remove observer methods so we can notify about 547 // CookiesTreeModel-specific things. Note that this is NOT overriding the 548 // method by the same name in TreeNodeModel because the argument type is 549 // different. Therefore, if this AddObserver(TreeModelObserver*) is called, 550 // the observer will NOT be notified about batching. This is also why we 551 // maintain a separate list of observers that are specifically Observer* 552 // objects. 553 virtual void AddObserver(Observer* observer); 554 virtual void RemoveObserver(Observer* observer); 555 556 private: 557 enum CookieIconIndex { 558 ORIGIN = 0, 559 COOKIE = 1, 560 DATABASE = 2 561 }; 562 typedef net::CookieMonster::CookieList CookieList; 563 typedef std::vector<BrowsingDataDatabaseHelper::DatabaseInfo> 564 DatabaseInfoList; 565 typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> 566 LocalStorageInfoList; 567 typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> 568 SessionStorageInfoList; 569 typedef std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> 570 IndexedDBInfoList; 571 572 void LoadCookies(); 573 void LoadCookiesWithFilter(const std::wstring& filter); 574 575 void OnAppCacheModelInfoLoaded(); 576 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); 577 void OnLocalStorageModelInfoLoaded( 578 const LocalStorageInfoList& local_storage_info); 579 void OnSessionStorageModelInfoLoaded( 580 const LocalStorageInfoList& local_storage_info); 581 void OnIndexedDBModelInfoLoaded( 582 const IndexedDBInfoList& indexed_db_info); 583 584 void PopulateAppCacheInfoWithFilter(const std::wstring& filter); 585 void PopulateDatabaseInfoWithFilter(const std::wstring& filter); 586 void PopulateLocalStorageInfoWithFilter(const std::wstring& filter); 587 void PopulateSessionStorageInfoWithFilter(const std::wstring& filter); 588 void PopulateIndexedDBInfoWithFilter(const std::wstring& filter); 589 590 void NotifyObserverBeginBatch(); 591 void NotifyObserverEndBatch(); 592 593 scoped_refptr<net::CookieMonster> cookie_monster_; 594 CookieList all_cookies_; 595 596 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; 597 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; 598 scoped_refptr<appcache::AppCacheInfoCollection> appcache_info_; 599 DatabaseInfoList database_info_list_; 600 601 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; 602 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; 603 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; 604 LocalStorageInfoList local_storage_info_list_; 605 LocalStorageInfoList session_storage_info_list_; 606 IndexedDBInfoList indexed_db_info_list_; 607 608 // The CookiesTreeModel maintains a separate list of observers that are 609 // specifically of the type CookiesTreeModel::Observer. 610 ObserverList<Observer> cookies_observer_list_; 611 612 // If this is non-zero, then this model is batching updates (there's a lot of 613 // notifications coming down the pipe). This is an integer is used to balance 614 // calls to Begin/EndBatch() if they're called in a nested manner. 615 int batch_update_; 616 617 friend class CookieTreeAppCacheNode; 618 friend class CookieTreeCookieNode; 619 friend class CookieTreeDatabaseNode; 620 friend class CookieTreeLocalStorageNode; 621 friend class CookieTreeIndexedDBNode; 622 623 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); 624}; 625 626#endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ 627