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/common/content_settings.h" | 24 #include "chrome/common/content_settings.h" |
25 #include "net/base/cookie_monster.h" | 25 #include "net/base/cookie_monster.h" |
26 #include "ui/base/models/tree_node_model.h" | 26 #include "ui/base/models/tree_node_model.h" |
27 | 27 |
28 class BrowsingDataCookieHelper; | |
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; |
(...skipping 24 matching lines...) Expand all Loading... |
63 TYPE_DATABASES, // This is used for CookieTreeDatabasesNode. | 62 TYPE_DATABASES, // This is used for CookieTreeDatabasesNode. |
64 TYPE_DATABASE, // This is used for CookieTreeDatabaseNode. | 63 TYPE_DATABASE, // This is used for CookieTreeDatabaseNode. |
65 TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. | 64 TYPE_LOCAL_STORAGES, // This is used for CookieTreeLocalStoragesNode. |
66 TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. | 65 TYPE_LOCAL_STORAGE, // This is used for CookieTreeLocalStorageNode. |
67 TYPE_SESSION_STORAGES, // This is used for CookieTreeSessionStoragesNode. | 66 TYPE_SESSION_STORAGES, // This is used for CookieTreeSessionStoragesNode. |
68 TYPE_SESSION_STORAGE, // This is used for CookieTreeSessionStorageNode. | 67 TYPE_SESSION_STORAGE, // This is used for CookieTreeSessionStorageNode. |
69 TYPE_APPCACHES, // This is used for CookieTreeAppCachesNode. | 68 TYPE_APPCACHES, // This is used for CookieTreeAppCachesNode. |
70 TYPE_APPCACHE, // This is used for CookieTreeAppCacheNode. | 69 TYPE_APPCACHE, // This is used for CookieTreeAppCacheNode. |
71 TYPE_INDEXED_DBS, // This is used for CookieTreeIndexedDBsNode. | 70 TYPE_INDEXED_DBS, // This is used for CookieTreeIndexedDBsNode. |
72 TYPE_INDEXED_DB, // This is used for CookieTreeIndexedDBNode. | 71 TYPE_INDEXED_DB, // This is used for CookieTreeIndexedDBNode. |
73 TYPE_FILE_SYSTEMS, // This is used for CookieTreeFileSystemsNode. | 72 TYPE_FILE_SYSTEMS, // This is used for CookieTreeFileSystemsNode. |
74 TYPE_FILE_SYSTEM, // This is used for CookieTreeFileSystemNode. | 73 TYPE_FILE_SYSTEM, // This is used for CookieTreeFileSystemNode. |
75 }; | 74 }; |
76 | 75 |
77 // 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 |
78 // |string16| or a (UTF-8) |std::string|, and convert. Remove constructor | 77 // |string16| or a (UTF-8) |std::string|, and convert. Remove constructor |
79 // taking an |std::wstring|. | 78 // taking an |std::wstring|. |
80 DetailedInfo(const string16& origin, NodeType node_type, | 79 DetailedInfo(const string16& origin, NodeType node_type, |
81 const net::CookieMonster::CanonicalCookie* cookie, | 80 const net::CookieMonster::CanonicalCookie* cookie, |
82 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info, | 81 const BrowsingDataDatabaseHelper::DatabaseInfo* database_info, |
83 const BrowsingDataLocalStorageHelper::LocalStorageInfo* | 82 const BrowsingDataLocalStorageHelper::LocalStorageInfo* |
84 local_storage_info, | 83 local_storage_info, |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 // observers for every item added from databases, local storage, and | 507 // observers for every item added from databases, local storage, and |
509 // appcache. We extend the Observer interface to add notifications before and | 508 // appcache. We extend the Observer interface to add notifications before and |
510 // after these batch inserts. | 509 // after these batch inserts. |
511 class Observer : public ui::TreeModelObserver { | 510 class Observer : public ui::TreeModelObserver { |
512 public: | 511 public: |
513 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} | 512 virtual void TreeModelBeginBatch(CookiesTreeModel* model) {} |
514 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} | 513 virtual void TreeModelEndBatch(CookiesTreeModel* model) {} |
515 }; | 514 }; |
516 | 515 |
517 CookiesTreeModel( | 516 CookiesTreeModel( |
518 BrowsingDataCookieHelper* cookie_helper, | 517 net::CookieMonster* cookie_monster_, |
519 BrowsingDataDatabaseHelper* database_helper, | 518 BrowsingDataDatabaseHelper* database_helper, |
520 BrowsingDataLocalStorageHelper* local_storage_helper, | 519 BrowsingDataLocalStorageHelper* local_storage_helper, |
521 BrowsingDataLocalStorageHelper* session_storage_helper, | 520 BrowsingDataLocalStorageHelper* session_storage_helper, |
522 BrowsingDataAppCacheHelper* appcache_helper, | 521 BrowsingDataAppCacheHelper* appcache_helper, |
523 BrowsingDataIndexedDBHelper* indexed_db_helper, | 522 BrowsingDataIndexedDBHelper* indexed_db_helper, |
524 BrowsingDataFileSystemHelper* file_system_helper, | 523 BrowsingDataFileSystemHelper* file_system_helper, |
525 bool use_cookie_source); | 524 bool use_cookie_source); |
526 virtual ~CookiesTreeModel(); | 525 virtual ~CookiesTreeModel(); |
527 | 526 |
528 // ui::TreeModel methods: | 527 // ui::TreeModel methods: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 DatabaseInfoList; | 559 DatabaseInfoList; |
561 typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> | 560 typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
562 LocalStorageInfoList; | 561 LocalStorageInfoList; |
563 typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> | 562 typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
564 SessionStorageInfoList; | 563 SessionStorageInfoList; |
565 typedef std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> | 564 typedef std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> |
566 IndexedDBInfoList; | 565 IndexedDBInfoList; |
567 typedef std::vector<BrowsingDataFileSystemHelper::FileSystemInfo> | 566 typedef std::vector<BrowsingDataFileSystemHelper::FileSystemInfo> |
568 FileSystemInfoList; | 567 FileSystemInfoList; |
569 | 568 |
| 569 void LoadCookies(); |
| 570 void LoadCookiesWithFilter(const std::wstring& filter); |
| 571 |
570 void OnAppCacheModelInfoLoaded(); | 572 void OnAppCacheModelInfoLoaded(); |
571 void OnCookiesModelInfoLoaded(const CookieList& cookie_list); | |
572 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); | 573 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); |
573 void OnLocalStorageModelInfoLoaded( | 574 void OnLocalStorageModelInfoLoaded( |
574 const LocalStorageInfoList& local_storage_info); | 575 const LocalStorageInfoList& local_storage_info); |
575 void OnSessionStorageModelInfoLoaded( | 576 void OnSessionStorageModelInfoLoaded( |
576 const LocalStorageInfoList& local_storage_info); | 577 const LocalStorageInfoList& local_storage_info); |
577 void OnIndexedDBModelInfoLoaded( | 578 void OnIndexedDBModelInfoLoaded( |
578 const IndexedDBInfoList& indexed_db_info); | 579 const IndexedDBInfoList& indexed_db_info); |
579 void OnFileSystemModelInfoLoaded( | 580 void OnFileSystemModelInfoLoaded( |
580 const FileSystemInfoList& file_system_info); | 581 const FileSystemInfoList& file_system_info); |
581 | 582 |
582 void PopulateAppCacheInfoWithFilter(const std::wstring& filter); | 583 void PopulateAppCacheInfoWithFilter(const std::wstring& filter); |
583 void PopulateCookieInfoWithFilter(const std::wstring& filter); | |
584 void PopulateDatabaseInfoWithFilter(const std::wstring& filter); | 584 void PopulateDatabaseInfoWithFilter(const std::wstring& filter); |
585 void PopulateLocalStorageInfoWithFilter(const std::wstring& filter); | 585 void PopulateLocalStorageInfoWithFilter(const std::wstring& filter); |
586 void PopulateSessionStorageInfoWithFilter(const std::wstring& filter); | 586 void PopulateSessionStorageInfoWithFilter(const std::wstring& filter); |
587 void PopulateIndexedDBInfoWithFilter(const std::wstring& filter); | 587 void PopulateIndexedDBInfoWithFilter(const std::wstring& filter); |
588 void PopulateFileSystemInfoWithFilter(const std::wstring& filter); | 588 void PopulateFileSystemInfoWithFilter(const std::wstring& filter); |
589 | 589 |
590 void NotifyObserverBeginBatch(); | 590 void NotifyObserverBeginBatch(); |
591 void NotifyObserverEndBatch(); | 591 void NotifyObserverEndBatch(); |
592 | 592 |
| 593 scoped_refptr<net::CookieMonster> cookie_monster_; |
| 594 CookieList all_cookies_; |
| 595 |
593 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; | 596 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; |
594 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; | |
595 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; | 597 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; |
| 598 scoped_refptr<appcache::AppCacheInfoCollection> appcache_info_; |
| 599 DatabaseInfoList database_info_list_; |
| 600 |
596 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; | 601 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; |
597 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; | 602 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; |
598 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; | 603 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; |
599 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; | 604 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; |
600 | |
601 scoped_refptr<appcache::AppCacheInfoCollection> appcache_info_; | |
602 CookieList cookie_list_; | |
603 DatabaseInfoList database_info_list_; | |
604 LocalStorageInfoList local_storage_info_list_; | 605 LocalStorageInfoList local_storage_info_list_; |
605 LocalStorageInfoList session_storage_info_list_; | 606 LocalStorageInfoList session_storage_info_list_; |
606 IndexedDBInfoList indexed_db_info_list_; | 607 IndexedDBInfoList indexed_db_info_list_; |
607 FileSystemInfoList file_system_info_list_; | 608 FileSystemInfoList file_system_info_list_; |
608 | 609 |
609 // The CookiesTreeModel maintains a separate list of observers that are | 610 // The CookiesTreeModel maintains a separate list of observers that are |
610 // specifically of the type CookiesTreeModel::Observer. | 611 // specifically of the type CookiesTreeModel::Observer. |
611 ObserverList<Observer> cookies_observer_list_; | 612 ObserverList<Observer> cookies_observer_list_; |
612 | 613 |
613 // 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 |
614 // 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 |
615 // 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. |
616 int batch_update_; | 617 int batch_update_; |
617 | 618 |
618 // If true, use the CanonicalCookie::Source attribute to group cookies. | 619 // If true, use the CanonicalCookie::Source attribute to group cookies. |
619 // Otherwise, use the CanonicalCookie::Domain attribute. | 620 // Otherwise, use the CanonicalCookie::Domain attribute. |
620 bool use_cookie_source_; | 621 bool use_cookie_source_; |
621 | 622 |
622 friend class CookieTreeAppCacheNode; | 623 friend class CookieTreeAppCacheNode; |
623 friend class CookieTreeCookieNode; | 624 friend class CookieTreeCookieNode; |
624 friend class CookieTreeDatabaseNode; | 625 friend class CookieTreeDatabaseNode; |
625 friend class CookieTreeLocalStorageNode; | 626 friend class CookieTreeLocalStorageNode; |
626 friend class CookieTreeIndexedDBNode; | 627 friend class CookieTreeIndexedDBNode; |
627 friend class CookieTreeFileSystemNode; | 628 friend class CookieTreeFileSystemNode; |
628 | 629 |
629 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); | 630 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); |
630 }; | 631 }; |
631 | 632 |
632 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ | 633 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
OLD | NEW |