| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/string16.h" | 17 #include "base/string16.h" |
| 18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 19 #include "chrome/browser/browsing_data_appcache_helper.h" | 19 #include "chrome/browser/browsing_data_appcache_helper.h" |
| 20 #include "chrome/browser/browsing_data_database_helper.h" | 20 #include "chrome/browser/browsing_data_database_helper.h" |
| 21 #include "chrome/browser/browsing_data_file_system_helper.h" | 21 #include "chrome/browser/browsing_data_file_system_helper.h" |
| 22 #include "chrome/browser/browsing_data_indexed_db_helper.h" | 22 #include "chrome/browser/browsing_data_indexed_db_helper.h" |
| 23 #include "chrome/browser/browsing_data_local_storage_helper.h" | 23 #include "chrome/browser/browsing_data_local_storage_helper.h" |
| 24 #include "chrome/browser/browsing_data_quota_helper.h" | |
| 25 #include "chrome/common/content_settings.h" | 24 #include "chrome/common/content_settings.h" |
| 26 #include "net/base/cookie_monster.h" | 25 #include "net/base/cookie_monster.h" |
| 27 #include "ui/base/models/tree_node_model.h" | 26 #include "ui/base/models/tree_node_model.h" |
| 28 | 27 |
| 29 class CookiesTreeModel; | 28 class CookiesTreeModel; |
| 30 class CookieTreeAppCacheNode; | 29 class CookieTreeAppCacheNode; |
| 31 class CookieTreeAppCachesNode; | 30 class CookieTreeAppCachesNode; |
| 32 class CookieTreeCookieNode; | 31 class CookieTreeCookieNode; |
| 33 class CookieTreeCookiesNode; | 32 class CookieTreeCookiesNode; |
| 34 class CookieTreeDatabaseNode; | 33 class CookieTreeDatabaseNode; |
| 35 class CookieTreeDatabasesNode; | 34 class CookieTreeDatabasesNode; |
| 36 class CookieTreeFileSystemsNode; | 35 class CookieTreeFileSystemsNode; |
| 37 class CookieTreeFileSystemNode; | 36 class CookieTreeFileSystemNode; |
| 38 class CookieTreeLocalStorageNode; | 37 class CookieTreeLocalStorageNode; |
| 39 class CookieTreeLocalStoragesNode; | 38 class CookieTreeLocalStoragesNode; |
| 40 class CookieTreeQuotaNode; | |
| 41 class CookieTreeSessionStorageNode; | 39 class CookieTreeSessionStorageNode; |
| 42 class CookieTreeSessionStoragesNode; | 40 class CookieTreeSessionStoragesNode; |
| 43 class CookieTreeIndexedDBNode; | 41 class CookieTreeIndexedDBNode; |
| 44 class CookieTreeIndexedDBsNode; | 42 class CookieTreeIndexedDBsNode; |
| 45 class CookieTreeOriginNode; | 43 class CookieTreeOriginNode; |
| 46 class HostContentSettingsMap; | 44 class HostContentSettingsMap; |
| 47 | 45 |
| 48 // CookieTreeNode ------------------------------------------------------------- | 46 // CookieTreeNode ------------------------------------------------------------- |
| 49 // The base node type in the Cookies, Databases, and Local Storage options | 47 // The base node type in the Cookies, Databases, and Local Storage options |
| 50 // view, from which all other types are derived. Specialized from TreeNode in | 48 // view, from which all other types are derived. Specialized from TreeNode in |
| (...skipping 13 matching lines...) Expand all Loading... |
| 64 TYPE_DATABASES, // This is used for CookieTreeDatabasesNode. | 62 TYPE_DATABASES, // This is used for CookieTreeDatabasesNode. |
| 65 TYPE_DATABASE, // This is used for CookieTreeDatabaseNode. | 63 TYPE_DATABASE, // This is used for CookieTreeDatabaseNode. |
| 66 TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. | 64 TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. |
| 67 TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. | 65 TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. |
| 68 TYPE_SESSION_STORAGES, // This is used for CookieTreeSessionStoragesNode. | 66 TYPE_SESSION_STORAGES, // This is used for CookieTreeSessionStoragesNode. |
| 69 TYPE_SESSION_STORAGE, // This is used for CookieTreeSessionStorageNode. | 67 TYPE_SESSION_STORAGE, // This is used for CookieTreeSessionStorageNode. |
| 70 TYPE_APPCACHES, // This is used for CookieTreeAppCachesNode. | 68 TYPE_APPCACHES, // This is used for CookieTreeAppCachesNode. |
| 71 TYPE_APPCACHE, // This is used for CookieTreeAppCacheNode. | 69 TYPE_APPCACHE, // This is used for CookieTreeAppCacheNode. |
| 72 TYPE_INDEXED_DBS, // This is used for CookieTreeIndexedDBsNode. | 70 TYPE_INDEXED_DBS, // This is used for CookieTreeIndexedDBsNode. |
| 73 TYPE_INDEXED_DB, // This is used for CookieTreeIndexedDBNode. | 71 TYPE_INDEXED_DB, // This is used for CookieTreeIndexedDBNode. |
| 74 TYPE_FILE_SYSTEMS, // This is used for CookieTreeFileSystemsNode. | 72 TYPE_FILE_SYSTEMS, // This is used for CookieTreeFileSystemsNode. |
| 75 TYPE_FILE_SYSTEM, // This is used for CookieTreeFileSystemNode. | 73 TYPE_FILE_SYSTEM, // This is used for CookieTreeFileSystemNode. |
| 76 TYPE_QUOTA, // This is used for CookieTreeQuotaNode. | |
| 77 }; | 74 }; |
| 78 | 75 |
| 79 // TODO(viettrungluu): Figure out whether we want to store |origin| as a | 76 // TODO(viettrungluu): Figure out whether we want to store |origin| as a |
| 80 // |string16| or a (UTF-8) |std::string|, and convert. Remove constructor | 77 // |string16| or a (UTF-8) |std::string|, and convert. Remove constructor |
| 81 // taking an |std::wstring|. | 78 // taking an |std::wstring|. |
| 82 DetailedInfo(const string16& origin, NodeType node_type, | 79 DetailedInfo(const string16& origin, NodeType node_type, |
| 83 const net::CookieMonster::CanonicalCookie* cookie, | 80 const net::CookieMonster::CanonicalCookie* cookie, |
| 84 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info, | 81 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info, |
| 85 const BrowsingDataLocalStorageHelper::LocalStorageInfo* | 82 const BrowsingDataLocalStorageHelper::LocalStorageInfo* |
| 86 local_storage_info, | 83 local_storage_info, |
| 87 const BrowsingDataLocalStorageHelper::LocalStorageInfo* | 84 const BrowsingDataLocalStorageHelper::LocalStorageInfo* |
| 88 session_storage_info, | 85 session_storage_info, |
| 89 const appcache::AppCacheInfo* appcache_info, | 86 const appcache::AppCacheInfo* appcache_info, |
| 90 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info, | 87 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info, |
| 91 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info, | 88 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info) |
| 92 const BrowsingDataQuotaHelper::QuotaInfo* quota_info) | |
| 93 : origin(UTF16ToWideHack(origin)), | 89 : origin(UTF16ToWideHack(origin)), |
| 94 node_type(node_type), | 90 node_type(node_type), |
| 95 cookie(cookie), | 91 cookie(cookie), |
| 96 database_info(database_info), | 92 database_info(database_info), |
| 97 local_storage_info(local_storage_info), | 93 local_storage_info(local_storage_info), |
| 98 session_storage_info(session_storage_info), | 94 session_storage_info(session_storage_info), |
| 99 appcache_info(appcache_info), | 95 appcache_info(appcache_info), |
| 100 indexed_db_info(indexed_db_info), | 96 indexed_db_info(indexed_db_info), |
| 101 file_system_info(file_system_info), | 97 file_system_info(file_system_info) { |
| 102 quota_info(quota_info) { | |
| 103 DCHECK((node_type != TYPE_DATABASE) || database_info); | 98 DCHECK((node_type != TYPE_DATABASE) || database_info); |
| 104 DCHECK((node_type != TYPE_LOCAL_STORAGE) || local_storage_info); | 99 DCHECK((node_type != TYPE_LOCAL_STORAGE) || local_storage_info); |
| 105 DCHECK((node_type != TYPE_SESSION_STORAGE) || session_storage_info); | 100 DCHECK((node_type != TYPE_SESSION_STORAGE) || session_storage_info); |
| 106 DCHECK((node_type != TYPE_APPCACHE) || appcache_info); | 101 DCHECK((node_type != TYPE_APPCACHE) || appcache_info); |
| 107 DCHECK((node_type != TYPE_INDEXED_DB) || indexed_db_info); | 102 DCHECK((node_type != TYPE_INDEXED_DB) || indexed_db_info); |
| 108 DCHECK((node_type != TYPE_FILE_SYSTEM) || file_system_info); | 103 DCHECK((node_type != TYPE_FILE_SYSTEM) || file_system_info); |
| 109 DCHECK((node_type != TYPE_QUOTA) || quota_info); | |
| 110 } | 104 } |
| 111 #if !defined(WCHAR_T_IS_UTF16) | 105 #if !defined(WCHAR_T_IS_UTF16) |
| 112 DetailedInfo(const std::wstring& origin, NodeType node_type, | 106 DetailedInfo(const std::wstring& origin, NodeType node_type, |
| 113 const net::CookieMonster::CanonicalCookie* cookie, | 107 const net::CookieMonster::CanonicalCookie* cookie, |
| 114 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info, | 108 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info, |
| 115 const BrowsingDataLocalStorageHelper::LocalStorageInfo* | 109 const BrowsingDataLocalStorageHelper::LocalStorageInfo* |
| 116 local_storage_info, | 110 local_storage_info, |
| 117 const BrowsingDataLocalStorageHelper::LocalStorageInfo* | 111 const BrowsingDataLocalStorageHelper::LocalStorageInfo* |
| 118 session_storage_info, | 112 session_storage_info, |
| 119 const appcache::AppCacheInfo* appcache_info, | 113 const appcache::AppCacheInfo* appcache_info, |
| 120 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info, | 114 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info, |
| 121 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info, | 115 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info) |
| 122 const BrowsingDataQuotaHelper::QuotaInfo* quota_info) | |
| 123 : origin(origin), | 116 : origin(origin), |
| 124 node_type(node_type), | 117 node_type(node_type), |
| 125 cookie(cookie), | 118 cookie(cookie), |
| 126 database_info(database_info), | 119 database_info(database_info), |
| 127 local_storage_info(local_storage_info), | 120 local_storage_info(local_storage_info), |
| 128 session_storage_info(session_storage_info), | 121 session_storage_info(session_storage_info), |
| 129 appcache_info(appcache_info), | 122 appcache_info(appcache_info), |
| 130 indexed_db_info(indexed_db_info), | 123 indexed_db_info(indexed_db_info), |
| 131 file_system_info(file_system_info), | 124 file_system_info(file_system_info) { |
| 132 quota_info(quota_info) { | |
| 133 DCHECK((node_type != TYPE_DATABASE) || database_info); | 125 DCHECK((node_type != TYPE_DATABASE) || database_info); |
| 134 DCHECK((node_type != TYPE_LOCAL_STORAGE) || local_storage_info); | 126 DCHECK((node_type != TYPE_LOCAL_STORAGE) || local_storage_info); |
| 135 DCHECK((node_type != TYPE_SESSION_STORAGE) || session_storage_info); | 127 DCHECK((node_type != TYPE_SESSION_STORAGE) || session_storage_info); |
| 136 DCHECK((node_type != TYPE_APPCACHE) || appcache_info); | 128 DCHECK((node_type != TYPE_APPCACHE) || appcache_info); |
| 137 DCHECK((node_type != TYPE_INDEXED_DB) || indexed_db_info); | 129 DCHECK((node_type != TYPE_INDEXED_DB) || indexed_db_info); |
| 138 DCHECK((node_type != TYPE_FILE_SYSTEM) || file_system_info); | 130 DCHECK((node_type != TYPE_FILE_SYSTEM) || file_system_info); |
| 139 DCHECK((node_type != TYPE_QUOTA) || quota_info); | |
| 140 } | 131 } |
| 141 #endif | 132 #endif |
| 142 | 133 |
| 143 std::wstring origin; | 134 std::wstring origin; |
| 144 NodeType node_type; | 135 NodeType node_type; |
| 145 const net::CookieMonster::CanonicalCookie* cookie; | 136 const net::CookieMonster::CanonicalCookie* cookie; |
| 146 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info; | 137 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info; |
| 147 const BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info; | 138 const BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info; |
| 148 const BrowsingDataLocalStorageHelper::LocalStorageInfo* | 139 const BrowsingDataLocalStorageHelper::LocalStorageInfo* |
| 149 session_storage_info; | 140 session_storage_info; |
| 150 const appcache::AppCacheInfo* appcache_info; | 141 const appcache::AppCacheInfo* appcache_info; |
| 151 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info; | 142 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info; |
| 152 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info; | 143 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info; |
| 153 const BrowsingDataQuotaHelper::QuotaInfo* quota_info; | |
| 154 }; | 144 }; |
| 155 | 145 |
| 156 CookieTreeNode() {} | 146 CookieTreeNode() {} |
| 157 explicit CookieTreeNode(const string16& title) | 147 explicit CookieTreeNode(const string16& title) |
| 158 : ui::TreeNode<CookieTreeNode>(title) {} | 148 : ui::TreeNode<CookieTreeNode>(title) {} |
| 159 virtual ~CookieTreeNode() {} | 149 virtual ~CookieTreeNode() {} |
| 160 | 150 |
| 161 // Delete backend storage for this node, and any children nodes. (E.g. delete | 151 // Delete backend storage for this node, and any children nodes. (E.g. delete |
| 162 // the cookie from CookieMonster, clear the database, and so forth.) | 152 // the cookie from CookieMonster, clear the database, and so forth.) |
| 163 virtual void DeleteStoredObjects(); | 153 virtual void DeleteStoredObjects(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 virtual DetailedInfo GetDetailedInfo() const; | 204 virtual DetailedInfo GetDetailedInfo() const; |
| 215 | 205 |
| 216 // CookieTreeOriginNode methods: | 206 // CookieTreeOriginNode methods: |
| 217 CookieTreeCookiesNode* GetOrCreateCookiesNode(); | 207 CookieTreeCookiesNode* GetOrCreateCookiesNode(); |
| 218 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); | 208 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); |
| 219 CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); | 209 CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); |
| 220 CookieTreeSessionStoragesNode* GetOrCreateSessionStoragesNode(); | 210 CookieTreeSessionStoragesNode* GetOrCreateSessionStoragesNode(); |
| 221 CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); | 211 CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); |
| 222 CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode(); | 212 CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode(); |
| 223 CookieTreeFileSystemsNode* GetOrCreateFileSystemsNode(); | 213 CookieTreeFileSystemsNode* GetOrCreateFileSystemsNode(); |
| 224 CookieTreeQuotaNode* UpdateOrCreateQuotaNode( | |
| 225 BrowsingDataQuotaHelper::QuotaInfo* quota_info); | |
| 226 | 214 |
| 227 // Creates an content exception for this origin of type | 215 // Creates an content exception for this origin of type |
| 228 // CONTENT_SETTINGS_TYPE_COOKIES. | 216 // CONTENT_SETTINGS_TYPE_COOKIES. |
| 229 void CreateContentException(HostContentSettingsMap* content_settings, | 217 void CreateContentException(HostContentSettingsMap* content_settings, |
| 230 ContentSetting setting) const; | 218 ContentSetting setting) const; |
| 231 | 219 |
| 232 // True if a content exception can be created for this origin. | 220 // True if a content exception can be created for this origin. |
| 233 bool CanCreateContentException() const; | 221 bool CanCreateContentException() const; |
| 234 | 222 |
| 235 private: | 223 private: |
| 236 // Pointers to the cookies, databases, local and session storage and appcache | 224 // Pointers to the cookies, databases, local and session storage and appcache |
| 237 // nodes. When we build up the tree we need to quickly get a reference to | 225 // nodes. When we build up the tree we need to quickly get a reference to |
| 238 // the COOKIES node to add children. Checking each child and interrogating | 226 // the COOKIES node to add children. Checking each child and interrogating |
| 239 // them to see if they are a COOKIES, APPCACHES, DATABASES etc node seems | 227 // them to see if they are a COOKIES, APPCACHES, DATABASES etc node seems |
| 240 // less preferable than storing an extra pointer per origin. | 228 // less preferable than storing an extra pointer per origin. |
| 241 CookieTreeCookiesNode* cookies_child_; | 229 CookieTreeCookiesNode* cookies_child_; |
| 242 CookieTreeDatabasesNode* databases_child_; | 230 CookieTreeDatabasesNode* databases_child_; |
| 243 CookieTreeLocalStoragesNode* local_storages_child_; | 231 CookieTreeLocalStoragesNode* local_storages_child_; |
| 244 CookieTreeSessionStoragesNode* session_storages_child_; | 232 CookieTreeSessionStoragesNode* session_storages_child_; |
| 245 CookieTreeAppCachesNode* appcaches_child_; | 233 CookieTreeAppCachesNode* appcaches_child_; |
| 246 CookieTreeIndexedDBsNode* indexed_dbs_child_; | 234 CookieTreeIndexedDBsNode* indexed_dbs_child_; |
| 247 CookieTreeFileSystemsNode* file_systems_child_; | 235 CookieTreeFileSystemsNode* file_systems_child_; |
| 248 CookieTreeQuotaNode* quota_child_; | |
| 249 | 236 |
| 250 // The URL for which this node was initially created. | 237 // The URL for which this node was initially created. |
| 251 GURL url_; | 238 GURL url_; |
| 252 | 239 |
| 253 DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); | 240 DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); |
| 254 }; | 241 }; |
| 255 | 242 |
| 256 // CookieTreeCookieNode ------------------------------------------------------ | 243 // CookieTreeCookieNode ------------------------------------------------------ |
| 257 class CookieTreeCookieNode : public CookieTreeNode { | 244 class CookieTreeCookieNode : public CookieTreeNode { |
| 258 public: | 245 public: |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 virtual DetailedInfo GetDetailedInfo() const; | 491 virtual DetailedInfo GetDetailedInfo() const; |
| 505 | 492 |
| 506 void AddIndexedDBNode(CookieTreeIndexedDBNode* child) { | 493 void AddIndexedDBNode(CookieTreeIndexedDBNode* child) { |
| 507 AddChildSortedByTitle(child); | 494 AddChildSortedByTitle(child); |
| 508 } | 495 } |
| 509 | 496 |
| 510 private: | 497 private: |
| 511 DISALLOW_COPY_AND_ASSIGN(CookieTreeIndexedDBsNode); | 498 DISALLOW_COPY_AND_ASSIGN(CookieTreeIndexedDBsNode); |
| 512 }; | 499 }; |
| 513 | 500 |
| 514 // CookieTreeQuotaNode -------------------------------------------------- | |
| 515 class CookieTreeQuotaNode : public CookieTreeNode { | |
| 516 public: | |
| 517 // Does not take ownership of quota_info, and quota_info should remain valid | |
| 518 // at least as long as the CookieTreeQuotaNode is valid. | |
| 519 explicit CookieTreeQuotaNode(BrowsingDataQuotaHelper::QuotaInfo* quota_info); | |
| 520 virtual ~CookieTreeQuotaNode(); | |
| 521 | |
| 522 virtual void DeleteStoredObjects(); | |
| 523 virtual DetailedInfo GetDetailedInfo() const; | |
| 524 | |
| 525 private: | |
| 526 // quota_info_ is not owned by the node, and is expected to remain valid as | |
| 527 // long as the CookieTreeQuotaNode is valid. | |
| 528 BrowsingDataQuotaHelper::QuotaInfo* quota_info_; | |
| 529 | |
| 530 DISALLOW_COPY_AND_ASSIGN(CookieTreeQuotaNode); | |
| 531 }; | |
| 532 | 501 |
| 533 // CookiesTreeModel ----------------------------------------------------------- | 502 // CookiesTreeModel ----------------------------------------------------------- |
| 534 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { | 503 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
| 535 public: | 504 public: |
| 536 // Because non-cookie nodes are fetched in a background thread, they are not | 505 // Because non-cookie nodes are fetched in a background thread, they are not |
| 537 // present at the time the Model is created. The Model then notifies its | 506 // present at the time the Model is created. The Model then notifies its |
| 538 // observers for every item added from databases, local storage, and | 507 // observers for every item added from databases, local storage, and |
| 539 // appcache. We extend the Observer interface to add notifications before and | 508 // appcache. We extend the Observer interface to add notifications before and |
| 540 // after these batch inserts. | 509 // after these batch inserts. |
| 541 class Observer : public ui::TreeModelObserver { | 510 class Observer : public ui::TreeModelObserver { |
| 542 public: | 511 public: |
| 543 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} | 512 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} |
| 544 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} | 513 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} |
| 545 }; | 514 }; |
| 546 | 515 |
| 547 CookiesTreeModel( | 516 CookiesTreeModel( |
| 548 net::CookieMonster* cookie_monster_, | 517 net::CookieMonster* cookie_monster_, |
| 549 BrowsingDataDatabaseHelper* database_helper, | 518 BrowsingDataDatabaseHelper* database_helper, |
| 550 BrowsingDataLocalStorageHelper* local_storage_helper, | 519 BrowsingDataLocalStorageHelper* local_storage_helper, |
| 551 BrowsingDataLocalStorageHelper* session_storage_helper, | 520 BrowsingDataLocalStorageHelper* session_storage_helper, |
| 552 BrowsingDataAppCacheHelper* appcache_helper, | 521 BrowsingDataAppCacheHelper* appcache_helper, |
| 553 BrowsingDataIndexedDBHelper* indexed_db_helper, | 522 BrowsingDataIndexedDBHelper* indexed_db_helper, |
| 554 BrowsingDataFileSystemHelper* file_system_helper, | 523 BrowsingDataFileSystemHelper* file_system_helper, |
| 555 BrowsingDataQuotaHelper* quota_helper, | |
| 556 bool use_cookie_source); | 524 bool use_cookie_source); |
| 557 virtual ~CookiesTreeModel(); | 525 virtual ~CookiesTreeModel(); |
| 558 | 526 |
| 559 // ui::TreeModel methods: | 527 // ui::TreeModel methods: |
| 560 // Returns the set of icons for the nodes in the tree. You only need override | 528 // Returns the set of icons for the nodes in the tree. You only need override |
| 561 // this if you don't want to use the default folder icons. | 529 // this if you don't want to use the default folder icons. |
| 562 virtual void GetIcons(std::vector<SkBitmap>* icons); | 530 virtual void GetIcons(std::vector<SkBitmap>* icons); |
| 563 | 531 |
| 564 // Returns the index of the icon to use for |node|. Return -1 to use the | 532 // Returns the index of the icon to use for |node|. Return -1 to use the |
| 565 // default icon. The index is relative to the list of icons returned from | 533 // default icon. The index is relative to the list of icons returned from |
| (...skipping 24 matching lines...) Expand all Loading... |
| 590 typedef std::vector<BrowsingDataDatabaseHelper::DatabaseInfo> | 558 typedef std::vector<BrowsingDataDatabaseHelper::DatabaseInfo> |
| 591 DatabaseInfoList; | 559 DatabaseInfoList; |
| 592 typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> | 560 typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
| 593 LocalStorageInfoList; | 561 LocalStorageInfoList; |
| 594 typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> | 562 typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
| 595 SessionStorageInfoList; | 563 SessionStorageInfoList; |
| 596 typedef std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> | 564 typedef std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> |
| 597 IndexedDBInfoList; | 565 IndexedDBInfoList; |
| 598 typedef std::vector<BrowsingDataFileSystemHelper::FileSystemInfo> | 566 typedef std::vector<BrowsingDataFileSystemHelper::FileSystemInfo> |
| 599 FileSystemInfoList; | 567 FileSystemInfoList; |
| 600 typedef std::vector<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoArray; | |
| 601 | 568 |
| 602 void LoadCookies(); | 569 void LoadCookies(); |
| 603 void LoadCookiesWithFilter(const std::wstring& filter); | 570 void LoadCookiesWithFilter(const std::wstring& filter); |
| 604 | 571 |
| 605 void OnAppCacheModelInfoLoaded(); | 572 void OnAppCacheModelInfoLoaded(); |
| 606 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); | 573 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); |
| 607 void OnLocalStorageModelInfoLoaded( | 574 void OnLocalStorageModelInfoLoaded( |
| 608 const LocalStorageInfoList& local_storage_info); | 575 const LocalStorageInfoList& local_storage_info); |
| 609 void OnSessionStorageModelInfoLoaded( | 576 void OnSessionStorageModelInfoLoaded( |
| 610 const LocalStorageInfoList& local_storage_info); | 577 const LocalStorageInfoList& local_storage_info); |
| 611 void OnIndexedDBModelInfoLoaded( | 578 void OnIndexedDBModelInfoLoaded( |
| 612 const IndexedDBInfoList& indexed_db_info); | 579 const IndexedDBInfoList& indexed_db_info); |
| 613 void OnFileSystemModelInfoLoaded( | 580 void OnFileSystemModelInfoLoaded( |
| 614 const FileSystemInfoList& file_system_info); | 581 const FileSystemInfoList& file_system_info); |
| 615 void OnQuotaModelInfoLoaded(const QuotaInfoArray& quota_info); | |
| 616 | 582 |
| 617 void PopulateAppCacheInfoWithFilter(const std::wstring& filter); | 583 void PopulateAppCacheInfoWithFilter(const std::wstring& filter); |
| 618 void PopulateDatabaseInfoWithFilter(const std::wstring& filter); | 584 void PopulateDatabaseInfoWithFilter(const std::wstring& filter); |
| 619 void PopulateLocalStorageInfoWithFilter(const std::wstring& filter); | 585 void PopulateLocalStorageInfoWithFilter(const std::wstring& filter); |
| 620 void PopulateSessionStorageInfoWithFilter(const std::wstring& filter); | 586 void PopulateSessionStorageInfoWithFilter(const std::wstring& filter); |
| 621 void PopulateIndexedDBInfoWithFilter(const std::wstring& filter); | 587 void PopulateIndexedDBInfoWithFilter(const std::wstring& filter); |
| 622 void PopulateFileSystemInfoWithFilter(const std::wstring& filter); | 588 void PopulateFileSystemInfoWithFilter(const std::wstring& filter); |
| 623 void PopulateQuotaInfoWithFilter(const std::wstring& filter); | |
| 624 | 589 |
| 625 void NotifyObserverBeginBatch(); | 590 void NotifyObserverBeginBatch(); |
| 626 void NotifyObserverEndBatch(); | 591 void NotifyObserverEndBatch(); |
| 627 | 592 |
| 628 scoped_refptr<net::CookieMonster> cookie_monster_; | 593 scoped_refptr<net::CookieMonster> cookie_monster_; |
| 629 CookieList all_cookies_; | 594 CookieList all_cookies_; |
| 630 | 595 |
| 631 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; | 596 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; |
| 632 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; | 597 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; |
| 633 scoped_refptr<appcache::AppCacheInfoCollection> appcache_info_; | 598 scoped_refptr<appcache::AppCacheInfoCollection> appcache_info_; |
| 634 DatabaseInfoList database_info_list_; | 599 DatabaseInfoList database_info_list_; |
| 635 | 600 |
| 636 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; | 601 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; |
| 637 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; | 602 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; |
| 638 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; | 603 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; |
| 639 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; | 604 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; |
| 640 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; | |
| 641 LocalStorageInfoList local_storage_info_list_; | 605 LocalStorageInfoList local_storage_info_list_; |
| 642 LocalStorageInfoList session_storage_info_list_; | 606 LocalStorageInfoList session_storage_info_list_; |
| 643 IndexedDBInfoList indexed_db_info_list_; | 607 IndexedDBInfoList indexed_db_info_list_; |
| 644 FileSystemInfoList file_system_info_list_; | 608 FileSystemInfoList file_system_info_list_; |
| 645 QuotaInfoArray quota_info_list_; | |
| 646 | 609 |
| 647 // The CookiesTreeModel maintains a separate list of observers that are | 610 // The CookiesTreeModel maintains a separate list of observers that are |
| 648 // specifically of the type CookiesTreeModel::Observer. | 611 // specifically of the type CookiesTreeModel::Observer. |
| 649 ObserverList<Observer> cookies_observer_list_; | 612 ObserverList<Observer> cookies_observer_list_; |
| 650 | 613 |
| 651 // If this is non-zero, then this model is batching updates (there's a lot of | 614 // If this is non-zero, then this model is batching updates (there's a lot of |
| 652 // notifications coming down the pipe). This is an integer is used to balance | 615 // notifications coming down the pipe). This is an integer is used to balance |
| 653 // calls to Begin/EndBatch() if they're called in a nested manner. | 616 // calls to Begin/EndBatch() if they're called in a nested manner. |
| 654 int batch_update_; | 617 int batch_update_; |
| 655 | 618 |
| 656 // If true, use the CanonicalCookie::Source attribute to group cookies. | 619 // If true, use the CanonicalCookie::Source attribute to group cookies. |
| 657 // Otherwise, use the CanonicalCookie::Domain attribute. | 620 // Otherwise, use the CanonicalCookie::Domain attribute. |
| 658 bool use_cookie_source_; | 621 bool use_cookie_source_; |
| 659 | 622 |
| 660 friend class CookieTreeAppCacheNode; | 623 friend class CookieTreeAppCacheNode; |
| 661 friend class CookieTreeCookieNode; | 624 friend class CookieTreeCookieNode; |
| 662 friend class CookieTreeDatabaseNode; | 625 friend class CookieTreeDatabaseNode; |
| 663 friend class CookieTreeLocalStorageNode; | 626 friend class CookieTreeLocalStorageNode; |
| 664 friend class CookieTreeIndexedDBNode; | 627 friend class CookieTreeIndexedDBNode; |
| 665 friend class CookieTreeFileSystemNode; | 628 friend class CookieTreeFileSystemNode; |
| 666 friend class CookieTreeQuotaNode; | |
| 667 | 629 |
| 668 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); | 630 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); |
| 669 }; | 631 }; |
| 670 | 632 |
| 671 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ | 633 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
| OLD | NEW |