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..3b5c84cc7d87913d80c86c17fd8eeb8bf3114bae 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_; |
@@ -617,6 +644,9 @@ class CookieTreeServerBoundCertsNode : public CookieTreeNode { |
// CookiesTreeModel ----------------------------------------------------------- |
class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
public: |
+ CookiesTreeModel(const ContainerMap& apps_map, bool group_by_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,18 +658,22 @@ 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(); |
+ // This class defines the scope for batch updates. It can be created as a |
+ // local variable and the destructor will terminate the batch update, if one |
+ // has been started. |
+ class ScopedBatchUpdateNotifier { |
+ public: |
+ ScopedBatchUpdateNotifier(CookiesTreeModel* model, |
+ CookieTreeNode* node); |
+ ~ScopedBatchUpdateNotifier(); |
+ |
+ void StartBatchUpdate(); |
+ |
+ private: |
+ CookiesTreeModel* model_; |
+ CookieTreeNode* node_; |
+ bool batch_in_progress_; |
+ }; |
// ui::TreeModel methods: |
// Returns the set of icons for the nodes in the tree. You only need override |
@@ -653,10 +687,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 +702,76 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { |
virtual void AddCookiesTreeObserver(Observer* observer); |
virtual void RemoveCookiesTreeObserver(Observer* observer); |
+ // Methods that update the model based on the data retrieved by the browsing |
+ // data helpers. |
+ void PopulateAppCacheInfo(LocalDataContainer* container); |
+ void PopulateCookieInfo(LocalDataContainer* container); |
+ void PopulateDatabaseInfo(LocalDataContainer* container); |
+ void PopulateLocalStorageInfo(LocalDataContainer* container); |
+ void PopulateSessionStorageInfo(LocalDataContainer* container); |
+ void PopulateIndexedDBInfo(LocalDataContainer* container); |
+ void PopulateFileSystemInfo(LocalDataContainer* container); |
+ void PopulateQuotaInfo(LocalDataContainer* container); |
+ void PopulateServerBoundCertInfo(LocalDataContainer* container); |
+ |
+ 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_; |
+ void PopulateAppCacheInfoWithFilter(LocalDataContainer* container, |
+ ScopedBatchUpdateNotifier& notifier, |
Bernhard Bauer
2012/07/09 17:34:47
Could you pass in |notifier| as a pointer?
nasko
2012/07/09 18:17:34
Done.
|
+ const string16& filter); |
+ void PopulateCookieInfoWithFilter(LocalDataContainer* container, |
+ ScopedBatchUpdateNotifier& notifier, |
+ const string16& filter); |
+ void PopulateDatabaseInfoWithFilter(LocalDataContainer* container, |
+ ScopedBatchUpdateNotifier& notifier, |
+ const string16& filter); |
+ void PopulateLocalStorageInfoWithFilter(LocalDataContainer* container, |
+ ScopedBatchUpdateNotifier& notifier, |
+ const string16& filter); |
+ void PopulateSessionStorageInfoWithFilter(LocalDataContainer* container, |
+ ScopedBatchUpdateNotifier& notifier, |
+ const string16& filter); |
+ void PopulateIndexedDBInfoWithFilter(LocalDataContainer* container, |
+ ScopedBatchUpdateNotifier& notifier, |
+ const string16& filter); |
+ void PopulateFileSystemInfoWithFilter(LocalDataContainer* container, |
+ ScopedBatchUpdateNotifier& notifier, |
+ const string16& filter); |
+ void PopulateQuotaInfoWithFilter(LocalDataContainer* container, |
+ ScopedBatchUpdateNotifier& notifier, |
+ const string16& filter); |
+ void PopulateServerBoundCertInfoWithFilter( |
+ LocalDataContainer* container, |
+ ScopedBatchUpdateNotifier& notifier, |
+ const string16& filter); |
+ |
+ // 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 true, use the CanonicalCookie::Source attribute to group cookies. |
+ // Otherwise, use the CanonicalCookie::Domain attribute. |
+ bool group_by_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_; |
- |
- // If true, use the CanonicalCookie::Source attribute to group cookies. |
- // Otherwise, use the CanonicalCookie::Domain attribute. |
- bool use_cookie_source_; |
- |
- 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); |
}; |
#endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |