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..ee3504a97deeb274d418dfd4c4f3fef1ce94afeb 100644 |
--- a/chrome/browser/cookies_tree_model.h |
+++ b/chrome/browser/cookies_tree_model.h |
@@ -51,6 +51,8 @@ class CookieTreeSessionStoragesNode; |
class CookieTreeIndexedDBNode; |
class CookieTreeIndexedDBsNode; |
class CookieTreeOriginNode; |
+class CookieTreeAppNode; |
+class LocalDataContainer; |
// CookieTreeNode ------------------------------------------------------------- |
// The base node type in the Cookies, Databases, and Local Storage options |
@@ -66,6 +68,7 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { |
enum NodeType { |
TYPE_NONE, |
TYPE_ROOT, // This is used for CookieTreeRootNode nodes. |
+ TYPE_APP, // This is used for CookieTreeAppNode nodes. |
TYPE_ORIGIN, // This is used for CookieTreeOriginNode nodes. |
TYPE_COOKIES, // This is used for CookieTreeCookiesNode nodes. |
TYPE_COOKIE, // This is used for CookieTreeCookieNode nodes. |
@@ -107,6 +110,13 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { |
return *this; |
} |
+ DetailedInfo& InitApp(const string16& app_name, const string16& app_id) { |
+ Init(TYPE_APP); |
+ 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; |
} |
+ string16 app_name; |
+ string16 app_id; |
string16 origin; |
NodeType node_type; |
const net::CookieMonster::CanonicalCookie* cookie; |
@@ -207,6 +219,11 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { |
bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); |
}; |
+ class AppNodeComparator { |
+ public: |
+ bool operator() (const CookieTreeNode* lhs, const CookieTreeNode* rhs); |
+ }; |
+ |
void AddChildSortedByTitle(CookieTreeNode* new_child); |
private: |
@@ -221,7 +238,9 @@ class CookieTreeRootNode : public CookieTreeNode { |
explicit CookieTreeRootNode(CookiesTreeModel* model); |
virtual ~CookieTreeRootNode(); |
- CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); |
+ //CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); |
+ CookieTreeAppNode* GetOrCreateAppNode(const string16& app_name, |
+ const string16& app_id); |
// CookieTreeNode methods: |
virtual CookiesTreeModel* GetModel() const OVERRIDE; |
@@ -233,13 +252,32 @@ class CookieTreeRootNode : public CookieTreeNode { |
DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); |
}; |
+// CookieTreeAppNode ------------------------------------------------------- |
+class CookieTreeAppNode : public CookieTreeNode { |
+ public: |
+ explicit CookieTreeAppNode(const string16& app_name, const string16& app_id); |
+ virtual ~CookieTreeAppNode(); |
+ |
+ CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); |
+ |
+ // CookieTreeNode methods: |
+ virtual DetailedInfo GetDetailedInfo() const OVERRIDE; |
+ |
+ const string16 app_id() const { return app_id_; } |
+ |
+ private: |
+ string16 app_name_; |
+ string16 app_id_; |
+ DISALLOW_COPY_AND_ASSIGN(CookieTreeAppNode); |
+}; |
+ |
// CookieTreeOriginNode ------------------------------------------------------- |
class CookieTreeOriginNode : public CookieTreeNode { |
public: |
// Returns the origin node's title to use for a given URL. |
static std::wstring TitleForUrl(const GURL& url); |
- explicit CookieTreeOriginNode(const GURL& url); |
+ explicit CookieTreeOriginNode(const string16& app_id, const GURL& url); |
virtual ~CookieTreeOriginNode(); |
// CookieTreeNode methods: |
@@ -265,6 +303,8 @@ class CookieTreeOriginNode : public CookieTreeNode { |
// True if a content exception can be created for this origin. |
bool CanCreateContentException() const; |
+ const string16 app_id() const { return app_id_; } |
+ |
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 |
@@ -284,6 +324,9 @@ class CookieTreeOriginNode : public CookieTreeNode { |
// The URL for which this node was initially created. |
GURL url_; |
+ // The app for which this node was created for. |
+ string16 app_id_; |
+ |
DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); |
}; |
@@ -614,9 +657,40 @@ class CookieTreeServerBoundCertsNode : public CookieTreeNode { |
DISALLOW_COPY_AND_ASSIGN(CookieTreeServerBoundCertsNode); |
}; |
+ |
+class CookiesTreeModelDelegate { |
+ public: |
+ //CookiesTreeModelDelegate(); |
+ |
+ virtual void PopulateAppCacheInfoWithFilter(string16* app, |
+ const std::wstring& filter) {} |
+ virtual void PopulateCookieInfoWithFilter(string16* app, |
+ const std::wstring& filter) {} |
+ virtual void PopulateDatabaseInfoWithFilter(string16* app, |
+ const std::wstring& filter) {} |
+ virtual void PopulateLocalStorageInfoWithFilter(string16* app, |
+ const std::wstring& filter) {} |
+ virtual void PopulateSessionStorageInfoWithFilter( |
+ string16* app, const std::wstring& filter) {} |
+ virtual void PopulateIndexedDBInfoWithFilter(string16* app, |
+ const std::wstring& filter) {} |
+ virtual void PopulateFileSystemInfoWithFilter(string16* app, |
+ const std::wstring& filter) {} |
+ virtual void PopulateQuotaInfoWithFilter(string16* app, |
+ const std::wstring& filter) {} |
+ virtual void PopulateServerBoundCertInfoWithFilter( |
+ string16* app, const std::wstring& filter) {} |
+}; |
+ |
+typedef std::map<string16, LocalDataContainer*> ContainerMap; |
+ |
// CookiesTreeModel ----------------------------------------------------------- |
-class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
+class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode>, |
+ public CookiesTreeModelDelegate { |
public: |
+ CookiesTreeModel(ContainerMap& apps_map); |
+ 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 +702,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. |
@@ -665,62 +726,91 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
virtual void AddCookiesTreeObserver(Observer* observer); |
virtual void RemoveCookiesTreeObserver(Observer* observer); |
+ void PopulateAppCacheInfoWithFilter(string16* app, |
+ const std::wstring& filter); |
+ void PopulateCookieInfoWithFilter(string16* app, |
+ const std::wstring& filter); |
+ void PopulateDatabaseInfoWithFilter(string16* app, |
+ const std::wstring& filter); |
+ void PopulateLocalStorageInfoWithFilter(string16* app, |
+ const std::wstring& filter); |
+ void PopulateSessionStorageInfoWithFilter(string16* app, |
+ const std::wstring& filter); |
+ void PopulateIndexedDBInfoWithFilter(string16* app, |
+ const std::wstring& filter); |
+ void PopulateFileSystemInfoWithFilter(string16* app, |
+ const std::wstring& filter); |
+ void PopulateQuotaInfoWithFilter(string16* app, |
+ const std::wstring& filter); |
+ void PopulateServerBoundCertInfoWithFilter(string16* app, |
+ const std::wstring& filter); |
+ |
+ BrowsingDataCookieHelper* GetCookieHelper(const string16& app_id); |
+ LocalDataContainer* GetLocalDataContainer(const string16& 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> |
+ |
+ void NotifyObserverBeginBatch(); |
+ void NotifyObserverEndBatch(); |
+ |
+ 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 true, use the CanonicalCookie::Source attribute to group cookies. |
+ // Otherwise, use the CanonicalCookie::Domain attribute. |
+ bool use_cookie_source_; |
+ |
+ // 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_; |
+}; |
+ |
+typedef std::list<net::CookieMonster::CanonicalCookie> CookieList; |
+typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo> DatabaseInfoList; |
+typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
LocalStorageInfoList; |
- typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
+typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
SessionStorageInfoList; |
- typedef std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> |
- IndexedDBInfoList; |
- typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo> |
+typedef std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> IndexedDBInfoList; |
+typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo> |
FileSystemInfoList; |
- typedef std::list<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoArray; |
- typedef net::ServerBoundCertStore::ServerBoundCertList ServerBoundCertList; |
+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); |
+// LocalDataContainer --------------------------------------------------------- |
+class LocalDataContainer { |
+ public: |
+ LocalDataContainer( |
+ const string16& app_name, |
+ const string16& app_id, |
+ 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 ~LocalDataContainer(); |
- void NotifyObserverBeginBatch(); |
- void NotifyObserverEndBatch(); |
+ void Init(CookiesTreeModelDelegate* d); |
- 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_; |
+ string16 app_name() { return app_name_; } |
+ string16 app_id() { return app_id_; } |
+ |
+ BrowsingDataCookieHelper* cookie_helper() { return cookie_helper_; } |
std::map<GURL, std::list<appcache::AppCacheInfo> > appcache_info_; |
CookieList cookie_list_; |
@@ -732,21 +822,39 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
QuotaInfoArray quota_info_list_; |
ServerBoundCertList server_bound_cert_list_; |
- // The CookiesTreeModel maintains a separate list of observers that are |
- // specifically of the type CookiesTreeModel::Observer. |
- ObserverList<Observer> cookies_observer_list_; |
+ 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_; |
- // 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_; |
+ private: |
+ 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); |
- // If true, use the CanonicalCookie::Source attribute to group cookies. |
- // Otherwise, use the CanonicalCookie::Domain attribute. |
- bool use_cookie_source_; |
+ string16 app_name_; |
+ string16 app_id_; |
+ CookiesTreeModelDelegate* delegate_; |
- base::WeakPtrFactory<CookiesTreeModel> weak_ptr_factory_; |
+ base::WeakPtrFactory<LocalDataContainer> weak_ptr_factory_; |
+ |
+ /* |
friend class CookieTreeAppCacheNode; |
friend class CookieTreeCookieNode; |
friend class CookieTreeDatabaseNode; |
@@ -756,8 +864,9 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
friend class CookieTreeFileSystemNode; |
friend class CookieTreeQuotaNode; |
friend class CookieTreeServerBoundCertNode; |
- |
- DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); |
+ friend class CookieTreeModel; |
+ */ |
+ DISALLOW_COPY_AND_ASSIGN(LocalDataContainer); |
}; |
#endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |