| 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 | 7 |
| 8 // TODO(viettrungluu): This header file #includes far too much and has too much | 8 // TODO(viettrungluu): This header file #includes far too much and has too much |
| 9 // inline code (which shouldn't be inline). | 9 // inline code (which shouldn't be inline). |
| 10 | 10 |
| 11 #include <list> | 11 #include <list> |
| 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/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/string16.h" | 18 #include "base/string16.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "chrome/browser/browsing_data_appcache_helper.h" | 20 #include "chrome/browser/browsing_data_appcache_helper.h" |
| 21 #include "chrome/browser/browsing_data_database_helper.h" | 21 #include "chrome/browser/browsing_data_database_helper.h" |
| 22 #include "chrome/browser/browsing_data_file_system_helper.h" | 22 #include "chrome/browser/browsing_data_file_system_helper.h" |
| 23 #include "chrome/browser/browsing_data_indexed_db_helper.h" | 23 #include "chrome/browser/browsing_data_indexed_db_helper.h" |
| 24 #include "chrome/browser/browsing_data_local_storage_helper.h" | 24 #include "chrome/browser/browsing_data_local_storage_helper.h" |
| 25 #include "chrome/browser/browsing_data_quota_helper.h" | 25 #include "chrome/browser/browsing_data_quota_helper.h" |
| 26 #include "chrome/browser/local_data_container.h" | 26 #include "chrome/browser/local_data_container.h" |
| 27 #include "chrome/common/content_settings.h" | 27 #include "chrome/common/content_settings.h" |
| 28 #include "chrome/common/extensions/extension_set.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; |
| 42 class CookieTreeFileSystemNode; | 43 class CookieTreeFileSystemNode; |
| 43 class CookieTreeFileSystemsNode; | 44 class CookieTreeFileSystemsNode; |
| 45 class CookieTreeHostNode; |
| 44 class CookieTreeIndexedDBNode; | 46 class CookieTreeIndexedDBNode; |
| 45 class CookieTreeIndexedDBsNode; | 47 class CookieTreeIndexedDBsNode; |
| 46 class CookieTreeLocalStorageNode; | 48 class CookieTreeLocalStorageNode; |
| 47 class CookieTreeLocalStoragesNode; | 49 class CookieTreeLocalStoragesNode; |
| 48 class CookieTreeOriginNode; | |
| 49 class CookieTreeQuotaNode; | 50 class CookieTreeQuotaNode; |
| 50 class CookieTreeServerBoundCertNode; | 51 class CookieTreeServerBoundCertNode; |
| 51 class CookieTreeServerBoundCertsNode; | 52 class CookieTreeServerBoundCertsNode; |
| 52 class CookieTreeSessionStorageNode; | 53 class CookieTreeSessionStorageNode; |
| 53 class CookieTreeSessionStoragesNode; | 54 class CookieTreeSessionStoragesNode; |
| 54 | 55 class ExtensionSpecialStoragePolicy; |
| 55 | 56 |
| 56 // CookieTreeNode ------------------------------------------------------------- | 57 // CookieTreeNode ------------------------------------------------------------- |
| 57 // 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 |
| 58 // 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 |
| 59 // 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 |
| 60 // able to have its children do the same. | 61 // able to have its children do the same. |
| 61 class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { | 62 class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { |
| 62 public: | 63 public: |
| 63 // 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 |
| 64 // the tree control.) | 65 // the tree control.) |
| 65 struct DetailedInfo { | 66 struct DetailedInfo { |
| 66 // NodeType corresponds to the various CookieTreeNode types. | 67 // NodeType corresponds to the various CookieTreeNode types. |
| 67 enum NodeType { | 68 enum NodeType { |
| 68 TYPE_NONE, | 69 TYPE_NONE, |
| 69 TYPE_ROOT, // This is used for CookieTreeRootNode nodes. | 70 TYPE_ROOT, // This is used for CookieTreeRootNode nodes. |
| 70 TYPE_ORIGIN, // This is used for CookieTreeOriginNode nodes. | 71 TYPE_HOST, // This is used for CookieTreeHostNode nodes. |
| 71 TYPE_COOKIES, // This is used for CookieTreeCookiesNode nodes. | 72 TYPE_COOKIES, // This is used for CookieTreeCookiesNode nodes. |
| 72 TYPE_COOKIE, // This is used for CookieTreeCookieNode nodes. | 73 TYPE_COOKIE, // This is used for CookieTreeCookieNode nodes. |
| 73 TYPE_DATABASES, // This is used for CookieTreeDatabasesNode. | 74 TYPE_DATABASES, // This is used for CookieTreeDatabasesNode. |
| 74 TYPE_DATABASE, // This is used for CookieTreeDatabaseNode. | 75 TYPE_DATABASE, // This is used for CookieTreeDatabaseNode. |
| 75 TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. | 76 TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. |
| 76 TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. | 77 TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. |
| 77 TYPE_SESSION_STORAGES, // This is used for CookieTreeSessionStoragesNode. | 78 TYPE_SESSION_STORAGES, // This is used for CookieTreeSessionStoragesNode. |
| 78 TYPE_SESSION_STORAGE, // This is used for CookieTreeSessionStorageNode. | 79 TYPE_SESSION_STORAGE, // This is used for CookieTreeSessionStorageNode. |
| 79 TYPE_APPCACHES, // This is used for CookieTreeAppCachesNode. | 80 TYPE_APPCACHES, // This is used for CookieTreeAppCachesNode. |
| 80 TYPE_APPCACHE, // This is used for CookieTreeAppCacheNode. | 81 TYPE_APPCACHE, // This is used for CookieTreeAppCacheNode. |
| 81 TYPE_INDEXED_DBS, // This is used for CookieTreeIndexedDBsNode. | 82 TYPE_INDEXED_DBS, // This is used for CookieTreeIndexedDBsNode. |
| 82 TYPE_INDEXED_DB, // This is used for CookieTreeIndexedDBNode. | 83 TYPE_INDEXED_DB, // This is used for CookieTreeIndexedDBNode. |
| 83 TYPE_FILE_SYSTEMS, // This is used for CookieTreeFileSystemsNode. | 84 TYPE_FILE_SYSTEMS, // This is used for CookieTreeFileSystemsNode. |
| 84 TYPE_FILE_SYSTEM, // This is used for CookieTreeFileSystemNode. | 85 TYPE_FILE_SYSTEM, // This is used for CookieTreeFileSystemNode. |
| 85 TYPE_QUOTA, // This is used for CookieTreeQuotaNode. | 86 TYPE_QUOTA, // This is used for CookieTreeQuotaNode. |
| 86 TYPE_SERVER_BOUND_CERTS, // Used for CookieTreeServerBoundCertsNode. | 87 TYPE_SERVER_BOUND_CERTS, // Used for CookieTreeServerBoundCertsNode. |
| 87 TYPE_SERVER_BOUND_CERT, // Used for CookieTreeServerBoundCertNode. | 88 TYPE_SERVER_BOUND_CERT, // Used for CookieTreeServerBoundCertNode. |
| 88 }; | 89 }; |
| 89 | 90 |
| 90 // TODO(viettrungluu): Figure out whether we want to store |origin| as a | 91 DetailedInfo(); |
| 91 // |string16| or a (UTF-8) |std::string|, and convert. | 92 ~DetailedInfo(); |
| 92 explicit DetailedInfo(const string16& origin) | |
| 93 : origin(origin), | |
| 94 node_type(TYPE_NONE), | |
| 95 cookie(NULL), | |
| 96 database_info(NULL), | |
| 97 local_storage_info(NULL), | |
| 98 session_storage_info(NULL), | |
| 99 appcache_info(NULL), | |
| 100 indexed_db_info(NULL), | |
| 101 file_system_info(NULL), | |
| 102 quota_info(NULL), | |
| 103 server_bound_cert(NULL) {} | |
| 104 | 93 |
| 105 DetailedInfo& Init(NodeType type) { | 94 DetailedInfo& Init(NodeType type); |
| 106 DCHECK_EQ(TYPE_NONE, node_type); | 95 DetailedInfo& InitHost(const std::string& app_id, |
| 107 node_type = type; | 96 const std::string& app_name); |
| 108 return *this; | |
| 109 } | |
| 110 | |
| 111 DetailedInfo& InitOrigin(const std::string& app_id, | |
| 112 const std::string& app_name) { | |
| 113 Init(TYPE_ORIGIN); | |
| 114 this->app_name = app_name; | |
| 115 this->app_id = app_id; | |
| 116 return *this; | |
| 117 } | |
| 118 | |
| 119 DetailedInfo& InitCookie( | 97 DetailedInfo& InitCookie( |
| 120 const net::CookieMonster::CanonicalCookie* cookie) { | 98 const net::CookieMonster::CanonicalCookie* cookie); |
| 121 Init(TYPE_COOKIE); | |
| 122 this->cookie = cookie; | |
| 123 return *this; | |
| 124 } | |
| 125 | |
| 126 DetailedInfo& InitDatabase( | 99 DetailedInfo& InitDatabase( |
| 127 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info) { | 100 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info); |
| 128 Init(TYPE_DATABASE); | |
| 129 this->database_info = database_info; | |
| 130 return *this; | |
| 131 } | |
| 132 | |
| 133 DetailedInfo& InitLocalStorage( | 101 DetailedInfo& InitLocalStorage( |
| 134 const BrowsingDataLocalStorageHelper::LocalStorageInfo* | 102 const BrowsingDataLocalStorageHelper::LocalStorageInfo* |
| 135 local_storage_info) { | 103 local_storage_info); |
| 136 Init(TYPE_LOCAL_STORAGE); | |
| 137 this->local_storage_info = local_storage_info; | |
| 138 return *this; | |
| 139 } | |
| 140 | |
| 141 DetailedInfo& InitSessionStorage( | 104 DetailedInfo& InitSessionStorage( |
| 142 const BrowsingDataLocalStorageHelper::LocalStorageInfo* | 105 const BrowsingDataLocalStorageHelper::LocalStorageInfo* |
| 143 session_storage_info) { | 106 session_storage_info); |
| 144 Init(TYPE_SESSION_STORAGE); | 107 DetailedInfo& InitAppCache(const GURL& origin, |
| 145 this->session_storage_info = session_storage_info; | 108 const appcache::AppCacheInfo* appcache_info); |
| 146 return *this; | |
| 147 } | |
| 148 | |
| 149 DetailedInfo& InitAppCache(const appcache::AppCacheInfo* appcache_info) { | |
| 150 Init(TYPE_APPCACHE); | |
| 151 this->appcache_info = appcache_info; | |
| 152 return *this; | |
| 153 } | |
| 154 | |
| 155 DetailedInfo& InitIndexedDB( | 109 DetailedInfo& InitIndexedDB( |
| 156 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info) { | 110 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info); |
| 157 Init(TYPE_INDEXED_DB); | |
| 158 this->indexed_db_info = indexed_db_info; | |
| 159 return *this; | |
| 160 } | |
| 161 | |
| 162 DetailedInfo& InitFileSystem( | 111 DetailedInfo& InitFileSystem( |
| 163 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info) { | 112 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info); |
| 164 Init(TYPE_FILE_SYSTEM); | |
| 165 this->file_system_info = file_system_info; | |
| 166 return *this; | |
| 167 } | |
| 168 | |
| 169 DetailedInfo& InitQuota( | 113 DetailedInfo& InitQuota( |
| 170 const BrowsingDataQuotaHelper::QuotaInfo* quota_info) { | 114 const BrowsingDataQuotaHelper::QuotaInfo* quota_info); |
| 171 Init(TYPE_QUOTA); | |
| 172 this->quota_info = quota_info; | |
| 173 return *this; | |
| 174 } | |
| 175 | |
| 176 DetailedInfo& InitServerBoundCert( | 115 DetailedInfo& InitServerBoundCert( |
| 177 const net::ServerBoundCertStore::ServerBoundCert* server_bound_cert) { | 116 const net::ServerBoundCertStore::ServerBoundCert* server_bound_cert); |
| 178 Init(TYPE_SERVER_BOUND_CERT); | |
| 179 this->server_bound_cert = server_bound_cert; | |
| 180 return *this; | |
| 181 } | |
| 182 | 117 |
| 183 std::string app_name; | 118 std::string app_name; |
| 184 std::string app_id; | 119 std::string app_id; |
| 185 string16 origin; | |
| 186 NodeType node_type; | 120 NodeType node_type; |
| 121 GURL origin; |
| 187 const net::CookieMonster::CanonicalCookie* cookie; | 122 const net::CookieMonster::CanonicalCookie* cookie; |
| 188 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info; | 123 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info; |
| 189 const BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info; | 124 const BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info; |
| 190 const BrowsingDataLocalStorageHelper::LocalStorageInfo* | 125 const BrowsingDataLocalStorageHelper::LocalStorageInfo* |
| 191 session_storage_info; | 126 session_storage_info; |
| 192 const appcache::AppCacheInfo* appcache_info; | 127 const appcache::AppCacheInfo* appcache_info; |
| 193 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info; | 128 const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info; |
| 194 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info; | 129 const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info; |
| 195 const BrowsingDataQuotaHelper::QuotaInfo* quota_info; | 130 const BrowsingDataQuotaHelper::QuotaInfo* quota_info; |
| 196 const net::ServerBoundCertStore::ServerBoundCert* server_bound_cert; | 131 const net::ServerBoundCertStore::ServerBoundCert* server_bound_cert; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 209 virtual CookiesTreeModel* GetModel() const; | 144 virtual CookiesTreeModel* GetModel() const; |
| 210 | 145 |
| 211 // Returns a struct with detailed information used to populate the details | 146 // Returns a struct with detailed information used to populate the details |
| 212 // part of the view. | 147 // part of the view. |
| 213 virtual DetailedInfo GetDetailedInfo() const = 0; | 148 virtual DetailedInfo GetDetailedInfo() const = 0; |
| 214 | 149 |
| 215 protected: | 150 protected: |
| 216 void AddChildSortedByTitle(CookieTreeNode* new_child); | 151 void AddChildSortedByTitle(CookieTreeNode* new_child); |
| 217 | 152 |
| 218 private: | 153 private: |
| 219 | |
| 220 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode); | 154 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode); |
| 221 }; | 155 }; |
| 222 | 156 |
| 223 // CookieTreeRootNode --------------------------------------------------------- | 157 // CookieTreeRootNode --------------------------------------------------------- |
| 224 // The node at the root of the CookieTree that gets inserted into the view. | 158 // The node at the root of the CookieTree that gets inserted into the view. |
| 225 class CookieTreeRootNode : public CookieTreeNode { | 159 class CookieTreeRootNode : public CookieTreeNode { |
| 226 public: | 160 public: |
| 227 explicit CookieTreeRootNode(CookiesTreeModel* model); | 161 explicit CookieTreeRootNode(CookiesTreeModel* model); |
| 228 virtual ~CookieTreeRootNode(); | 162 virtual ~CookieTreeRootNode(); |
| 229 | 163 |
| 230 CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url, | 164 CookieTreeHostNode* GetOrCreateHostNode(const GURL& url, |
| 231 const std::string& app_id, | 165 const std::string& app_id, |
| 232 const std::string& app_name); | 166 const std::string& app_name); |
| 233 | 167 |
| 234 // CookieTreeNode methods: | 168 // CookieTreeNode methods: |
| 235 virtual CookiesTreeModel* GetModel() const OVERRIDE; | 169 virtual CookiesTreeModel* GetModel() const OVERRIDE; |
| 236 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 170 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
| 237 | 171 |
| 238 private: | 172 private: |
| 239 CookiesTreeModel* model_; | 173 CookiesTreeModel* model_; |
| 240 | 174 |
| 241 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); | 175 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); |
| 242 }; | 176 }; |
| 243 | 177 |
| 244 // CookieTreeOriginNode ------------------------------------------------------- | 178 // CookieTreeHostNode ------------------------------------------------------- |
| 245 class CookieTreeOriginNode : public CookieTreeNode { | 179 class CookieTreeHostNode : public CookieTreeNode { |
| 246 public: | 180 public: |
| 247 // Returns the origin node's title to use for a given URL. | 181 // Returns the host node's title to use for a given URL. |
| 248 static string16 TitleForUrl(const GURL& url, | 182 static string16 TitleForUrl(const GURL& url, |
| 249 const std::string& app_id, | 183 const std::string& app_id, |
| 250 const std::string& app_name); | 184 const std::string& app_name); |
| 251 | 185 |
| 252 explicit CookieTreeOriginNode(const GURL& url, | 186 explicit CookieTreeHostNode(const GURL& url, |
| 253 const std::string& app_id, | 187 const std::string& app_id, |
| 254 const std::string& app_name); | 188 const std::string& app_name); |
| 255 virtual ~CookieTreeOriginNode(); | 189 virtual ~CookieTreeHostNode(); |
| 256 | 190 |
| 257 // CookieTreeNode methods: | 191 // CookieTreeNode methods: |
| 258 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; | 192 virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
| 259 | 193 |
| 260 // CookieTreeOriginNode methods: | 194 // CookieTreeHostNode methods: |
| 261 CookieTreeCookiesNode* GetOrCreateCookiesNode(); | 195 CookieTreeCookiesNode* GetOrCreateCookiesNode(); |
| 262 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); | 196 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); |
| 263 CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); | 197 CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); |
| 264 CookieTreeSessionStoragesNode* GetOrCreateSessionStoragesNode(); | 198 CookieTreeSessionStoragesNode* GetOrCreateSessionStoragesNode(); |
| 265 CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); | 199 CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); |
| 266 CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode(); | 200 CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode(); |
| 267 CookieTreeFileSystemsNode* GetOrCreateFileSystemsNode(); | 201 CookieTreeFileSystemsNode* GetOrCreateFileSystemsNode(); |
| 268 CookieTreeServerBoundCertsNode* GetOrCreateServerBoundCertsNode(); | 202 CookieTreeServerBoundCertsNode* GetOrCreateServerBoundCertsNode(); |
| 269 CookieTreeQuotaNode* UpdateOrCreateQuotaNode( | 203 CookieTreeQuotaNode* UpdateOrCreateQuotaNode( |
| 270 std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info); | 204 std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info); |
| 271 | 205 |
| 206 std::string canonicalized_host() const { return canonicalized_host_; } |
| 207 |
| 272 // Creates an content exception for this origin of type | 208 // Creates an content exception for this origin of type |
| 273 // CONTENT_SETTINGS_TYPE_COOKIES. | 209 // CONTENT_SETTINGS_TYPE_COOKIES. |
| 274 void CreateContentException(CookieSettings* cookie_settings, | 210 void CreateContentException(CookieSettings* cookie_settings, |
| 275 ContentSetting setting) const; | 211 ContentSetting setting) const; |
| 276 | 212 |
| 277 // True if a content exception can be created for this origin. | 213 // True if a content exception can be created for this origin. |
| 278 bool CanCreateContentException() const; | 214 bool CanCreateContentException() const; |
| 279 | 215 |
| 280 const std::string& app_id() const { return app_id_; } | 216 const std::string& app_id() const { return app_id_; } |
| 281 const std::string& app_name() const { return app_name_; } | 217 const std::string& app_name() const { return app_name_; } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 296 CookieTreeFileSystemsNode* file_systems_child_; | 232 CookieTreeFileSystemsNode* file_systems_child_; |
| 297 CookieTreeQuotaNode* quota_child_; | 233 CookieTreeQuotaNode* quota_child_; |
| 298 CookieTreeServerBoundCertsNode* server_bound_certs_child_; | 234 CookieTreeServerBoundCertsNode* server_bound_certs_child_; |
| 299 | 235 |
| 300 std::string app_id_; | 236 std::string app_id_; |
| 301 std::string app_name_; | 237 std::string app_name_; |
| 302 | 238 |
| 303 // The URL for which this node was initially created. | 239 // The URL for which this node was initially created. |
| 304 GURL url_; | 240 GURL url_; |
| 305 | 241 |
| 306 DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); | 242 std::string canonicalized_host_; |
| 243 |
| 244 DISALLOW_COPY_AND_ASSIGN(CookieTreeHostNode); |
| 307 }; | 245 }; |
| 308 | 246 |
| 309 // CookieTreeCookieNode ------------------------------------------------------ | 247 // CookieTreeCookieNode ------------------------------------------------------ |
| 310 class CookieTreeCookieNode : public CookieTreeNode { | 248 class CookieTreeCookieNode : public CookieTreeNode { |
| 311 public: | 249 public: |
| 312 friend class CookieTreeCookiesNode; | 250 friend class CookieTreeCookiesNode; |
| 313 | 251 |
| 314 // The cookie should remain valid at least as long as the | 252 // The cookie should remain valid at least as long as the |
| 315 // CookieTreeCookieNode is valid. | 253 // CookieTreeCookieNode is valid. |
| 316 explicit CookieTreeCookieNode( | 254 explicit CookieTreeCookieNode( |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 AddChildSortedByTitle(child); | 567 AddChildSortedByTitle(child); |
| 630 } | 568 } |
| 631 | 569 |
| 632 private: | 570 private: |
| 633 DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); | 571 DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); |
| 634 }; | 572 }; |
| 635 | 573 |
| 636 // CookiesTreeModel ----------------------------------------------------------- | 574 // CookiesTreeModel ----------------------------------------------------------- |
| 637 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { | 575 class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
| 638 public: | 576 public: |
| 639 CookiesTreeModel(const ContainerMap& apps_map, bool group_by_cookie_source); | 577 CookiesTreeModel(const ContainerMap& apps_map, |
| 578 ExtensionSpecialStoragePolicy* special_storage_policy, |
| 579 bool group_by_cookie_source); |
| 640 virtual ~CookiesTreeModel(); | 580 virtual ~CookiesTreeModel(); |
| 641 | 581 |
| 642 // Because non-cookie nodes are fetched in a background thread, they are not | 582 // Because non-cookie nodes are fetched in a background thread, they are not |
| 643 // present at the time the Model is created. The Model then notifies its | 583 // present at the time the Model is created. The Model then notifies its |
| 644 // observers for every item added from databases, local storage, and | 584 // observers for every item added from databases, local storage, and |
| 645 // appcache. We extend the Observer interface to add notifications before and | 585 // appcache. We extend the Observer interface to add notifications before and |
| 646 // after these batch inserts. | 586 // after these batch inserts. |
| 647 class Observer : public ui::TreeModelObserver { | 587 class Observer : public ui::TreeModelObserver { |
| 648 public: | 588 public: |
| 649 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} | 589 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} |
| (...skipping 30 matching lines...) Expand all Loading... |
| 680 // CookiesTreeModel methods: | 620 // CookiesTreeModel methods: |
| 681 void DeleteAllStoredObjects(); | 621 void DeleteAllStoredObjects(); |
| 682 | 622 |
| 683 // Deletes a specific node in the tree, identified by |cookie_node|, and its | 623 // Deletes a specific node in the tree, identified by |cookie_node|, and its |
| 684 // subtree. | 624 // subtree. |
| 685 void DeleteCookieNode(CookieTreeNode* cookie_node); | 625 void DeleteCookieNode(CookieTreeNode* cookie_node); |
| 686 | 626 |
| 687 // Filter the origins to only display matched results. | 627 // Filter the origins to only display matched results. |
| 688 void UpdateSearchResults(const string16& filter); | 628 void UpdateSearchResults(const string16& filter); |
| 689 | 629 |
| 630 // Returns the set of extensions which protect the data item represented by |
| 631 // this node from deletion. |
| 632 // Returns NULL if the node doesn't represent a protected data item or the |
| 633 // special storage policy is NULL. |
| 634 const ExtensionSet* ExtensionsProtectingNode( |
| 635 const CookieTreeNode& cookie_node); |
| 636 |
| 690 // Manages CookiesTreeModel::Observers. This will also call | 637 // Manages CookiesTreeModel::Observers. This will also call |
| 691 // TreeNodeModel::AddObserver so that it gets all the proper notifications. | 638 // TreeNodeModel::AddObserver so that it gets all the proper notifications. |
| 692 // Note that the converse is not true: simply adding a TreeModelObserver will | 639 // Note that the converse is not true: simply adding a TreeModelObserver will |
| 693 // not get CookiesTreeModel::Observer notifications. | 640 // not get CookiesTreeModel::Observer notifications. |
| 694 virtual void AddCookiesTreeObserver(Observer* observer); | 641 virtual void AddCookiesTreeObserver(Observer* observer); |
| 695 virtual void RemoveCookiesTreeObserver(Observer* observer); | 642 virtual void RemoveCookiesTreeObserver(Observer* observer); |
| 696 | 643 |
| 697 // Methods that update the model based on the data retrieved by the browsing | 644 // Methods that update the model based on the data retrieved by the browsing |
| 698 // data helpers. | 645 // data helpers. |
| 699 void PopulateAppCacheInfo(LocalDataContainer* container); | 646 void PopulateAppCacheInfo(LocalDataContainer* container); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 const string16& filter); | 692 const string16& filter); |
| 746 void PopulateServerBoundCertInfoWithFilter( | 693 void PopulateServerBoundCertInfoWithFilter( |
| 747 LocalDataContainer* container, | 694 LocalDataContainer* container, |
| 748 ScopedBatchUpdateNotifier* notifier, | 695 ScopedBatchUpdateNotifier* notifier, |
| 749 const string16& filter); | 696 const string16& filter); |
| 750 | 697 |
| 751 // Map of app ids to LocalDataContainer objects to use when retrieving | 698 // Map of app ids to LocalDataContainer objects to use when retrieving |
| 752 // locally stored data. | 699 // locally stored data. |
| 753 ContainerMap app_data_map_; | 700 ContainerMap app_data_map_; |
| 754 | 701 |
| 702 // The extension special storage policy; see ExtensionsProtectingNode() above. |
| 703 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_; |
| 704 |
| 755 // The CookiesTreeModel maintains a separate list of observers that are | 705 // The CookiesTreeModel maintains a separate list of observers that are |
| 756 // specifically of the type CookiesTreeModel::Observer. | 706 // specifically of the type CookiesTreeModel::Observer. |
| 757 ObserverList<Observer> cookies_observer_list_; | 707 ObserverList<Observer> cookies_observer_list_; |
| 758 | 708 |
| 759 // If true, use the CanonicalCookie::Source attribute to group cookies. | 709 // If true, use the CanonicalCookie::Source attribute to group cookies. |
| 760 // Otherwise, use the CanonicalCookie::Domain attribute. | 710 // Otherwise, use the CanonicalCookie::Domain attribute. |
| 761 bool group_by_cookie_source_; | 711 bool group_by_cookie_source_; |
| 762 | 712 |
| 763 // If this is non-zero, then this model is batching updates (there's a lot of | 713 // If this is non-zero, then this model is batching updates (there's a lot of |
| 764 // notifications coming down the pipe). This is an integer is used to balance | 714 // notifications coming down the pipe). This is an integer is used to balance |
| 765 // calls to Begin/EndBatch() if they're called in a nested manner. | 715 // calls to Begin/EndBatch() if they're called in a nested manner. |
| 766 int batch_update_; | 716 int batch_update_; |
| 767 }; | 717 }; |
| 768 | 718 |
| 769 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ | 719 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
| OLD | NEW |