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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_BROWSING_DATA_COOKIES_TREE_MODEL_H_
6 #define CHROME_BROWSER_BROWSING_DATA_COOKIES_TREE_MODEL_H_
8 // TODO(viettrungluu): This header file #includes far too much and has too much
9 // inline code (which shouldn't be inline).
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h"
18 #include "base/strings/string16.h"
19 #include "base/strings/utf_string_conversions.h"
20 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h"
21 #include "chrome/browser/browsing_data/browsing_data_database_helper.h"
22 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
23 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
24 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
25 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h"
26 #include "chrome/browser/browsing_data/browsing_data_service_worker_helper.h"
27 #include "chrome/browser/browsing_data/local_data_container.h"
28 #include "components/content_settings/core/common/content_settings.h"
29 #include "net/ssl/channel_id_store.h"
30 #include "ui/base/models/tree_node_model.h"
32 class BrowsingDataChannelIDHelper
;
33 class BrowsingDataCookieHelper
;
34 class CookiesTreeModel
;
35 class CookieTreeAppCacheNode
;
36 class CookieTreeAppCachesNode
;
37 class CookieTreeChannelIDNode
;
38 class CookieTreeChannelIDsNode
;
39 class CookieTreeCookieNode
;
40 class CookieTreeCookiesNode
;
41 class CookieTreeDatabaseNode
;
42 class CookieTreeDatabasesNode
;
43 class CookieTreeFileSystemNode
;
44 class CookieTreeFileSystemsNode
;
45 class CookieTreeFlashLSONode
;
46 class CookieTreeHostNode
;
47 class CookieTreeIndexedDBNode
;
48 class CookieTreeIndexedDBsNode
;
49 class CookieTreeLocalStorageNode
;
50 class CookieTreeLocalStoragesNode
;
51 class CookieTreeQuotaNode
;
52 class CookieTreeServiceWorkerNode
;
53 class CookieTreeServiceWorkersNode
;
54 class CookieTreeSessionStorageNode
;
55 class CookieTreeSessionStoragesNode
;
56 class ExtensionSpecialStoragePolicy
;
58 namespace content_settings
{
62 namespace extensions
{
67 class CanonicalCookie
;
70 // CookieTreeNode -------------------------------------------------------------
71 // The base node type in the Cookies, Databases, and Local Storage options
72 // view, from which all other types are derived. Specialized from TreeNode in
73 // that it has a notion of deleting objects stored in the profile, and being
74 // able to have its children do the same.
75 class CookieTreeNode
: public ui::TreeNode
<CookieTreeNode
> {
77 // Used to pull out information for the InfoView (the details display below
80 // NodeType corresponds to the various CookieTreeNode types.
83 TYPE_ROOT
, // This is used for CookieTreeRootNode nodes.
84 TYPE_HOST
, // This is used for CookieTreeHostNode nodes.
85 TYPE_COOKIES
, // This is used for CookieTreeCookiesNode nodes.
86 TYPE_COOKIE
, // This is used for CookieTreeCookieNode nodes.
87 TYPE_DATABASES
, // This is used for CookieTreeDatabasesNode.
88 TYPE_DATABASE
, // This is used for CookieTreeDatabaseNode.
89 TYPE_LOCAL_STORAGES
, // This is used for CookieTreeLocalStoragesNode.
90 TYPE_LOCAL_STORAGE
, // This is used for CookieTreeLocalStorageNode.
91 TYPE_SESSION_STORAGES
, // This is used for CookieTreeSessionStoragesNode.
92 TYPE_SESSION_STORAGE
, // This is used for CookieTreeSessionStorageNode.
93 TYPE_APPCACHES
, // This is used for CookieTreeAppCachesNode.
94 TYPE_APPCACHE
, // This is used for CookieTreeAppCacheNode.
95 TYPE_INDEXED_DBS
, // This is used for CookieTreeIndexedDBsNode.
96 TYPE_INDEXED_DB
, // This is used for CookieTreeIndexedDBNode.
97 TYPE_FILE_SYSTEMS
, // This is used for CookieTreeFileSystemsNode.
98 TYPE_FILE_SYSTEM
, // This is used for CookieTreeFileSystemNode.
99 TYPE_QUOTA
, // This is used for CookieTreeQuotaNode.
100 TYPE_CHANNEL_IDS
, // Used for CookieTreeChannelIDsNode.
101 TYPE_CHANNEL_ID
, // Used for CookieTreeChannelIDNode.
102 TYPE_SERVICE_WORKERS
, // This is used for CookieTreeServiceWorkersNode.
103 TYPE_SERVICE_WORKER
, // This is used for CookieTreeServiceWorkerNode.
104 TYPE_FLASH_LSO
, // This is used for CookieTreeFlashLSONode.
110 DetailedInfo
& Init(NodeType type
);
111 DetailedInfo
& InitHost();
112 DetailedInfo
& InitCookie(const net::CanonicalCookie
* cookie
);
113 DetailedInfo
& InitDatabase(
114 const BrowsingDataDatabaseHelper::DatabaseInfo
* database_info
);
115 DetailedInfo
& InitLocalStorage(
116 const BrowsingDataLocalStorageHelper::LocalStorageInfo
*
118 DetailedInfo
& InitSessionStorage(
119 const BrowsingDataLocalStorageHelper::LocalStorageInfo
*
120 session_storage_info
);
121 DetailedInfo
& InitAppCache(const GURL
& origin
,
122 const content::AppCacheInfo
* appcache_info
);
123 DetailedInfo
& InitIndexedDB(
124 const content::IndexedDBInfo
* indexed_db_info
);
125 DetailedInfo
& InitFileSystem(
126 const BrowsingDataFileSystemHelper::FileSystemInfo
* file_system_info
);
127 DetailedInfo
& InitQuota(
128 const BrowsingDataQuotaHelper::QuotaInfo
* quota_info
);
129 DetailedInfo
& InitChannelID(
130 const net::ChannelIDStore::ChannelID
* channel_id
);
131 DetailedInfo
& InitServiceWorker(
132 const content::ServiceWorkerUsageInfo
* service_worker_info
);
133 DetailedInfo
& InitFlashLSO(const std::string
& flash_lso_domain
);
137 const net::CanonicalCookie
* cookie
;
138 const BrowsingDataDatabaseHelper::DatabaseInfo
* database_info
;
139 const BrowsingDataLocalStorageHelper::LocalStorageInfo
* local_storage_info
;
140 const BrowsingDataLocalStorageHelper::LocalStorageInfo
*
141 session_storage_info
;
142 const content::AppCacheInfo
* appcache_info
;
143 const content::IndexedDBInfo
* indexed_db_info
;
144 const BrowsingDataFileSystemHelper::FileSystemInfo
* file_system_info
;
145 const BrowsingDataQuotaHelper::QuotaInfo
* quota_info
;
146 const net::ChannelIDStore::ChannelID
* channel_id
;
147 const content::ServiceWorkerUsageInfo
* service_worker_info
;
148 std::string flash_lso_domain
;
152 explicit CookieTreeNode(const base::string16
& title
)
153 : ui::TreeNode
<CookieTreeNode
>(title
) {}
154 ~CookieTreeNode() override
{}
156 // Delete backend storage for this node, and any children nodes. (E.g. delete
157 // the cookie from CookieMonster, clear the database, and so forth.)
158 virtual void DeleteStoredObjects();
160 // Gets a pointer back to the associated model for the tree we are in.
161 virtual CookiesTreeModel
* GetModel() const;
163 // Returns a struct with detailed information used to populate the details
165 virtual DetailedInfo
GetDetailedInfo() const = 0;
168 void AddChildSortedByTitle(CookieTreeNode
* new_child
);
171 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode
);
174 // CookieTreeRootNode ---------------------------------------------------------
175 // The node at the root of the CookieTree that gets inserted into the view.
176 class CookieTreeRootNode
: public CookieTreeNode
{
178 explicit CookieTreeRootNode(CookiesTreeModel
* model
);
179 ~CookieTreeRootNode() override
;
181 CookieTreeHostNode
* GetOrCreateHostNode(const GURL
& url
);
183 // CookieTreeNode methods:
184 CookiesTreeModel
* GetModel() const override
;
185 DetailedInfo
GetDetailedInfo() const override
;
188 CookiesTreeModel
* model_
;
190 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode
);
193 // CookieTreeHostNode -------------------------------------------------------
194 class CookieTreeHostNode
: public CookieTreeNode
{
196 // Returns the host node's title to use for a given URL.
197 static base::string16
TitleForUrl(const GURL
& url
);
199 explicit CookieTreeHostNode(const GURL
& url
);
200 ~CookieTreeHostNode() override
;
202 // CookieTreeNode methods:
203 DetailedInfo
GetDetailedInfo() const override
;
205 // CookieTreeHostNode methods:
206 CookieTreeCookiesNode
* GetOrCreateCookiesNode();
207 CookieTreeDatabasesNode
* GetOrCreateDatabasesNode();
208 CookieTreeLocalStoragesNode
* GetOrCreateLocalStoragesNode();
209 CookieTreeSessionStoragesNode
* GetOrCreateSessionStoragesNode();
210 CookieTreeAppCachesNode
* GetOrCreateAppCachesNode();
211 CookieTreeIndexedDBsNode
* GetOrCreateIndexedDBsNode();
212 CookieTreeFileSystemsNode
* GetOrCreateFileSystemsNode();
213 CookieTreeChannelIDsNode
* GetOrCreateChannelIDsNode();
214 CookieTreeServiceWorkersNode
* GetOrCreateServiceWorkersNode();
215 CookieTreeQuotaNode
* UpdateOrCreateQuotaNode(
216 std::list
<BrowsingDataQuotaHelper::QuotaInfo
>::iterator quota_info
);
217 CookieTreeFlashLSONode
* GetOrCreateFlashLSONode(const std::string
& domain
);
219 std::string
canonicalized_host() const { return canonicalized_host_
; }
221 // Creates an content exception for this origin of type
222 // CONTENT_SETTINGS_TYPE_COOKIES.
223 void CreateContentException(content_settings::CookieSettings
* cookie_settings
,
224 ContentSetting setting
) const;
226 // True if a content exception can be created for this origin.
227 bool CanCreateContentException() const;
229 const std::string
GetHost() const;
232 // Pointers to the cookies, databases, local and session storage and appcache
233 // nodes. When we build up the tree we need to quickly get a reference to
234 // the COOKIES node to add children. Checking each child and interrogating
235 // them to see if they are a COOKIES, APPCACHES, DATABASES etc node seems
236 // less preferable than storing an extra pointer per origin.
237 CookieTreeCookiesNode
* cookies_child_
;
238 CookieTreeDatabasesNode
* databases_child_
;
239 CookieTreeLocalStoragesNode
* local_storages_child_
;
240 CookieTreeSessionStoragesNode
* session_storages_child_
;
241 CookieTreeAppCachesNode
* appcaches_child_
;
242 CookieTreeIndexedDBsNode
* indexed_dbs_child_
;
243 CookieTreeFileSystemsNode
* file_systems_child_
;
244 CookieTreeQuotaNode
* quota_child_
;
245 CookieTreeChannelIDsNode
* channel_ids_child_
;
246 CookieTreeServiceWorkersNode
* service_workers_child_
;
247 CookieTreeFlashLSONode
* flash_lso_child_
;
249 // The URL for which this node was initially created.
252 std::string canonicalized_host_
;
254 DISALLOW_COPY_AND_ASSIGN(CookieTreeHostNode
);
257 // CookieTreeCookieNode ------------------------------------------------------
258 class CookieTreeCookieNode
: public CookieTreeNode
{
260 friend class CookieTreeCookiesNode
;
262 // The cookie should remain valid at least as long as the
263 // CookieTreeCookieNode is valid.
264 explicit CookieTreeCookieNode(
265 std::list
<net::CanonicalCookie
>::iterator cookie
);
266 ~CookieTreeCookieNode() override
;
268 // CookieTreeNode methods:
269 void DeleteStoredObjects() override
;
270 DetailedInfo
GetDetailedInfo() const override
;
273 // cookie_ is expected to remain valid as long as the CookieTreeCookieNode is
275 std::list
<net::CanonicalCookie
>::iterator cookie_
;
277 DISALLOW_COPY_AND_ASSIGN(CookieTreeCookieNode
);
280 class CookieTreeCookiesNode
: public CookieTreeNode
{
282 CookieTreeCookiesNode();
283 ~CookieTreeCookiesNode() override
;
285 DetailedInfo
GetDetailedInfo() const override
;
287 void AddCookieNode(CookieTreeCookieNode
* child
) {
288 AddChildSortedByTitle(child
);
292 DISALLOW_COPY_AND_ASSIGN(CookieTreeCookiesNode
);
295 // CookieTreeAppCacheNode -----------------------------------------------------
296 class CookieTreeAppCacheNode
: public CookieTreeNode
{
298 friend class CookieTreeAppCachesNode
;
300 // appcache_info should remain valid at least as long as the
301 // CookieTreeAppCacheNode is valid.
302 explicit CookieTreeAppCacheNode(
303 const GURL
& origin_url
,
304 std::list
<content::AppCacheInfo
>::iterator appcache_info
);
305 ~CookieTreeAppCacheNode() override
;
307 void DeleteStoredObjects() override
;
308 DetailedInfo
GetDetailedInfo() const override
;
312 std::list
<content::AppCacheInfo
>::iterator appcache_info_
;
313 DISALLOW_COPY_AND_ASSIGN(CookieTreeAppCacheNode
);
316 class CookieTreeAppCachesNode
: public CookieTreeNode
{
318 CookieTreeAppCachesNode();
319 ~CookieTreeAppCachesNode() override
;
321 DetailedInfo
GetDetailedInfo() const override
;
323 void AddAppCacheNode(CookieTreeAppCacheNode
* child
) {
324 AddChildSortedByTitle(child
);
328 DISALLOW_COPY_AND_ASSIGN(CookieTreeAppCachesNode
);
331 // CookieTreeDatabaseNode -----------------------------------------------------
332 class CookieTreeDatabaseNode
: public CookieTreeNode
{
334 friend class CookieTreeDatabasesNode
;
336 // database_info should remain valid at least as long as the
337 // CookieTreeDatabaseNode is valid.
338 explicit CookieTreeDatabaseNode(
339 std::list
<BrowsingDataDatabaseHelper::DatabaseInfo
>::iterator
341 ~CookieTreeDatabaseNode() override
;
343 void DeleteStoredObjects() override
;
344 DetailedInfo
GetDetailedInfo() const override
;
347 // database_info_ is expected to remain valid as long as the
348 // CookieTreeDatabaseNode is valid.
349 std::list
<BrowsingDataDatabaseHelper::DatabaseInfo
>::iterator
352 DISALLOW_COPY_AND_ASSIGN(CookieTreeDatabaseNode
);
355 class CookieTreeDatabasesNode
: public CookieTreeNode
{
357 CookieTreeDatabasesNode();
358 ~CookieTreeDatabasesNode() override
;
360 DetailedInfo
GetDetailedInfo() const override
;
362 void AddDatabaseNode(CookieTreeDatabaseNode
* child
) {
363 AddChildSortedByTitle(child
);
367 DISALLOW_COPY_AND_ASSIGN(CookieTreeDatabasesNode
);
370 // CookieTreeFileSystemNode --------------------------------------------------
371 class CookieTreeFileSystemNode
: public CookieTreeNode
{
373 friend class CookieTreeFileSystemsNode
;
375 // file_system_info should remain valid at least as long as the
376 // CookieTreeFileSystemNode is valid.
377 explicit CookieTreeFileSystemNode(
378 std::list
<BrowsingDataFileSystemHelper::FileSystemInfo
>::iterator
380 ~CookieTreeFileSystemNode() override
;
382 void DeleteStoredObjects() override
;
383 DetailedInfo
GetDetailedInfo() const override
;
386 // file_system_info_ expected to remain valid as long as the
387 // CookieTreeFileSystemNode is valid.
388 std::list
<BrowsingDataFileSystemHelper::FileSystemInfo
>::iterator
391 DISALLOW_COPY_AND_ASSIGN(CookieTreeFileSystemNode
);
394 class CookieTreeFileSystemsNode
: public CookieTreeNode
{
396 CookieTreeFileSystemsNode();
397 ~CookieTreeFileSystemsNode() override
;
399 DetailedInfo
GetDetailedInfo() const override
;
401 void AddFileSystemNode(CookieTreeFileSystemNode
* child
) {
402 AddChildSortedByTitle(child
);
406 DISALLOW_COPY_AND_ASSIGN(CookieTreeFileSystemsNode
);
409 // CookieTreeLocalStorageNode -------------------------------------------------
410 class CookieTreeLocalStorageNode
: public CookieTreeNode
{
412 // local_storage_info should remain valid at least as long as the
413 // CookieTreeLocalStorageNode is valid.
414 explicit CookieTreeLocalStorageNode(
415 std::list
<BrowsingDataLocalStorageHelper::LocalStorageInfo
>::iterator
417 ~CookieTreeLocalStorageNode() override
;
419 // CookieTreeNode methods:
420 void DeleteStoredObjects() override
;
421 DetailedInfo
GetDetailedInfo() const override
;
424 // local_storage_info_ is expected to remain valid as long as the
425 // CookieTreeLocalStorageNode is valid.
426 std::list
<BrowsingDataLocalStorageHelper::LocalStorageInfo
>::iterator
429 DISALLOW_COPY_AND_ASSIGN(CookieTreeLocalStorageNode
);
432 class CookieTreeLocalStoragesNode
: public CookieTreeNode
{
434 CookieTreeLocalStoragesNode();
435 ~CookieTreeLocalStoragesNode() override
;
437 DetailedInfo
GetDetailedInfo() const override
;
439 void AddLocalStorageNode(CookieTreeLocalStorageNode
* child
) {
440 AddChildSortedByTitle(child
);
444 DISALLOW_COPY_AND_ASSIGN(CookieTreeLocalStoragesNode
);
448 // CookieTreeSessionStorageNode -----------------------------------------------
449 class CookieTreeSessionStorageNode
: public CookieTreeNode
{
451 // session_storage_info should remain valid at least as long as the
452 // CookieTreeSessionStorageNode is valid.
453 explicit CookieTreeSessionStorageNode(
454 std::list
<BrowsingDataLocalStorageHelper::LocalStorageInfo
>::iterator
455 session_storage_info
);
456 ~CookieTreeSessionStorageNode() override
;
458 // CookieTreeNode methods:
459 void DeleteStoredObjects() override
;
460 DetailedInfo
GetDetailedInfo() const override
;
463 // session_storage_info_ is expected to remain valid as long as the
464 // CookieTreeSessionStorageNode is valid.
465 std::list
<BrowsingDataLocalStorageHelper::LocalStorageInfo
>::iterator
466 session_storage_info_
;
468 DISALLOW_COPY_AND_ASSIGN(CookieTreeSessionStorageNode
);
471 class CookieTreeSessionStoragesNode
: public CookieTreeNode
{
473 CookieTreeSessionStoragesNode();
474 ~CookieTreeSessionStoragesNode() override
;
476 DetailedInfo
GetDetailedInfo() const override
;
478 void AddSessionStorageNode(CookieTreeSessionStorageNode
* child
) {
479 AddChildSortedByTitle(child
);
483 DISALLOW_COPY_AND_ASSIGN(CookieTreeSessionStoragesNode
);
486 // CookieTreeIndexedDBNode -----------------------------------------------
487 class CookieTreeIndexedDBNode
: public CookieTreeNode
{
489 // indexed_db_info should remain valid at least as long as the
490 // CookieTreeIndexedDBNode is valid.
491 explicit CookieTreeIndexedDBNode(
492 std::list
<content::IndexedDBInfo
>::iterator
494 ~CookieTreeIndexedDBNode() override
;
496 // CookieTreeNode methods:
497 void DeleteStoredObjects() override
;
498 DetailedInfo
GetDetailedInfo() const override
;
501 // indexed_db_info_ is expected to remain valid as long as the
502 // CookieTreeIndexedDBNode is valid.
503 std::list
<content::IndexedDBInfo
>::iterator
506 DISALLOW_COPY_AND_ASSIGN(CookieTreeIndexedDBNode
);
509 class CookieTreeIndexedDBsNode
: public CookieTreeNode
{
511 CookieTreeIndexedDBsNode();
512 ~CookieTreeIndexedDBsNode() override
;
514 DetailedInfo
GetDetailedInfo() const override
;
516 void AddIndexedDBNode(CookieTreeIndexedDBNode
* child
) {
517 AddChildSortedByTitle(child
);
521 DISALLOW_COPY_AND_ASSIGN(CookieTreeIndexedDBsNode
);
524 // CookieTreeQuotaNode --------------------------------------------------
525 class CookieTreeQuotaNode
: public CookieTreeNode
{
527 // quota_info should remain valid at least as long as the CookieTreeQuotaNode
529 explicit CookieTreeQuotaNode(
530 std::list
<BrowsingDataQuotaHelper::QuotaInfo
>::iterator quota_info
);
531 ~CookieTreeQuotaNode() override
;
533 void DeleteStoredObjects() override
;
534 DetailedInfo
GetDetailedInfo() const override
;
537 // quota_info_ is expected to remain valid as long as the CookieTreeQuotaNode
539 std::list
<BrowsingDataQuotaHelper::QuotaInfo
>::iterator quota_info_
;
541 DISALLOW_COPY_AND_ASSIGN(CookieTreeQuotaNode
);
544 // CookieTreeChannelIDNode ---------------------------------------------
545 class CookieTreeChannelIDNode
: public CookieTreeNode
{
547 friend class CookieTreeChannelIDsNode
;
549 // The iterator should remain valid at least as long as the
550 // CookieTreeChannelIDNode is valid.
551 explicit CookieTreeChannelIDNode(
552 net::ChannelIDStore::ChannelIDList::iterator cert
);
553 ~CookieTreeChannelIDNode() override
;
555 // CookieTreeNode methods:
556 void DeleteStoredObjects() override
;
557 DetailedInfo
GetDetailedInfo() const override
;
560 // channel_id_ is expected to remain valid as long as the
561 // CookieTreeChannelIDNode is valid.
562 net::ChannelIDStore::ChannelIDList::iterator channel_id_
;
564 DISALLOW_COPY_AND_ASSIGN(CookieTreeChannelIDNode
);
567 class CookieTreeChannelIDsNode
: public CookieTreeNode
{
569 CookieTreeChannelIDsNode();
570 ~CookieTreeChannelIDsNode() override
;
572 DetailedInfo
GetDetailedInfo() const override
;
574 void AddChannelIDNode(CookieTreeChannelIDNode
* child
) {
575 AddChildSortedByTitle(child
);
579 DISALLOW_COPY_AND_ASSIGN(CookieTreeChannelIDsNode
);
582 // CookieTreeServiceWorkerNode -----------------------------------------------
583 class CookieTreeServiceWorkerNode
: public CookieTreeNode
{
585 // service_worker_info should remain valid at least as long as the
586 // CookieTreeServiceWorkerNode is valid.
587 explicit CookieTreeServiceWorkerNode(
588 std::list
<content::ServiceWorkerUsageInfo
>::iterator service_worker_info
);
589 ~CookieTreeServiceWorkerNode() override
;
591 // CookieTreeNode methods:
592 void DeleteStoredObjects() override
;
593 DetailedInfo
GetDetailedInfo() const override
;
596 // service_worker_info_ is expected to remain valid as long as the
597 // CookieTreeServiceWorkerNode is valid.
598 std::list
<content::ServiceWorkerUsageInfo
>::iterator service_worker_info_
;
600 DISALLOW_COPY_AND_ASSIGN(CookieTreeServiceWorkerNode
);
603 class CookieTreeServiceWorkersNode
: public CookieTreeNode
{
605 CookieTreeServiceWorkersNode();
606 ~CookieTreeServiceWorkersNode() override
;
608 DetailedInfo
GetDetailedInfo() const override
;
610 void AddServiceWorkerNode(CookieTreeServiceWorkerNode
* child
) {
611 AddChildSortedByTitle(child
);
615 DISALLOW_COPY_AND_ASSIGN(CookieTreeServiceWorkersNode
);
618 // CookieTreeFlashLSONode ----------------------------------------------------
619 class CookieTreeFlashLSONode
: public CookieTreeNode
{
621 explicit CookieTreeFlashLSONode(const std::string
& domain
);
622 ~CookieTreeFlashLSONode() override
;
624 // CookieTreeNode methods:
625 void DeleteStoredObjects() override
;
626 DetailedInfo
GetDetailedInfo() const override
;
631 DISALLOW_COPY_AND_ASSIGN(CookieTreeFlashLSONode
);
634 // CookiesTreeModel -----------------------------------------------------------
635 class CookiesTreeModel
: public ui::TreeNodeModel
<CookieTreeNode
> {
637 CookiesTreeModel(LocalDataContainer
* data_container
,
638 ExtensionSpecialStoragePolicy
* special_storage_policy
,
639 bool group_by_cookie_source
);
640 ~CookiesTreeModel() override
;
642 // Given a CanonicalCookie, return the ID of the message which should be
643 // displayed in various ports' "Send for:" UI.
644 static int GetSendForMessageID(const net::CanonicalCookie
& cookie
);
646 // Because non-cookie nodes are fetched in a background thread, they are not
647 // present at the time the Model is created. The Model then notifies its
648 // observers for every item added from databases, local storage, and
649 // appcache. We extend the Observer interface to add notifications before and
650 // after these batch inserts.
651 class Observer
: public ui::TreeModelObserver
{
653 virtual void TreeModelBeginBatch(CookiesTreeModel
* model
) {}
654 virtual void TreeModelEndBatch(CookiesTreeModel
* model
) {}
657 // This class defines the scope for batch updates. It can be created as a
658 // local variable and the destructor will terminate the batch update, if one
660 class ScopedBatchUpdateNotifier
{
662 ScopedBatchUpdateNotifier(CookiesTreeModel
* model
,
663 CookieTreeNode
* node
);
664 ~ScopedBatchUpdateNotifier();
666 void StartBatchUpdate();
669 CookiesTreeModel
* model_
;
670 CookieTreeNode
* node_
;
671 bool batch_in_progress_
;
674 // ui::TreeModel methods:
675 // Returns the set of icons for the nodes in the tree. You only need override
676 // this if you don't want to use the default folder icons.
677 void GetIcons(std::vector
<gfx::ImageSkia
>* icons
) override
;
679 // Returns the index of the icon to use for |node|. Return -1 to use the
680 // default icon. The index is relative to the list of icons returned from
682 int GetIconIndex(ui::TreeModelNode
* node
) override
;
684 // CookiesTreeModel methods:
685 void DeleteAllStoredObjects();
687 // Deletes a specific node in the tree, identified by |cookie_node|, and its
689 void DeleteCookieNode(CookieTreeNode
* cookie_node
);
691 // Filter the origins to only display matched results.
692 void UpdateSearchResults(const base::string16
& filter
);
694 #if defined(ENABLE_EXTENSIONS)
695 // Returns the set of extensions which protect the data item represented by
696 // this node from deletion.
697 // Returns NULL if the node doesn't represent a protected data item or the
698 // special storage policy is NULL.
699 const extensions::ExtensionSet
* ExtensionsProtectingNode(
700 const CookieTreeNode
& cookie_node
);
703 // Manages CookiesTreeModel::Observers. This will also call
704 // TreeNodeModel::AddObserver so that it gets all the proper notifications.
705 // Note that the converse is not true: simply adding a TreeModelObserver will
706 // not get CookiesTreeModel::Observer notifications.
707 virtual void AddCookiesTreeObserver(Observer
* observer
);
708 virtual void RemoveCookiesTreeObserver(Observer
* observer
);
710 // Methods that update the model based on the data retrieved by the browsing
712 void PopulateAppCacheInfo(LocalDataContainer
* container
);
713 void PopulateCookieInfo(LocalDataContainer
* container
);
714 void PopulateDatabaseInfo(LocalDataContainer
* container
);
715 void PopulateLocalStorageInfo(LocalDataContainer
* container
);
716 void PopulateSessionStorageInfo(LocalDataContainer
* container
);
717 void PopulateIndexedDBInfo(LocalDataContainer
* container
);
718 void PopulateFileSystemInfo(LocalDataContainer
* container
);
719 void PopulateQuotaInfo(LocalDataContainer
* container
);
720 void PopulateChannelIDInfo(LocalDataContainer
* container
);
721 void PopulateServiceWorkerUsageInfo(LocalDataContainer
* container
);
722 void PopulateFlashLSOInfo(LocalDataContainer
* container
);
724 BrowsingDataCookieHelper
* GetCookieHelper(const std::string
& app_id
);
725 LocalDataContainer
* data_container() {
726 return data_container_
.get();
729 // Set the number of |batches_expected| this class should expect to receive.
730 // If |reset| is true, then this is a new set of batches, but if false, then
731 // this is a revised number (batches originally counted should no longer be
733 void SetBatchExpectation(int batches_expected
, bool reset
);
736 enum CookieIconIndex
{
742 // Reset the counters for batches.
745 // Record that one batch has been delivered.
746 void RecordBatchSeen();
748 // Record that one batch has begun processing. If this is the first batch then
749 // observers will be notified that batch processing has started.
750 void NotifyObserverBeginBatch();
752 // Record that one batch has finished processing. If this is the last batch
753 // then observers will be notified that batch processing has ended.
754 void NotifyObserverEndBatch();
756 // Notifies observers if expected batch count has been delievered and all
757 // batches have finished processing.
758 void MaybeNotifyBatchesEnded();
760 void PopulateAppCacheInfoWithFilter(LocalDataContainer
* container
,
761 ScopedBatchUpdateNotifier
* notifier
,
762 const base::string16
& filter
);
763 void PopulateCookieInfoWithFilter(LocalDataContainer
* container
,
764 ScopedBatchUpdateNotifier
* notifier
,
765 const base::string16
& filter
);
766 void PopulateDatabaseInfoWithFilter(LocalDataContainer
* container
,
767 ScopedBatchUpdateNotifier
* notifier
,
768 const base::string16
& filter
);
769 void PopulateLocalStorageInfoWithFilter(LocalDataContainer
* container
,
770 ScopedBatchUpdateNotifier
* notifier
,
771 const base::string16
& filter
);
772 void PopulateSessionStorageInfoWithFilter(LocalDataContainer
* container
,
773 ScopedBatchUpdateNotifier
* notifier
,
774 const base::string16
& filter
);
775 void PopulateIndexedDBInfoWithFilter(LocalDataContainer
* container
,
776 ScopedBatchUpdateNotifier
* notifier
,
777 const base::string16
& filter
);
778 void PopulateFileSystemInfoWithFilter(LocalDataContainer
* container
,
779 ScopedBatchUpdateNotifier
* notifier
,
780 const base::string16
& filter
);
781 void PopulateQuotaInfoWithFilter(LocalDataContainer
* container
,
782 ScopedBatchUpdateNotifier
* notifier
,
783 const base::string16
& filter
);
784 void PopulateChannelIDInfoWithFilter(
785 LocalDataContainer
* container
,
786 ScopedBatchUpdateNotifier
* notifier
,
787 const base::string16
& filter
);
788 void PopulateServiceWorkerUsageInfoWithFilter(
789 LocalDataContainer
* container
,
790 ScopedBatchUpdateNotifier
* notifier
,
791 const base::string16
& filter
);
792 void PopulateFlashLSOInfoWithFilter(LocalDataContainer
* container
,
793 ScopedBatchUpdateNotifier
* notifier
,
794 const base::string16
& filter
);
796 // Map of app ids to LocalDataContainer objects to use when retrieving
797 // locally stored data.
798 scoped_ptr
<LocalDataContainer
> data_container_
;
800 #if defined(ENABLE_EXTENSIONS)
801 // The extension special storage policy; see ExtensionsProtectingNode() above.
802 scoped_refptr
<ExtensionSpecialStoragePolicy
> special_storage_policy_
;
805 // The CookiesTreeModel maintains a separate list of observers that are
806 // specifically of the type CookiesTreeModel::Observer.
807 base::ObserverList
<Observer
> cookies_observer_list_
;
809 // If true, use the CanonicalCookie::Source attribute to group cookies.
810 // Otherwise, use the CanonicalCookie::Domain attribute.
811 bool group_by_cookie_source_
;
813 // Keeps track of how many batches the consumer of this class says it is going
815 int batches_expected_
;
817 // Keeps track of how many batches we've seen.
820 // Counts how many batches have started already. If this is non-zero and lower
821 // than batches_ended_, then this model is still batching updates.
822 int batches_started_
;
824 // Counts how many batches have finished.
828 #endif // CHROME_BROWSER_BROWSING_DATA_COOKIES_TREE_MODEL_H_