| Index: chrome/browser/cookies_tree_model.cc
|
| diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc
|
| index d198fa2c02f019eb949a3b598a9aeae3b023c21d..b2660ec852bd9e74151437ebe6205018cdccdf6b 100644
|
| --- a/chrome/browser/cookies_tree_model.cc
|
| +++ b/chrome/browser/cookies_tree_model.cc
|
| @@ -49,7 +49,7 @@ CookiesTreeModel* CookieTreeNode::GetModel() const {
|
| // CookieTreeCookieNode, public:
|
|
|
| CookieTreeCookieNode::CookieTreeCookieNode(
|
| - net::CookieMonster::CanonicalCookie* cookie)
|
| + std::list<net::CookieMonster::CanonicalCookie>::iterator cookie)
|
| : CookieTreeNode(UTF8ToUTF16(cookie->Name())),
|
| cookie_(cookie) {
|
| }
|
| @@ -58,19 +58,14 @@ CookieTreeCookieNode::~CookieTreeCookieNode() {}
|
|
|
| void CookieTreeCookieNode::DeleteStoredObjects() {
|
| // notify CookieMonster that we should delete this cookie
|
| - // We have stored a copy of all the cookies in the model, and our model is
|
| - // never re-calculated. Thus, we just need to delete the nodes from our
|
| - // model, and tell CookieMonster to delete the cookies. We can keep the
|
| - // vector storing the cookies in-tact and not delete from there (that would
|
| - // invalidate our pointers), and the fact that it contains semi out-of-date
|
| - // data is not problematic as we don't re-build the model based on that.
|
| GetModel()->cookie_helper_->DeleteCookie(*cookie_);
|
| + GetModel()->cookie_list_.erase(cookie_);
|
| }
|
|
|
| CookieTreeNode::DetailedInfo CookieTreeCookieNode::GetDetailedInfo() const {
|
| return DetailedInfo(parent()->parent()->GetTitle(),
|
| DetailedInfo::TYPE_COOKIE,
|
| - cookie_, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
| + &*cookie_, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
| }
|
|
|
| namespace {
|
| @@ -136,28 +131,35 @@ class OriginNodeComparator {
|
| // CookieTreeAppCacheNode, public:
|
|
|
| CookieTreeAppCacheNode::CookieTreeAppCacheNode(
|
| - const appcache::AppCacheInfo* appcache_info)
|
| + const GURL& origin_url,
|
| + std::list<appcache::AppCacheInfo>::iterator appcache_info)
|
| : CookieTreeNode(UTF8ToUTF16(appcache_info->manifest_url.spec())),
|
| + origin_url_(origin_url),
|
| appcache_info_(appcache_info) {
|
| }
|
|
|
| +CookieTreeAppCacheNode::~CookieTreeAppCacheNode() {
|
| +}
|
| +
|
| void CookieTreeAppCacheNode::DeleteStoredObjects() {
|
| DCHECK(GetModel()->appcache_helper_);
|
| GetModel()->appcache_helper_->DeleteAppCacheGroup(
|
| appcache_info_->manifest_url);
|
| + GetModel()->appcache_info_[origin_url_].erase(appcache_info_);
|
| }
|
|
|
| CookieTreeNode::DetailedInfo CookieTreeAppCacheNode::GetDetailedInfo() const {
|
| return DetailedInfo(parent()->parent()->GetTitle(),
|
| DetailedInfo::TYPE_APPCACHE,
|
| - NULL, NULL, NULL, NULL, appcache_info_, NULL, NULL, NULL);
|
| + NULL, NULL, NULL, NULL, &*appcache_info_,
|
| + NULL, NULL, NULL);
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // CookieTreeDatabaseNode, public:
|
|
|
| CookieTreeDatabaseNode::CookieTreeDatabaseNode(
|
| - BrowsingDataDatabaseHelper::DatabaseInfo* database_info)
|
| + std::list<BrowsingDataDatabaseHelper::DatabaseInfo>::iterator database_info)
|
| : CookieTreeNode(database_info->database_name.empty() ?
|
| l10n_util::GetStringUTF16(IDS_COOKIES_WEB_DATABASE_UNNAMED_NAME) :
|
| UTF8ToUTF16(database_info->database_name)),
|
| @@ -169,19 +171,22 @@ CookieTreeDatabaseNode::~CookieTreeDatabaseNode() {}
|
| void CookieTreeDatabaseNode::DeleteStoredObjects() {
|
| GetModel()->database_helper_->DeleteDatabase(
|
| database_info_->origin_identifier, database_info_->database_name);
|
| + GetModel()->database_info_list_.erase(database_info_);
|
| }
|
|
|
| CookieTreeNode::DetailedInfo CookieTreeDatabaseNode::GetDetailedInfo() const {
|
| return DetailedInfo(parent()->parent()->GetTitle(),
|
| DetailedInfo::TYPE_DATABASE,
|
| - NULL, database_info_, NULL, NULL, NULL, NULL, NULL, NULL);
|
| + NULL, &*database_info_,
|
| + NULL, NULL, NULL, NULL, NULL, NULL);
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // CookieTreeLocalStorageNode, public:
|
|
|
| CookieTreeLocalStorageNode::CookieTreeLocalStorageNode(
|
| - BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info)
|
| + std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator
|
| + local_storage_info)
|
| : CookieTreeNode(UTF8ToUTF16(
|
| local_storage_info->origin.empty() ?
|
| local_storage_info->database_identifier :
|
| @@ -194,13 +199,14 @@ CookieTreeLocalStorageNode::~CookieTreeLocalStorageNode() {}
|
| void CookieTreeLocalStorageNode::DeleteStoredObjects() {
|
| GetModel()->local_storage_helper_->DeleteLocalStorageFile(
|
| local_storage_info_->file_path);
|
| + GetModel()->local_storage_info_list_.erase(local_storage_info_);
|
| }
|
|
|
| CookieTreeNode::DetailedInfo
|
| CookieTreeLocalStorageNode::GetDetailedInfo() const {
|
| return DetailedInfo(parent()->parent()->GetTitle(),
|
| DetailedInfo::TYPE_LOCAL_STORAGE,
|
| - NULL, NULL, local_storage_info_, NULL, NULL, NULL, NULL,
|
| + NULL, NULL, &*local_storage_info_, NULL, NULL, NULL, NULL,
|
| NULL);
|
| }
|
|
|
| @@ -208,7 +214,8 @@ CookieTreeLocalStorageNode::GetDetailedInfo() const {
|
| // CookieTreeSessionStorageNode, public:
|
|
|
| CookieTreeSessionStorageNode::CookieTreeSessionStorageNode(
|
| - BrowsingDataLocalStorageHelper::LocalStorageInfo* session_storage_info)
|
| + std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator
|
| + session_storage_info)
|
| : CookieTreeNode(UTF8ToUTF16(
|
| session_storage_info->origin.empty() ?
|
| session_storage_info->database_identifier :
|
| @@ -218,11 +225,15 @@ CookieTreeSessionStorageNode::CookieTreeSessionStorageNode(
|
|
|
| CookieTreeSessionStorageNode::~CookieTreeSessionStorageNode() {}
|
|
|
| +void CookieTreeSessionStorageNode::DeleteStoredObjects() {
|
| + GetModel()->session_storage_info_list_.erase(session_storage_info_);
|
| +}
|
| +
|
| CookieTreeNode::DetailedInfo
|
| CookieTreeSessionStorageNode::GetDetailedInfo() const {
|
| return DetailedInfo(parent()->parent()->GetTitle(),
|
| DetailedInfo::TYPE_SESSION_STORAGE,
|
| - NULL, NULL, NULL, session_storage_info_, NULL, NULL,
|
| + NULL, NULL, NULL, &*session_storage_info_, NULL, NULL,
|
| NULL, NULL);
|
| }
|
|
|
| @@ -230,7 +241,8 @@ CookieTreeSessionStorageNode::GetDetailedInfo() const {
|
| // CookieTreeIndexedDBNode, public:
|
|
|
| CookieTreeIndexedDBNode::CookieTreeIndexedDBNode(
|
| - BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info)
|
| + std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo>::iterator
|
| + indexed_db_info)
|
| : CookieTreeNode(UTF8ToUTF16(
|
| indexed_db_info->origin.empty() ?
|
| indexed_db_info->database_identifier :
|
| @@ -243,12 +255,13 @@ CookieTreeIndexedDBNode::~CookieTreeIndexedDBNode() {}
|
| void CookieTreeIndexedDBNode::DeleteStoredObjects() {
|
| GetModel()->indexed_db_helper_->DeleteIndexedDBFile(
|
| indexed_db_info_->file_path);
|
| + GetModel()->indexed_db_info_list_.erase(indexed_db_info_);
|
| }
|
|
|
| CookieTreeNode::DetailedInfo CookieTreeIndexedDBNode::GetDetailedInfo() const {
|
| return DetailedInfo(parent()->parent()->GetTitle(),
|
| DetailedInfo::TYPE_INDEXED_DB,
|
| - NULL, NULL, NULL, NULL, NULL, indexed_db_info_, NULL,
|
| + NULL, NULL, NULL, NULL, NULL, &*indexed_db_info_, NULL,
|
| NULL);
|
| }
|
|
|
| @@ -256,7 +269,8 @@ CookieTreeNode::DetailedInfo CookieTreeIndexedDBNode::GetDetailedInfo() const {
|
| // CookieTreeFileSystemNode, public:
|
|
|
| CookieTreeFileSystemNode::CookieTreeFileSystemNode(
|
| - BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info)
|
| + std::list<BrowsingDataFileSystemHelper::FileSystemInfo>::iterator
|
| + file_system_info)
|
| : CookieTreeNode(UTF8ToUTF16(
|
| file_system_info->origin.spec())),
|
| file_system_info_(file_system_info) {
|
| @@ -267,12 +281,13 @@ CookieTreeFileSystemNode::~CookieTreeFileSystemNode() {}
|
| void CookieTreeFileSystemNode::DeleteStoredObjects() {
|
| GetModel()->file_system_helper_->DeleteFileSystemOrigin(
|
| file_system_info_->origin);
|
| + GetModel()->file_system_info_list_.erase(file_system_info_);
|
| }
|
|
|
| CookieTreeNode::DetailedInfo CookieTreeFileSystemNode::GetDetailedInfo() const {
|
| return DetailedInfo(parent()->parent()->GetTitle(),
|
| DetailedInfo::TYPE_FILE_SYSTEM,
|
| - NULL, NULL, NULL, NULL, NULL, NULL, file_system_info_,
|
| + NULL, NULL, NULL, NULL, NULL, NULL, &*file_system_info_,
|
| NULL);
|
| }
|
|
|
| @@ -280,7 +295,7 @@ CookieTreeNode::DetailedInfo CookieTreeFileSystemNode::GetDetailedInfo() const {
|
| // CookieTreeQuotaNode, public:
|
|
|
| CookieTreeQuotaNode::CookieTreeQuotaNode(
|
| - BrowsingDataQuotaHelper::QuotaInfo* quota_info)
|
| + std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info)
|
| : CookieTreeNode(UTF8ToUTF16(quota_info->host)),
|
| quota_info_(quota_info) {
|
| }
|
| @@ -289,12 +304,13 @@ CookieTreeQuotaNode::~CookieTreeQuotaNode() {}
|
|
|
| void CookieTreeQuotaNode::DeleteStoredObjects() {
|
| GetModel()->quota_helper_->DeleteQuotaHost(quota_info_->host);
|
| + GetModel()->quota_info_list_.erase(quota_info_);
|
| }
|
|
|
| CookieTreeNode::DetailedInfo CookieTreeQuotaNode::GetDetailedInfo() const {
|
| return DetailedInfo(parent()->parent()->GetTitle(),
|
| DetailedInfo::TYPE_QUOTA,
|
| - NULL, NULL, NULL, NULL, NULL, NULL, NULL, quota_info_);
|
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, &*quota_info_);
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| @@ -427,7 +443,7 @@ CookieTreeFileSystemsNode* CookieTreeOriginNode::GetOrCreateFileSystemsNode() {
|
| }
|
|
|
| CookieTreeQuotaNode* CookieTreeOriginNode::UpdateOrCreateQuotaNode(
|
| - BrowsingDataQuotaHelper::QuotaInfo* quota_info) {
|
| + std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info) {
|
| if (quota_child_)
|
| return quota_child_;
|
| quota_child_ = new CookieTreeQuotaNode(quota_info);
|
| @@ -759,24 +775,39 @@ void CookiesTreeModel::RemoveCookiesTreeObserver(Observer* observer) {
|
| }
|
|
|
| void CookiesTreeModel::OnAppCacheModelInfoLoaded() {
|
| - appcache_info_ = appcache_helper_->info_collection();
|
| + using appcache::AppCacheInfo;
|
| + using appcache::AppCacheInfoCollection;
|
| + using appcache::AppCacheInfoVector;
|
| + typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin;
|
| +
|
| + scoped_refptr<AppCacheInfoCollection> appcache_info =
|
| + appcache_helper_->info_collection();
|
| + if (!appcache_info || appcache_info->infos_by_origin.empty())
|
| + return;
|
| +
|
| + for (InfoByOrigin::const_iterator origin =
|
| + appcache_info->infos_by_origin.begin();
|
| + origin != appcache_info->infos_by_origin.end(); ++origin) {
|
| + std::list<AppCacheInfo>& info_list = appcache_info_[origin->first];
|
| + info_list.insert(
|
| + info_list.begin(), origin->second.begin(), origin->second.end());
|
| + }
|
| +
|
| PopulateAppCacheInfoWithFilter(std::wstring());
|
| }
|
|
|
| void CookiesTreeModel::PopulateAppCacheInfoWithFilter(
|
| const std::wstring& filter) {
|
| using appcache::AppCacheInfo;
|
| - using appcache::AppCacheInfoVector;
|
| - typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin;
|
| + typedef std::map<GURL, std::list<AppCacheInfo> > InfoByOrigin;
|
|
|
| - if (!appcache_info_ || appcache_info_->infos_by_origin.empty())
|
| + if (appcache_info_.empty())
|
| return;
|
|
|
| CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
|
| NotifyObserverBeginBatch();
|
| - for (InfoByOrigin::const_iterator origin =
|
| - appcache_info_->infos_by_origin.begin();
|
| - origin != appcache_info_->infos_by_origin.end(); ++origin) {
|
| + for (InfoByOrigin::iterator origin = appcache_info_.begin();
|
| + origin != appcache_info_.end(); ++origin) {
|
| std::wstring origin_node_name = UTF8ToWide(origin->first.host());
|
| if (filter.empty() ||
|
| (origin_node_name.find(filter) != std::wstring::npos)) {
|
| @@ -785,10 +816,10 @@ void CookiesTreeModel::PopulateAppCacheInfoWithFilter(
|
| CookieTreeAppCachesNode* appcaches_node =
|
| origin_node->GetOrCreateAppCachesNode();
|
|
|
| - for (AppCacheInfoVector::const_iterator info = origin->second.begin();
|
| + for (std::list<AppCacheInfo>::iterator info = origin->second.begin();
|
| info != origin->second.end(); ++info) {
|
| appcaches_node->AddAppCacheNode(
|
| - new CookieTreeAppCacheNode(&(*info)));
|
| + new CookieTreeAppCacheNode(origin->first, info));
|
| }
|
| }
|
| }
|
| @@ -797,8 +828,10 @@ void CookiesTreeModel::PopulateAppCacheInfoWithFilter(
|
| }
|
|
|
| void CookiesTreeModel::OnCookiesModelInfoLoaded(
|
| - const CookieList& cookie_list) {
|
| - cookie_list_ = cookie_list;
|
| + const net::CookieList& cookie_list) {
|
| + cookie_list_.insert(cookie_list_.begin(),
|
| + cookie_list.begin(),
|
| + cookie_list.end());
|
| PopulateCookieInfoWithFilter(std::wstring());
|
| }
|
|
|
| @@ -828,7 +861,7 @@ void CookiesTreeModel::PopulateCookieInfoWithFilter(
|
| root->GetOrCreateOriginNode(source);
|
| CookieTreeCookiesNode* cookies_node =
|
| origin_node->GetOrCreateCookiesNode();
|
| - CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(&*it);
|
| + CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(it);
|
| cookies_node->AddCookieNode(new_cookie);
|
| }
|
| }
|
| @@ -859,7 +892,7 @@ void CookiesTreeModel::PopulateDatabaseInfoWithFilter(
|
| CookieTreeDatabasesNode* databases_node =
|
| origin_node->GetOrCreateDatabasesNode();
|
| databases_node->AddDatabaseNode(
|
| - new CookieTreeDatabaseNode(&(*database_info)));
|
| + new CookieTreeDatabaseNode(database_info));
|
| }
|
| }
|
| NotifyObserverTreeNodeChanged(root);
|
| @@ -892,7 +925,7 @@ void CookiesTreeModel::PopulateLocalStorageInfoWithFilter(
|
| CookieTreeLocalStoragesNode* local_storages_node =
|
| origin_node->GetOrCreateLocalStoragesNode();
|
| local_storages_node->AddLocalStorageNode(
|
| - new CookieTreeLocalStorageNode(&(*local_storage_info)));
|
| + new CookieTreeLocalStorageNode(local_storage_info));
|
| }
|
| }
|
| NotifyObserverTreeNodeChanged(root);
|
| @@ -925,7 +958,7 @@ void CookiesTreeModel::PopulateSessionStorageInfoWithFilter(
|
| CookieTreeSessionStoragesNode* session_storages_node =
|
| origin_node->GetOrCreateSessionStoragesNode();
|
| session_storages_node->AddSessionStorageNode(
|
| - new CookieTreeSessionStorageNode(&(*session_storage_info)));
|
| + new CookieTreeSessionStorageNode(session_storage_info));
|
| }
|
| }
|
| NotifyObserverTreeNodeChanged(root);
|
| @@ -958,7 +991,7 @@ void CookiesTreeModel::PopulateIndexedDBInfoWithFilter(
|
| CookieTreeIndexedDBsNode* indexed_dbs_node =
|
| origin_node->GetOrCreateIndexedDBsNode();
|
| indexed_dbs_node->AddIndexedDBNode(
|
| - new CookieTreeIndexedDBNode(&(*indexed_db_info)));
|
| + new CookieTreeIndexedDBNode(indexed_db_info));
|
| }
|
| }
|
| NotifyObserverTreeNodeChanged(root);
|
| @@ -991,7 +1024,7 @@ void CookiesTreeModel::PopulateFileSystemInfoWithFilter(
|
| CookieTreeFileSystemsNode* file_systems_node =
|
| origin_node->GetOrCreateFileSystemsNode();
|
| file_systems_node->AddFileSystemNode(
|
| - new CookieTreeFileSystemNode(&(*file_system_info)));
|
| + new CookieTreeFileSystemNode(file_system_info));
|
| }
|
| }
|
| NotifyObserverTreeNodeChanged(root);
|
| @@ -1017,7 +1050,7 @@ void CookiesTreeModel::PopulateQuotaInfoWithFilter(
|
| (UTF8ToWide(quota_info->host).find(filter) != std::wstring::npos)) {
|
| CookieTreeOriginNode* origin_node =
|
| root->GetOrCreateOriginNode(GURL("http://" + quota_info->host));
|
| - origin_node->UpdateOrCreateQuotaNode(&*quota_info);
|
| + origin_node->UpdateOrCreateQuotaNode(quota_info);
|
| }
|
| }
|
| NotifyObserverTreeNodeChanged(root);
|
|
|