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