Index: chrome/browser/cookies_tree_model.h |
diff --git a/chrome/browser/cookies_tree_model.h b/chrome/browser/cookies_tree_model.h |
index e99fa7f5188930d2aab740e58e49744c74e18ac8..a732d2f5419ff671c1b345cf2b3a0d5342e3ac4f 100644 |
--- a/chrome/browser/cookies_tree_model.h |
+++ b/chrome/browser/cookies_tree_model.h |
@@ -24,6 +24,7 @@ |
#include "chrome/browser/browsing_data_indexed_db_helper.h" |
#include "chrome/browser/browsing_data_local_storage_helper.h" |
#include "chrome/browser/browsing_data_quota_helper.h" |
+#include "chrome/browser/local_data_container.h" |
#include "chrome/common/content_settings.h" |
#include "net/base/server_bound_cert_store.h" |
#include "net/cookies/cookie_monster.h" |
@@ -39,18 +40,19 @@ class CookieTreeCookieNode; |
class CookieTreeCookiesNode; |
class CookieTreeDatabaseNode; |
class CookieTreeDatabasesNode; |
-class CookieTreeFileSystemsNode; |
class CookieTreeFileSystemNode; |
+class CookieTreeFileSystemsNode; |
+class CookieTreeIndexedDBNode; |
+class CookieTreeIndexedDBsNode; |
class CookieTreeLocalStorageNode; |
class CookieTreeLocalStoragesNode; |
+class CookieTreeOriginNode; |
+class CookieTreeQuotaNode; |
class CookieTreeServerBoundCertNode; |
class CookieTreeServerBoundCertsNode; |
-class CookieTreeQuotaNode; |
class CookieTreeSessionStorageNode; |
class CookieTreeSessionStoragesNode; |
-class CookieTreeIndexedDBNode; |
-class CookieTreeIndexedDBsNode; |
-class CookieTreeOriginNode; |
+ |
// CookieTreeNode ------------------------------------------------------------- |
// The base node type in the Cookies, Databases, and Local Storage options |
@@ -107,6 +109,14 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { |
return *this; |
} |
+ DetailedInfo& InitOrigin(const std::string& app_id, |
+ const std::string& app_name) { |
+ Init(TYPE_ORIGIN); |
+ this->app_name = app_name; |
+ this->app_id = app_id; |
+ return *this; |
+ } |
+ |
DetailedInfo& InitCookie( |
const net::CookieMonster::CanonicalCookie* cookie) { |
Init(TYPE_COOKIE); |
@@ -171,6 +181,8 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { |
return *this; |
} |
+ std::string app_name; |
+ std::string app_id; |
string16 origin; |
NodeType node_type; |
const net::CookieMonster::CanonicalCookie* cookie; |
@@ -202,6 +214,8 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { |
virtual DetailedInfo GetDetailedInfo() const = 0; |
protected: |
+ // This class implements comparison by title of a CookieTreeNode. It is |
+ // used to insert nodes in alphabetical order. |
class NodeTitleComparator { |
public: |
bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); |
@@ -221,7 +235,9 @@ class CookieTreeRootNode : public CookieTreeNode { |
explicit CookieTreeRootNode(CookiesTreeModel* model); |
virtual ~CookieTreeRootNode(); |
- CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); |
+ CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url, |
+ const std::string& app_id, |
+ const std::string& app_name); |
// CookieTreeNode methods: |
virtual CookiesTreeModel* GetModel() const OVERRIDE; |
@@ -237,9 +253,13 @@ class CookieTreeRootNode : public CookieTreeNode { |
class CookieTreeOriginNode : public CookieTreeNode { |
public: |
// Returns the origin node's title to use for a given URL. |
- static std::wstring TitleForUrl(const GURL& url); |
+ static string16 TitleForUrl(const GURL& url, |
+ const std::string& app_id, |
+ const std::string& app_name); |
- explicit CookieTreeOriginNode(const GURL& url); |
+ explicit CookieTreeOriginNode(const GURL& url, |
+ const std::string& app_id, |
+ const std::string& app_name); |
virtual ~CookieTreeOriginNode(); |
// CookieTreeNode methods: |
@@ -265,6 +285,10 @@ class CookieTreeOriginNode : public CookieTreeNode { |
// True if a content exception can be created for this origin. |
bool CanCreateContentException() const; |
+ const std::string& app_id() const { return app_id_; } |
+ const std::string& app_name() const { return app_name_; } |
+ const std::string GetHost() const; |
+ |
private: |
// Pointers to the cookies, databases, local and session storage and appcache |
// nodes. When we build up the tree we need to quickly get a reference to |
@@ -281,6 +305,9 @@ class CookieTreeOriginNode : public CookieTreeNode { |
CookieTreeQuotaNode* quota_child_; |
CookieTreeServerBoundCertsNode* server_bound_certs_child_; |
+ std::string app_id_; |
+ std::string app_name_; |
+ |
// The URL for which this node was initially created. |
GURL url_; |
@@ -614,9 +641,44 @@ class CookieTreeServerBoundCertsNode : public CookieTreeNode { |
DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); |
}; |
+// CookiesTreeModelDelegate --------------------------------------------------- |
+// This is a delegate definition class. It is used by the CookiesTreeModel |
+// to pass a pointer to itself to each of the LocalDataContainer objects, so |
+// when resource fetching is complete, the objects can call back to the model |
+// and update it. The CookiesTreeModel instance must outlive the |
+// LocalDataContainer instances. |
+class CookiesTreeModelDelegate { |
+ public: |
+ virtual void PopulateAppCacheInfoWithFilter( |
+ const std::string* app_id, const string16& filter) = 0; |
+ virtual void PopulateCookieInfoWithFilter( |
+ const std::string* app_id, const string16& filter) = 0; |
+ virtual void PopulateDatabaseInfoWithFilter( |
+ const std::string* app_id, const string16& filter) = 0; |
+ virtual void PopulateLocalStorageInfoWithFilter( |
+ const std::string* app_id, const string16& filter) = 0; |
+ virtual void PopulateSessionStorageInfoWithFilter( |
+ const std::string* app_id, const string16& filter) = 0; |
+ virtual void PopulateIndexedDBInfoWithFilter( |
+ const std::string* app_id, const string16& filter) = 0; |
+ virtual void PopulateFileSystemInfoWithFilter( |
+ const std::string* app_id, const string16& filter) = 0; |
+ virtual void PopulateQuotaInfoWithFilter( |
+ const std::string* app_id, const string16& filter) = 0; |
+ virtual void PopulateServerBoundCertInfoWithFilter( |
+ const std::string* app_id, const string16& filter) = 0; |
+ |
+ protected: |
+ virtual ~CookiesTreeModelDelegate() {} |
+}; |
+ |
// CookiesTreeModel ----------------------------------------------------------- |
-class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
+class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode>, |
+ public CookiesTreeModelDelegate { |
Bernhard Bauer
2012/06/26 21:03:55
Wait, CookiesTreeModel is a CookiesTreeModelDelega
nasko
2012/06/26 22:33:16
Done.
|
public: |
+ CookiesTreeModel(const ContainerMap& apps_map, bool use_cookie_source); |
+ virtual ~CookiesTreeModel(); |
+ |
// Because non-cookie nodes are fetched in a background thread, they are not |
// present at the time the Model is created. The Model then notifies its |
// observers for every item added from databases, local storage, and |
@@ -628,19 +690,6 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
virtual void TreeModelEndBatch(CookiesTreeModel* model) {} |
}; |
- CookiesTreeModel( |
- BrowsingDataCookieHelper* cookie_helper, |
- BrowsingDataDatabaseHelper* database_helper, |
- BrowsingDataLocalStorageHelper* local_storage_helper, |
- BrowsingDataLocalStorageHelper* session_storage_helper, |
- BrowsingDataAppCacheHelper* appcache_helper, |
- BrowsingDataIndexedDBHelper* indexed_db_helper, |
- BrowsingDataFileSystemHelper* file_system_helper, |
- BrowsingDataQuotaHelper* quota_helper, |
- BrowsingDataServerBoundCertHelper* server_bound_cert_helper, |
- bool use_cookie_source); |
- virtual ~CookiesTreeModel(); |
- |
// ui::TreeModel methods: |
// Returns the set of icons for the nodes in the tree. You only need override |
// this if you don't want to use the default folder icons. |
@@ -653,10 +702,13 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
// CookiesTreeModel methods: |
void DeleteAllStoredObjects(); |
+ |
+ // Deletes a specific node in the tree, identified by |cookie_node|, and its |
+ // subtree. |
void DeleteCookieNode(CookieTreeNode* cookie_node); |
// Filter the origins to only display matched results. |
- void UpdateSearchResults(const std::wstring& filter); |
+ void UpdateSearchResults(const string16& filter); |
// Manages CookiesTreeModel::Observers. This will also call |
// TreeNodeModel::AddObserver so that it gets all the proper notifications. |
@@ -665,99 +717,55 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
virtual void AddCookiesTreeObserver(Observer* observer); |
virtual void RemoveCookiesTreeObserver(Observer* observer); |
+ // CookiesTreeModelDelegate methods: |
+ virtual void PopulateAppCacheInfoWithFilter( |
+ const std::string* app_id, const string16& filter) OVERRIDE; |
+ virtual void PopulateCookieInfoWithFilter( |
+ const std::string* app_id, const string16& filter) OVERRIDE; |
+ virtual void PopulateDatabaseInfoWithFilter( |
+ const std::string* app_id, const string16& filter) OVERRIDE; |
+ virtual void PopulateLocalStorageInfoWithFilter( |
+ const std::string* app_id, const string16& filter) OVERRIDE; |
+ virtual void PopulateSessionStorageInfoWithFilter( |
+ const std::string* app_id, const string16& filter) OVERRIDE; |
+ virtual void PopulateIndexedDBInfoWithFilter( |
+ const std::string* app_id, const string16& filter) OVERRIDE; |
+ virtual void PopulateFileSystemInfoWithFilter( |
+ const std::string* app_id, const string16& filter) OVERRIDE; |
+ virtual void PopulateQuotaInfoWithFilter( |
+ const std::string* app_id, const string16& filter) OVERRIDE; |
+ virtual void PopulateServerBoundCertInfoWithFilter( |
+ const std::string* app_id, const string16& filter) OVERRIDE; |
+ |
+ BrowsingDataCookieHelper* GetCookieHelper(const std::string& app_id); |
+ LocalDataContainer* GetLocalDataContainer(const std::string& app_id); |
+ |
private: |
enum CookieIconIndex { |
ORIGIN = 0, |
COOKIE = 1, |
DATABASE = 2 |
}; |
- typedef std::list<net::CookieMonster::CanonicalCookie> CookieList; |
- typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo> |
- DatabaseInfoList; |
- typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
- LocalStorageInfoList; |
- typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
- SessionStorageInfoList; |
- typedef std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> |
- IndexedDBInfoList; |
- typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo> |
- FileSystemInfoList; |
- typedef std::list<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoArray; |
- typedef net::ServerBoundCertStore::ServerBoundCertList ServerBoundCertList; |
- |
- void OnAppCacheModelInfoLoaded(); |
- void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list); |
- void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); |
- void OnLocalStorageModelInfoLoaded( |
- const LocalStorageInfoList& local_storage_info); |
- void OnSessionStorageModelInfoLoaded( |
- const LocalStorageInfoList& local_storage_info); |
- void OnIndexedDBModelInfoLoaded( |
- const IndexedDBInfoList& indexed_db_info); |
- void OnFileSystemModelInfoLoaded( |
- const FileSystemInfoList& file_system_info); |
- void OnQuotaModelInfoLoaded(const QuotaInfoArray& quota_info); |
- void OnServerBoundCertModelInfoLoaded(const ServerBoundCertList& cert_list); |
- |
- void PopulateAppCacheInfoWithFilter(const std::wstring& filter); |
- void PopulateCookieInfoWithFilter(const std::wstring& filter); |
- void PopulateDatabaseInfoWithFilter(const std::wstring& filter); |
- void PopulateLocalStorageInfoWithFilter(const std::wstring& filter); |
- void PopulateSessionStorageInfoWithFilter(const std::wstring& filter); |
- void PopulateIndexedDBInfoWithFilter(const std::wstring& filter); |
- void PopulateFileSystemInfoWithFilter(const std::wstring& filter); |
- void PopulateQuotaInfoWithFilter(const std::wstring& filter); |
- void PopulateServerBoundCertInfoWithFilter(const std::wstring& filter); |
void NotifyObserverBeginBatch(); |
void NotifyObserverEndBatch(); |
- scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; |
- scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; |
- scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; |
- scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; |
- scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; |
- scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; |
- scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; |
- scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; |
- scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_; |
- |
- std::map<GURL, std::list<appcache::AppCacheInfo> > appcache_info_; |
- CookieList cookie_list_; |
- DatabaseInfoList database_info_list_; |
- LocalStorageInfoList local_storage_info_list_; |
- LocalStorageInfoList session_storage_info_list_; |
- IndexedDBInfoList indexed_db_info_list_; |
- FileSystemInfoList file_system_info_list_; |
- QuotaInfoArray quota_info_list_; |
- ServerBoundCertList server_bound_cert_list_; |
+ // Map of app ids to LocalDataContainer objects to use when retrieving |
+ // locally stored data. |
+ ContainerMap app_data_map_; |
// The CookiesTreeModel maintains a separate list of observers that are |
// specifically of the type CookiesTreeModel::Observer. |
ObserverList<Observer> cookies_observer_list_; |
- // If this is non-zero, then this model is batching updates (there's a lot of |
- // notifications coming down the pipe). This is an integer is used to balance |
- // calls to Begin/EndBatch() if they're called in a nested manner. |
- int batch_update_; |
- |
// If true, use the CanonicalCookie::Source attribute to group cookies. |
// Otherwise, use the CanonicalCookie::Domain attribute. |
bool use_cookie_source_; |
Bernhard Bauer
2012/06/26 21:03:55
|group_by_cookie_source_|?
nasko
2012/06/26 22:33:16
This was just moved around, but I think it is a go
|
- base::WeakPtrFactory<CookiesTreeModel> weak_ptr_factory_; |
- |
- friend class CookieTreeAppCacheNode; |
- friend class CookieTreeCookieNode; |
- friend class CookieTreeDatabaseNode; |
- friend class CookieTreeLocalStorageNode; |
- friend class CookieTreeSessionStorageNode; |
- friend class CookieTreeIndexedDBNode; |
- friend class CookieTreeFileSystemNode; |
- friend class CookieTreeQuotaNode; |
- friend class CookieTreeServerBoundCertNode; |
- |
- DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); |
+ // If this is non-zero, then this model is batching updates (there's a lot of |
+ // notifications coming down the pipe). This is an integer is used to balance |
+ // calls to Begin/EndBatch() if they're called in a nested manner. |
+ int batch_update_; |
}; |
#endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |