Chromium Code Reviews| Index: chrome/browser/cookies_tree_model.cc |
| diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc |
| index f662eab9e09ead39ce28a1af16be3bd051003b9e..05124b46d9ffc0f0ec31098c0931774dc3693933 100644 |
| --- a/chrome/browser/cookies_tree_model.cc |
| +++ b/chrome/browser/cookies_tree_model.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/bind.h" |
| #include "base/memory/linked_ptr.h" |
| +#include "base/stl_util.h" |
| #include "base/string_util.h" |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/browsing_data_cookie_helper.h" |
| @@ -38,10 +39,15 @@ void CookieTreeNode::DeleteStoredObjects() { |
| } |
| CookiesTreeModel* CookieTreeNode::GetModel() const { |
| - if (parent()) |
| - return parent()->GetModel(); |
| - else |
| + if (parent()) { |
| + if (parent()->parent()) { |
| + return parent()->parent()->GetModel(); |
| + } else { |
| + return parent()->GetModel(); |
| + } |
| + } else { |
| return NULL; |
| + } |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -57,8 +63,15 @@ CookieTreeCookieNode::~CookieTreeCookieNode() {} |
| void CookieTreeCookieNode::DeleteStoredObjects() { |
| // notify CookieMonster that we should delete this cookie |
| - GetModel()->cookie_helper_->DeleteCookie(*cookie_); |
| - GetModel()->cookie_list_.erase(cookie_); |
| + CookieTreeAppNode* app = static_cast<CookieTreeAppNode*>( |
| + parent()->parent()->parent()); |
| + LocalDataContainer* container = GetModel()->GetLocalDataContainer( |
| + app->app_id()); |
| + |
| + if (container) { |
| + container->cookie_helper_->DeleteCookie(*cookie_); |
| + container->cookie_list_.erase(cookie_); |
| + } |
| } |
| CookieTreeNode::DetailedInfo CookieTreeCookieNode::GetDetailedInfo() const { |
| @@ -139,10 +152,18 @@ 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_); |
| + |
|
markusheintz_
2012/06/18 16:52:41
Please delete the empty line here.
nasko
2012/06/18 19:59:14
Done.
|
| + CookieTreeAppNode* app = static_cast<CookieTreeAppNode*>( |
| + parent()->parent()->parent()); |
| + LocalDataContainer* container = GetModel()->GetLocalDataContainer( |
| + app->app_id()); |
| + |
| + if (container) { |
| + DCHECK(container->appcache_helper_); |
| + container->appcache_helper_->DeleteAppCacheGroup( |
| + appcache_info_->manifest_url); |
| + container->appcache_info_[origin_url_].erase(appcache_info_); |
| + } |
| } |
| CookieTreeNode::DetailedInfo CookieTreeAppCacheNode::GetDetailedInfo() const { |
| @@ -164,9 +185,16 @@ CookieTreeDatabaseNode::CookieTreeDatabaseNode( |
| CookieTreeDatabaseNode::~CookieTreeDatabaseNode() {} |
| void CookieTreeDatabaseNode::DeleteStoredObjects() { |
| - GetModel()->database_helper_->DeleteDatabase( |
| - database_info_->origin_identifier, database_info_->database_name); |
| - GetModel()->database_info_list_.erase(database_info_); |
| + CookieTreeAppNode* app = static_cast<CookieTreeAppNode*>( |
|
markusheintz_
2012/06/18 16:52:41
You repeat these 4 lines again and again in other
nasko
2012/06/18 19:59:14
The reason I didn't is that it assumes a level in
markusheintz_
2012/06/19 20:01:34
Looks like the quota node is the only exemption.
nasko
2012/06/19 22:22:40
Done.
|
| + parent()->parent()->parent()); |
| + LocalDataContainer* container = GetModel()->GetLocalDataContainer( |
| + app->app_id()); |
| + |
| + if (container) { |
| + container->database_helper_->DeleteDatabase( |
| + database_info_->origin_identifier, database_info_->database_name); |
| + container->database_info_list_.erase(database_info_); |
| + } |
| } |
| CookieTreeNode::DetailedInfo CookieTreeDatabaseNode::GetDetailedInfo() const { |
| @@ -187,9 +215,16 @@ CookieTreeLocalStorageNode::CookieTreeLocalStorageNode( |
| CookieTreeLocalStorageNode::~CookieTreeLocalStorageNode() {} |
| void CookieTreeLocalStorageNode::DeleteStoredObjects() { |
| - GetModel()->local_storage_helper_->DeleteOrigin( |
| - local_storage_info_->origin_url); |
| - GetModel()->local_storage_info_list_.erase(local_storage_info_); |
| + CookieTreeAppNode* app = static_cast<CookieTreeAppNode*>( |
| + parent()->parent()->parent()); |
| + LocalDataContainer* container = GetModel()->GetLocalDataContainer( |
| + app->app_id()); |
| + |
| + if (container) { |
| + container->local_storage_helper_->DeleteOrigin( |
| + local_storage_info_->origin_url); |
| + container->local_storage_info_list_.erase(local_storage_info_); |
| + } |
| } |
| CookieTreeNode::DetailedInfo |
| @@ -211,7 +246,14 @@ CookieTreeSessionStorageNode::CookieTreeSessionStorageNode( |
| CookieTreeSessionStorageNode::~CookieTreeSessionStorageNode() {} |
| void CookieTreeSessionStorageNode::DeleteStoredObjects() { |
| - GetModel()->session_storage_info_list_.erase(session_storage_info_); |
| + CookieTreeAppNode* app = static_cast<CookieTreeAppNode*>( |
| + parent()->parent()->parent()); |
| + LocalDataContainer* container = GetModel()->GetLocalDataContainer( |
| + app->app_id()); |
| + |
| + if (container) { |
| + container->session_storage_info_list_.erase(session_storage_info_); |
| + } |
| } |
| CookieTreeNode::DetailedInfo |
| @@ -234,9 +276,16 @@ CookieTreeIndexedDBNode::CookieTreeIndexedDBNode( |
| CookieTreeIndexedDBNode::~CookieTreeIndexedDBNode() {} |
| void CookieTreeIndexedDBNode::DeleteStoredObjects() { |
| - GetModel()->indexed_db_helper_->DeleteIndexedDB( |
| - indexed_db_info_->origin); |
| - GetModel()->indexed_db_info_list_.erase(indexed_db_info_); |
| + CookieTreeAppNode* app = static_cast<CookieTreeAppNode*>( |
| + parent()->parent()->parent()); |
| + LocalDataContainer* container = GetModel()->GetLocalDataContainer( |
| + app->app_id()); |
| + |
| + if (container) { |
| + container->indexed_db_helper_->DeleteIndexedDB( |
| + indexed_db_info_->origin); |
| + container->indexed_db_info_list_.erase(indexed_db_info_); |
| + } |
| } |
| CookieTreeNode::DetailedInfo CookieTreeIndexedDBNode::GetDetailedInfo() const { |
| @@ -258,9 +307,16 @@ CookieTreeFileSystemNode::CookieTreeFileSystemNode( |
| CookieTreeFileSystemNode::~CookieTreeFileSystemNode() {} |
| void CookieTreeFileSystemNode::DeleteStoredObjects() { |
| - GetModel()->file_system_helper_->DeleteFileSystemOrigin( |
| - file_system_info_->origin); |
| - GetModel()->file_system_info_list_.erase(file_system_info_); |
| + CookieTreeAppNode* app = static_cast<CookieTreeAppNode*>( |
| + parent()->parent()->parent()); |
| + LocalDataContainer* container = GetModel()->GetLocalDataContainer( |
| + app->app_id()); |
| + |
| + if (container) { |
| + container->file_system_helper_->DeleteFileSystemOrigin( |
| + file_system_info_->origin); |
| + container->file_system_info_list_.erase(file_system_info_); |
| + } |
| } |
| CookieTreeNode::DetailedInfo CookieTreeFileSystemNode::GetDetailedInfo() const { |
| @@ -282,8 +338,15 @@ CookieTreeQuotaNode::~CookieTreeQuotaNode() {} |
| void CookieTreeQuotaNode::DeleteStoredObjects() { |
| // Calling this function may cause unexpected over-quota state of origin. |
| // However, it'll caused no problem, just prevent usage growth of the origin. |
| - GetModel()->quota_helper_->RevokeHostQuota(quota_info_->host); |
| - GetModel()->quota_info_list_.erase(quota_info_); |
| + CookieTreeAppNode* app = static_cast<CookieTreeAppNode*>( |
| + parent()->parent()); |
| + LocalDataContainer* container = GetModel()->GetLocalDataContainer( |
| + app->app_id()); |
| + |
| + if (container) { |
| + container->quota_helper_->RevokeHostQuota(quota_info_->host); |
| + container->quota_info_list_.erase(quota_info_); |
| + } |
| } |
| CookieTreeNode::DetailedInfo CookieTreeQuotaNode::GetDetailedInfo() const { |
| @@ -303,9 +366,16 @@ CookieTreeServerBoundCertNode::CookieTreeServerBoundCertNode( |
| CookieTreeServerBoundCertNode::~CookieTreeServerBoundCertNode() {} |
| void CookieTreeServerBoundCertNode::DeleteStoredObjects() { |
| - GetModel()->server_bound_cert_helper_->DeleteServerBoundCert( |
| - server_bound_cert_->server_identifier()); |
| - GetModel()->server_bound_cert_list_.erase(server_bound_cert_); |
| + CookieTreeAppNode* app = static_cast<CookieTreeAppNode*>( |
| + parent()->parent()->parent()); |
| + LocalDataContainer* container = GetModel()->GetLocalDataContainer( |
| + app->app_id()); |
| + |
| + if (container) { |
| + container->server_bound_cert_helper_->DeleteServerBoundCert( |
| + server_bound_cert_->server_identifier()); |
| + container->server_bound_cert_list_.erase(server_bound_cert_); |
| + } |
| } |
| CookieTreeNode::DetailedInfo |
| @@ -323,7 +393,49 @@ CookieTreeRootNode::CookieTreeRootNode(CookiesTreeModel* model) |
| CookieTreeRootNode::~CookieTreeRootNode() {} |
| -CookieTreeOriginNode* CookieTreeRootNode::GetOrCreateOriginNode( |
| +CookieTreeAppNode* CookieTreeRootNode::GetOrCreateAppNode( |
| + const string16& app_name, |
| + const string16& app_id) { |
| + CookieTreeAppNode app_node(app_name, app_id); |
| + |
| + // First see if there is an existing match. |
| + std::vector<CookieTreeNode*>::iterator app_node_iterator = |
| + std::lower_bound(children().begin(), |
| + children().end(), |
| + &app_node, |
| + AppNodeComparator()); |
| + |
| + if (app_node_iterator != children().end()) |
| + return static_cast<CookieTreeAppNode*>(*app_node_iterator); |
| + |
| + // Node doesn't exist, create a new one and insert it into the (ordered) |
| + // children. |
| + CookieTreeAppNode* retval = new CookieTreeAppNode(app_name, app_id); |
| + DCHECK(model_); |
| + model_->Add(this, retval, (app_node_iterator - children().begin())); |
| + return retval; |
| +} |
| + |
| +CookiesTreeModel* CookieTreeRootNode::GetModel() const { |
| + return model_; |
| +} |
| + |
| +CookieTreeNode::DetailedInfo CookieTreeRootNode::GetDetailedInfo() const { |
| + return DetailedInfo(string16()).Init(DetailedInfo::TYPE_ROOT); |
| +} |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| +// CookieTreeAppNode, public: |
| + |
| +CookieTreeAppNode::CookieTreeAppNode(const string16& app_name, |
| + const string16& app_id) |
| + : CookieTreeNode(app_name), |
| + app_name_(app_name), |
| + app_id_(app_id) {} |
| + |
| +CookieTreeAppNode::~CookieTreeAppNode() {} |
| + |
| +CookieTreeOriginNode* CookieTreeAppNode::GetOrCreateOriginNode( |
| const GURL& url) { |
| CookieTreeOriginNode origin_node(url); |
| @@ -335,36 +447,31 @@ CookieTreeOriginNode* CookieTreeRootNode::GetOrCreateOriginNode( |
| OriginNodeComparator()); |
| if (origin_node_iterator != children().end() && |
| - WideToUTF16Hack(CookieTreeOriginNode::TitleForUrl(url)) == |
| + CookieTreeOriginNode::TitleForUrl(url) == |
| (*origin_node_iterator)->GetTitle()) |
| return static_cast<CookieTreeOriginNode*>(*origin_node_iterator); |
| // Node doesn't exist, create a new one and insert it into the (ordered) |
| // children. |
| CookieTreeOriginNode* retval = new CookieTreeOriginNode(url); |
| - DCHECK(model_); |
| - model_->Add(this, retval, (origin_node_iterator - children().begin())); |
| + GetModel()->Add(this, retval, (origin_node_iterator - children().begin())); |
| return retval; |
| } |
| -CookiesTreeModel* CookieTreeRootNode::GetModel() const { |
| - return model_; |
| -} |
| - |
| -CookieTreeNode::DetailedInfo CookieTreeRootNode::GetDetailedInfo() const { |
| - return DetailedInfo(string16()).Init(DetailedInfo::TYPE_ROOT); |
| +CookieTreeNode::DetailedInfo CookieTreeAppNode::GetDetailedInfo() const { |
| + return DetailedInfo(GetTitle()).InitApp(app_name_, app_id_); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| // CookieTreeOriginNode, public: |
| // static |
| -std::wstring CookieTreeOriginNode::TitleForUrl( |
| +string16 CookieTreeOriginNode::TitleForUrl( |
| const GURL& url) { |
| - return UTF8ToWide(url.SchemeIsFile() ? kFileOriginNodeName : url.host()); |
| + return UTF8ToUTF16(url.SchemeIsFile() ? kFileOriginNodeName : url.host()); |
| } |
| CookieTreeOriginNode::CookieTreeOriginNode(const GURL& url) |
| - : CookieTreeNode(WideToUTF16Hack(TitleForUrl(url))), |
| + : CookieTreeNode(TitleForUrl(url)), |
| cookies_child_(NULL), |
| databases_child_(NULL), |
| local_storages_child_(NULL), |
| @@ -606,6 +713,15 @@ bool CookieTreeNode::NodeTitleComparator::operator() ( |
| return (left->GetTitle() < right->GetTitle()); |
| } |
| +bool CookieTreeNode::AppNodeComparator::operator() ( |
| + const CookieTreeNode* lhs, const CookieTreeNode* rhs) { |
| + const CookieTreeAppNode* left = |
| + static_cast<const CookieTreeAppNode*>(lhs); |
| + const CookieTreeAppNode* right = |
| + static_cast<const CookieTreeAppNode*>(rhs); |
| + return (left->app_id() < right->app_id()); |
| +} |
| + |
| void CookieTreeNode::AddChildSortedByTitle(CookieTreeNode* new_child) { |
| DCHECK(new_child); |
| std::vector<CookieTreeNode*>::iterator iter = |
| @@ -618,84 +734,22 @@ void CookieTreeNode::AddChildSortedByTitle(CookieTreeNode* new_child) { |
| /////////////////////////////////////////////////////////////////////////////// |
| // CookiesTreeModel, public: |
| - |
| -CookiesTreeModel::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) |
| +CookiesTreeModel::CookiesTreeModel(ContainerMap& apps_map, |
|
markusheintz_
2012/06/18 16:52:41
Below you copy the apps_map.
I think you can avoi
nasko
2012/06/18 19:59:14
Done.
|
| + bool use_cookie_source) |
| : ALLOW_THIS_IN_INITIALIZER_LIST(ui::TreeNodeModel<CookieTreeNode>( |
| new CookieTreeRootNode(this))), |
| - appcache_helper_(appcache_helper), |
| - cookie_helper_(cookie_helper), |
| - database_helper_(database_helper), |
| - local_storage_helper_(local_storage_helper), |
| - session_storage_helper_(session_storage_helper), |
| - indexed_db_helper_(indexed_db_helper), |
| - file_system_helper_(file_system_helper), |
| - quota_helper_(quota_helper), |
| - server_bound_cert_helper_(server_bound_cert_helper), |
| - batch_update_(0), |
| use_cookie_source_(use_cookie_source), |
| - ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| - DCHECK(cookie_helper_); |
| - cookie_helper_->StartFetching( |
| - base::Bind(&CookiesTreeModel::OnCookiesModelInfoLoaded, |
| - weak_ptr_factory_.GetWeakPtr())); |
| - DCHECK(database_helper_); |
| - database_helper_->StartFetching( |
| - base::Bind(&CookiesTreeModel::OnDatabaseModelInfoLoaded, |
| - weak_ptr_factory_.GetWeakPtr())); |
| - DCHECK(local_storage_helper_); |
| - local_storage_helper_->StartFetching( |
| - base::Bind(&CookiesTreeModel::OnLocalStorageModelInfoLoaded, |
| - weak_ptr_factory_.GetWeakPtr())); |
| - if (session_storage_helper_) { |
| - session_storage_helper_->StartFetching( |
| - base::Bind(&CookiesTreeModel::OnSessionStorageModelInfoLoaded, |
| - weak_ptr_factory_.GetWeakPtr())); |
| - } |
| - |
| - // TODO(michaeln): When all of the UI implementations have been updated, make |
| - // this a required parameter. |
| - if (appcache_helper_) { |
| - appcache_helper_->StartFetching( |
| - base::Bind(&CookiesTreeModel::OnAppCacheModelInfoLoaded, |
| - weak_ptr_factory_.GetWeakPtr())); |
| - } |
| - |
| - if (indexed_db_helper_) { |
| - indexed_db_helper_->StartFetching( |
| - base::Bind(&CookiesTreeModel::OnIndexedDBModelInfoLoaded, |
| - weak_ptr_factory_.GetWeakPtr())); |
| - } |
| - |
| - if (file_system_helper_) { |
| - file_system_helper_->StartFetching( |
| - base::Bind(&CookiesTreeModel::OnFileSystemModelInfoLoaded, |
| - weak_ptr_factory_.GetWeakPtr())); |
| - } |
| - |
| - if (quota_helper_) { |
| - quota_helper_->StartFetching( |
| - base::Bind(&CookiesTreeModel::OnQuotaModelInfoLoaded, |
| - weak_ptr_factory_.GetWeakPtr())); |
| - } |
| - |
| - if (server_bound_cert_helper_) { |
| - server_bound_cert_helper_->StartFetching( |
| - base::Bind(&CookiesTreeModel::OnServerBoundCertModelInfoLoaded, |
| - weak_ptr_factory_.GetWeakPtr())); |
| + batch_update_(0) { |
| + for (ContainerMap::iterator it = apps_map.begin(); |
| + it != apps_map.end(); ++it) { |
|
markusheintz_
2012/06/18 16:52:41
Please fix indentation here. Thanks.
nasko
2012/06/18 19:59:14
Done.
|
| + app_data_map_[it->first] = it->second; |
| + it->second->Init(this); |
| } |
| } |
| -CookiesTreeModel::~CookiesTreeModel() {} |
| +CookiesTreeModel::~CookiesTreeModel() { |
| + STLDeleteValues(&app_data_map_); |
| +} |
| /////////////////////////////////////////////////////////////////////////////// |
| // CookiesTreeModel, TreeModel methods (public): |
| @@ -755,6 +809,29 @@ void CookiesTreeModel::DeleteAllStoredObjects() { |
| NotifyObserverEndBatch(); |
| } |
| +void CookiesTreeModel::DeleteStoredObjectsForApp(const string16& app_id) { |
| + NotifyObserverBeginBatch(); |
| + CookieTreeAppNode* app_node; |
| + CookieTreeNode* root = GetRoot(); |
| + for (int i = 0; i < root->child_count(); ++i) { |
| + app_node = static_cast<CookieTreeAppNode*>(root->GetChild(i)); |
| + app_node->DeleteStoredObjects(); |
| + if (app_node->GetDetailedInfo().app_id == app_id) { |
| + // We need to loop over and delete the child nodes, as we can't just |
| + // delete the app node. The reason for this is that the app node doesn't |
| + // really get deleted, unless the app is uninstalled, which doesn't happen |
| + // in this case. |
| + int num_children = app_node->child_count(); |
| + for (int j = num_children - 1; j >= 0; --j) { |
| + delete Remove(app_node, app_node->GetChild(j)); |
| + } |
| + break; |
| + } |
| + } |
| + NotifyObserverTreeNodeChanged(root); |
| + NotifyObserverEndBatch(); |
| +} |
| + |
| void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) { |
| if (cookie_node == GetRoot()) |
| return; |
| @@ -765,21 +842,21 @@ void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) { |
| DeleteCookieNode(parent_node); |
| } |
| -void CookiesTreeModel::UpdateSearchResults(const std::wstring& filter) { |
| +void CookiesTreeModel::UpdateSearchResults(const string16& filter) { |
| CookieTreeNode* root = GetRoot(); |
| int num_children = root->child_count(); |
| NotifyObserverBeginBatch(); |
| for (int i = num_children - 1; i >= 0; --i) |
| delete Remove(root, root->GetChild(i)); |
| - PopulateCookieInfoWithFilter(filter); |
| - PopulateDatabaseInfoWithFilter(filter); |
| - PopulateLocalStorageInfoWithFilter(filter); |
| - PopulateSessionStorageInfoWithFilter(filter); |
| - PopulateAppCacheInfoWithFilter(filter); |
| - PopulateIndexedDBInfoWithFilter(filter); |
| - PopulateFileSystemInfoWithFilter(filter); |
| - PopulateQuotaInfoWithFilter(filter); |
| - PopulateServerBoundCertInfoWithFilter(filter); |
| + PopulateCookieInfoWithFilter(NULL, filter); |
| + PopulateDatabaseInfoWithFilter(NULL, filter); |
| + PopulateLocalStorageInfoWithFilter(NULL, filter); |
| + PopulateSessionStorageInfoWithFilter(NULL, filter); |
| + PopulateAppCacheInfoWithFilter(NULL, filter); |
| + PopulateIndexedDBInfoWithFilter(NULL, filter); |
| + PopulateFileSystemInfoWithFilter(NULL, filter); |
| + PopulateQuotaInfoWithFilter(NULL, filter); |
| + PopulateServerBoundCertInfoWithFilter(NULL, filter); |
| NotifyObserverTreeNodeChanged(root); |
| NotifyObserverEndBatch(); |
| } |
| @@ -796,328 +873,443 @@ void CookiesTreeModel::RemoveCookiesTreeObserver(Observer* observer) { |
| ui::TreeNodeModel<CookieTreeNode>::RemoveObserver(observer); |
| } |
| -void CookiesTreeModel::OnAppCacheModelInfoLoaded() { |
| - using appcache::AppCacheInfo; |
| - using appcache::AppCacheInfoCollection; |
| - using appcache::AppCacheInfoVector; |
| - typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; |
| +void CookiesTreeModel::PopulateAppCacheInfoWithFilter( |
| + const string16* app_id, |
| + const string16& filter) { |
| - scoped_refptr<AppCacheInfoCollection> appcache_info = |
| - appcache_helper_->info_collection(); |
| - if (!appcache_info || appcache_info->infos_by_origin.empty()) |
| - return; |
| + using appcache::AppCacheInfo; |
| + typedef std::map<GURL, std::list<AppCacheInfo> > InfoByOrigin; |
| + CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| + bool begin_batch = false; |
| - 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()); |
| - } |
| + for (ContainerMap::iterator ait = app_data_map_.begin(); |
|
markusheintz_
2012/06/19 20:01:34
Here and in all other populate methods:
I probabl
nasko
2012/06/19 22:22:40
The reason is that if app_id is NULL, you want to
|
| + ait != app_data_map_.end(); ++ait ) { |
| + LocalDataContainer* container = ait->second; |
| - PopulateAppCacheInfoWithFilter(std::wstring()); |
| -} |
| + if (container->appcache_info_.empty()) |
| + continue; |
| -void CookiesTreeModel::PopulateAppCacheInfoWithFilter( |
| - const std::wstring& filter) { |
| - using appcache::AppCacheInfo; |
| - typedef std::map<GURL, std::list<AppCacheInfo> > InfoByOrigin; |
| + if (app_id && *app_id != container->app_id()) |
| + continue; |
| - if (appcache_info_.empty()) |
| - return; |
| + if (!begin_batch) { |
| + NotifyObserverBeginBatch(); |
| + begin_batch = true; |
| + } |
| - CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| - NotifyObserverBeginBatch(); |
| - 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)) { |
| - CookieTreeOriginNode* origin_node = |
| - root->GetOrCreateOriginNode(origin->first); |
| - CookieTreeAppCachesNode* appcaches_node = |
| - origin_node->GetOrCreateAppCachesNode(); |
| - |
| - for (std::list<AppCacheInfo>::iterator info = origin->second.begin(); |
| - info != origin->second.end(); ++info) { |
| - appcaches_node->AddAppCacheNode( |
| - new CookieTreeAppCacheNode(origin->first, info)); |
| + CookieTreeAppNode* app_node = |
| + root->GetOrCreateAppNode(container->app_name(), container->app_id()); |
| + |
| + for (InfoByOrigin::iterator origin = container->appcache_info_.begin(); |
| + origin != container->appcache_info_.end(); ++origin) { |
|
markusheintz_
2012/06/19 20:01:34
indent by 1
nasko
2012/06/19 22:22:40
Done.
|
| + string16 origin_node_name = UTF8ToUTF16(origin->first.host()); |
| + if (filter.empty() || |
| + (origin_node_name.find(filter) != string16::npos)) { |
| + CookieTreeOriginNode* origin_node = |
| + app_node->GetOrCreateOriginNode(origin->first); |
| + CookieTreeAppCachesNode* appcaches_node = |
| + origin_node->GetOrCreateAppCachesNode(); |
| + |
| + for (std::list<AppCacheInfo>::iterator info = origin->second.begin(); |
| + info != origin->second.end(); ++info) { |
|
markusheintz_
2012/06/19 20:01:34
indent by 1
nasko
2012/06/19 22:22:40
Done.
|
| + appcaches_node->AddAppCacheNode( |
| + new CookieTreeAppCacheNode(origin->first, info)); |
| + } |
| } |
| } |
| } |
| - NotifyObserverTreeNodeChanged(root); |
| - NotifyObserverEndBatch(); |
| -} |
| -void CookiesTreeModel::OnCookiesModelInfoLoaded( |
| - const net::CookieList& cookie_list) { |
| - cookie_list_.insert(cookie_list_.begin(), |
| - cookie_list.begin(), |
| - cookie_list.end()); |
| - PopulateCookieInfoWithFilter(std::wstring()); |
| + if (begin_batch) { |
| + NotifyObserverTreeNodeChanged(root); |
| + NotifyObserverEndBatch(); |
| + } |
| } |
| void CookiesTreeModel::PopulateCookieInfoWithFilter( |
| - const std::wstring& filter) { |
| + const string16* app_id, |
| + const string16& filter) { |
| // mmargh mmargh mmargh! delicious! |
| CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| NotifyObserverBeginBatch(); |
| - for (CookieList::iterator it = cookie_list_.begin(); |
| - it != cookie_list_.end(); ++it) { |
| - std::string source_string = it->Source(); |
| - if (source_string.empty() || !use_cookie_source_) { |
| - std::string domain = it->Domain(); |
| - if (domain.length() > 1 && domain[0] == '.') |
| - domain = domain.substr(1); |
| - |
| - // We treat secure cookies just the same as normal ones. |
| - source_string = std::string(chrome::kHttpScheme) + |
| - content::kStandardSchemeSeparator + domain + "/"; |
| - } |
| + for (ContainerMap::iterator ait = app_data_map_.begin(); |
| + ait != app_data_map_.end(); ++ait ) { |
| + LocalDataContainer* container = ait->second; |
| + |
| + if (app_id && *app_id != container->app_id()) |
| + continue; |
| + |
| + CookieTreeAppNode* app_node = |
| + root->GetOrCreateAppNode(container->app_name(), container->app_id()); |
| + |
| + for (CookieList::iterator it = container->cookie_list_.begin(); |
| + it != container->cookie_list_.end(); ++it) { |
|
markusheintz_
2012/06/19 20:01:34
indent by 1
nasko
2012/06/19 22:22:40
Done.
|
| + std::string source_string = it->Source(); |
| + if (source_string.empty() || !use_cookie_source_) { |
| + std::string domain = it->Domain(); |
| + if (domain.length() > 1 && domain[0] == '.') |
| + domain = domain.substr(1); |
| + |
| + // We treat secure cookies just the same as normal ones. |
| + source_string = std::string(chrome::kHttpScheme) + |
| + content::kStandardSchemeSeparator + domain + "/"; |
| + } |
| - GURL source(source_string); |
| - if (!filter.size() || |
| - (CookieTreeOriginNode::TitleForUrl(source).find(filter) != |
| - std::string::npos)) { |
| - CookieTreeOriginNode* origin_node = |
| - root->GetOrCreateOriginNode(source); |
| - CookieTreeCookiesNode* cookies_node = |
| - origin_node->GetOrCreateCookiesNode(); |
| - CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(it); |
| - cookies_node->AddCookieNode(new_cookie); |
| + GURL source(source_string); |
| + if (!filter.size() || |
| + (CookieTreeOriginNode::TitleForUrl(source).find(filter) != |
| + std::string::npos)) { |
| + CookieTreeOriginNode* origin_node = |
| + app_node->GetOrCreateOriginNode(source); |
| + CookieTreeCookiesNode* cookies_node = |
| + origin_node->GetOrCreateCookiesNode(); |
| + CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(it); |
| + cookies_node->AddCookieNode(new_cookie); |
| + } |
| } |
| } |
| NotifyObserverTreeNodeChanged(root); |
| NotifyObserverEndBatch(); |
| } |
| -void CookiesTreeModel::OnDatabaseModelInfoLoaded( |
| - const DatabaseInfoList& database_info) { |
| - database_info_list_ = database_info; |
| - PopulateDatabaseInfoWithFilter(std::wstring()); |
| -} |
| - |
| void CookiesTreeModel::PopulateDatabaseInfoWithFilter( |
| - const std::wstring& filter) { |
| - if (database_info_list_.empty()) |
| - return; |
| + const string16* app_id, |
| + const string16& filter) { |
| + |
| CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| - NotifyObserverBeginBatch(); |
| - for (DatabaseInfoList::iterator database_info = database_info_list_.begin(); |
| - database_info != database_info_list_.end(); |
| - ++database_info) { |
| - GURL origin(database_info->origin); |
| - |
| - if (!filter.size() || |
| - (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != |
| - std::wstring::npos)) { |
| - CookieTreeOriginNode* origin_node = |
| - root->GetOrCreateOriginNode(origin); |
| - CookieTreeDatabasesNode* databases_node = |
| - origin_node->GetOrCreateDatabasesNode(); |
| - databases_node->AddDatabaseNode( |
| - new CookieTreeDatabaseNode(database_info)); |
| + bool begin_batch = false; |
| + |
| + for (ContainerMap::iterator ait = app_data_map_.begin(); |
| + ait != app_data_map_.end(); ++ait ) { |
| + LocalDataContainer* container = ait->second; |
| + |
| + if (container->database_info_list_.empty()) |
|
markusheintz_
2012/06/19 20:01:34
Here and in all other Populate methods:
If you ke
|
| + continue; |
| + |
| + if (app_id && *app_id != container->app_id()) |
| + continue; |
| + |
| + if (!begin_batch) { |
| + NotifyObserverBeginBatch(); |
| + begin_batch = true; |
| + } |
| + |
| + CookieTreeAppNode* app_node = |
| + root->GetOrCreateAppNode(container->app_name(), container->app_id()); |
| + |
| + for (DatabaseInfoList::iterator database_info = |
| + container->database_info_list_.begin(); |
| + database_info != container->database_info_list_.end(); |
| + ++database_info) { |
| + GURL origin(database_info->origin); |
| + |
| + if (!filter.size() || |
| + (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != |
| + string16::npos)) { |
| + CookieTreeOriginNode* origin_node = |
| + app_node->GetOrCreateOriginNode(origin); |
| + CookieTreeDatabasesNode* databases_node = |
| + origin_node->GetOrCreateDatabasesNode(); |
| + databases_node->AddDatabaseNode( |
| + new CookieTreeDatabaseNode(database_info)); |
| + } |
| } |
| } |
| - NotifyObserverTreeNodeChanged(root); |
| - NotifyObserverEndBatch(); |
| -} |
| -void CookiesTreeModel::OnLocalStorageModelInfoLoaded( |
| - const LocalStorageInfoList& local_storage_info) { |
| - local_storage_info_list_ = local_storage_info; |
| - PopulateLocalStorageInfoWithFilter(std::wstring()); |
| + if (begin_batch) { |
| + NotifyObserverTreeNodeChanged(root); |
| + NotifyObserverEndBatch(); |
| + } |
| } |
| void CookiesTreeModel::PopulateLocalStorageInfoWithFilter( |
| - const std::wstring& filter) { |
| - if (local_storage_info_list_.empty()) |
| - return; |
| + const string16* app_id, |
| + const string16& filter) { |
| + |
| CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| - NotifyObserverBeginBatch(); |
| - for (LocalStorageInfoList::iterator local_storage_info = |
| - local_storage_info_list_.begin(); |
| - local_storage_info != local_storage_info_list_.end(); |
| - ++local_storage_info) { |
| - const GURL& origin(local_storage_info->origin_url); |
| - |
| - if (!filter.size() || |
| - (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != |
| - std::wstring::npos)) { |
| - CookieTreeOriginNode* origin_node = |
| - root->GetOrCreateOriginNode(origin); |
| - CookieTreeLocalStoragesNode* local_storages_node = |
| - origin_node->GetOrCreateLocalStoragesNode(); |
| - local_storages_node->AddLocalStorageNode( |
| - new CookieTreeLocalStorageNode(local_storage_info)); |
| + bool begin_batch = false; |
| + |
| + for (ContainerMap::iterator ait = app_data_map_.begin(); |
| + ait != app_data_map_.end(); ++ait ) { |
| + LocalDataContainer* container = ait->second; |
| + |
| + if (container->local_storage_info_list_.empty()) |
| + continue; |
| + |
| + if (app_id && *app_id != container->app_id()) |
| + continue; |
| + |
| + if (!begin_batch) { |
| + NotifyObserverBeginBatch(); |
| + begin_batch = true; |
| } |
| - } |
| - NotifyObserverTreeNodeChanged(root); |
| - NotifyObserverEndBatch(); |
| -} |
| -void CookiesTreeModel::OnSessionStorageModelInfoLoaded( |
| - const LocalStorageInfoList& session_storage_info) { |
| - session_storage_info_list_ = session_storage_info; |
| - PopulateSessionStorageInfoWithFilter(std::wstring()); |
| + CookieTreeAppNode* app_node = |
| + root->GetOrCreateAppNode(container->app_name(), container->app_id()); |
| + |
| + for (LocalStorageInfoList::iterator local_storage_info = |
| + container->local_storage_info_list_.begin(); |
|
markusheintz_
2012/06/19 20:01:34
Fix indentation.
nasko
2012/06/19 22:22:40
Done.
|
| + local_storage_info != container->local_storage_info_list_.end(); |
| + ++local_storage_info) { |
| + const GURL& origin(local_storage_info->origin_url); |
| + |
| + if (!filter.size() || |
| + (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != |
| + string16::npos)) { |
| + CookieTreeOriginNode* origin_node = |
| + app_node->GetOrCreateOriginNode(origin); |
| + CookieTreeLocalStoragesNode* local_storages_node = |
| + origin_node->GetOrCreateLocalStoragesNode(); |
| + local_storages_node->AddLocalStorageNode( |
| + new CookieTreeLocalStorageNode(local_storage_info)); |
| + } |
| + } |
| + } |
| + if (begin_batch) { |
| + NotifyObserverTreeNodeChanged(root); |
| + NotifyObserverEndBatch(); |
| + } |
| } |
| void CookiesTreeModel::PopulateSessionStorageInfoWithFilter( |
| - const std::wstring& filter) { |
| - if (session_storage_info_list_.empty()) |
| - return; |
| + const string16* app_id, |
| + const string16& filter) { |
| CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| - NotifyObserverBeginBatch(); |
| - for (LocalStorageInfoList::iterator session_storage_info = |
| - session_storage_info_list_.begin(); |
| - session_storage_info != session_storage_info_list_.end(); |
| - ++session_storage_info) { |
| - const GURL& origin = session_storage_info->origin_url; |
| - if (!filter.size() || |
| - (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != |
| - std::wstring::npos)) { |
| - CookieTreeOriginNode* origin_node = |
| - root->GetOrCreateOriginNode(origin); |
| - CookieTreeSessionStoragesNode* session_storages_node = |
| - origin_node->GetOrCreateSessionStoragesNode(); |
| - session_storages_node->AddSessionStorageNode( |
| - new CookieTreeSessionStorageNode(session_storage_info)); |
| + bool begin_batch = false; |
| + |
| + for (ContainerMap::iterator ait = app_data_map_.begin(); |
| + ait != app_data_map_.end(); ++ait ) { |
| + LocalDataContainer* container = ait->second; |
| + |
| + if (container->session_storage_info_list_.empty()) |
| + continue; |
| + |
| + if (app_id && *app_id != container->app_id()) |
| + continue; |
| + |
| + if (!begin_batch) { |
| + NotifyObserverBeginBatch(); |
| + begin_batch = true; |
| } |
| - } |
| - NotifyObserverTreeNodeChanged(root); |
| - NotifyObserverEndBatch(); |
| -} |
| -void CookiesTreeModel::OnIndexedDBModelInfoLoaded( |
| - const IndexedDBInfoList& indexed_db_info) { |
| - indexed_db_info_list_ = indexed_db_info; |
| - PopulateIndexedDBInfoWithFilter(std::wstring()); |
| + CookieTreeAppNode* app_node = |
| + root->GetOrCreateAppNode(container->app_name(), container->app_id()); |
| + |
| + for (LocalStorageInfoList::iterator session_storage_info = |
| + container->session_storage_info_list_.begin(); |
|
markusheintz_
2012/06/19 20:01:34
indent by 5 next two lines indet by 1
nasko
2012/06/19 22:22:40
Done.
|
| + session_storage_info != container->session_storage_info_list_.end(); |
| + ++session_storage_info) { |
| + const GURL& origin = session_storage_info->origin_url; |
| + |
| + if (!filter.size() || |
| + (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != |
| + string16::npos)) { |
| + CookieTreeOriginNode* origin_node = |
| + app_node->GetOrCreateOriginNode(origin); |
| + CookieTreeSessionStoragesNode* session_storages_node = |
| + origin_node->GetOrCreateSessionStoragesNode(); |
| + session_storages_node->AddSessionStorageNode( |
| + new CookieTreeSessionStorageNode(session_storage_info)); |
| + } |
| + } |
| + } |
| + if (begin_batch) { |
| + NotifyObserverTreeNodeChanged(root); |
| + NotifyObserverEndBatch(); |
| + } |
| } |
| void CookiesTreeModel::PopulateIndexedDBInfoWithFilter( |
| - const std::wstring& filter) { |
| - if (indexed_db_info_list_.empty()) |
| - return; |
| + const string16* app_id, |
| + const string16& filter) { |
| + |
| CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| - NotifyObserverBeginBatch(); |
| - for (IndexedDBInfoList::iterator indexed_db_info = |
| - indexed_db_info_list_.begin(); |
| - indexed_db_info != indexed_db_info_list_.end(); |
| - ++indexed_db_info) { |
| - const GURL& origin = indexed_db_info->origin; |
| - |
| - if (!filter.size() || |
| - (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != |
| - std::wstring::npos)) { |
| - CookieTreeOriginNode* origin_node = |
| - root->GetOrCreateOriginNode(origin); |
| - CookieTreeIndexedDBsNode* indexed_dbs_node = |
| - origin_node->GetOrCreateIndexedDBsNode(); |
| - indexed_dbs_node->AddIndexedDBNode( |
| - new CookieTreeIndexedDBNode(indexed_db_info)); |
| + bool begin_batch = false; |
| + |
| + for (ContainerMap::iterator ait = app_data_map_.begin(); |
| + ait != app_data_map_.end(); ++ait ) { |
|
markusheintz_
2012/06/19 20:01:34
indent by one
nasko
2012/06/19 22:22:40
Done.
|
| + LocalDataContainer* container = ait->second; |
| + |
| + if (container->indexed_db_info_list_.empty()) |
| + continue; |
| + |
| + if (app_id && *app_id != container->app_id()) |
| + continue; |
| + |
| + if (!begin_batch) { |
| + NotifyObserverBeginBatch(); |
| + begin_batch = true; |
| + } |
| + |
| + CookieTreeAppNode* app_node = |
| + root->GetOrCreateAppNode(container->app_name(), container->app_id()); |
| + |
| + for (IndexedDBInfoList::iterator indexed_db_info = |
| + container->indexed_db_info_list_.begin(); |
|
markusheintz_
2012/06/19 20:01:34
Indent by 5.
nasko
2012/06/19 22:22:40
Done.
|
| + indexed_db_info != container->indexed_db_info_list_.end(); |
|
markusheintz_
2012/06/19 20:01:34
this and the next line indent by 1
nasko
2012/06/19 22:22:40
Done.
nasko
2012/06/19 22:22:40
Done.
|
| + ++indexed_db_info) { |
| + const GURL& origin = indexed_db_info->origin; |
| + |
| + if (!filter.size() || |
| + (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != |
| + string16::npos)) { |
| + CookieTreeOriginNode* origin_node = |
| + app_node->GetOrCreateOriginNode(origin); |
| + CookieTreeIndexedDBsNode* indexed_dbs_node = |
| + origin_node->GetOrCreateIndexedDBsNode(); |
| + indexed_dbs_node->AddIndexedDBNode( |
| + new CookieTreeIndexedDBNode(indexed_db_info)); |
| + } |
| } |
| } |
| - NotifyObserverTreeNodeChanged(root); |
| - NotifyObserverEndBatch(); |
| + if (begin_batch) { |
| + NotifyObserverTreeNodeChanged(root); |
| + NotifyObserverEndBatch(); |
| + } |
| } |
| -void CookiesTreeModel::OnFileSystemModelInfoLoaded( |
| - const FileSystemInfoList& file_system_info) { |
| - file_system_info_list_ = file_system_info; |
| - PopulateFileSystemInfoWithFilter(std::wstring()); |
| +void CookiesTreeModel::PopulateServerBoundCertInfoWithFilter( |
| + const string16* app_id, |
| + const string16& filter) { |
| + CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| + bool begin_batch = false; |
| + |
| + for (ContainerMap::iterator ait = app_data_map_.begin(); |
| + ait != app_data_map_.end(); ++ait ) { |
|
markusheintz_
2012/06/19 20:01:34
Indentation.
nasko
2012/06/19 22:22:40
Done.
|
| + LocalDataContainer* container = ait->second; |
| + |
| + if (container->server_bound_cert_list_.empty()) |
| + continue; |
| + |
| + if (app_id && *app_id != container->app_id()) |
| + continue; |
| + |
| + if (!begin_batch) { |
| + NotifyObserverBeginBatch(); |
| + begin_batch = true; |
| + } |
| + |
| + CookieTreeAppNode* app_node = |
| + root->GetOrCreateAppNode(container->app_name(), container->app_id()); |
| + |
| + for (ServerBoundCertList::iterator cert_info = |
| + container->server_bound_cert_list_.begin(); |
|
markusheintz_
2012/06/19 20:01:34
Please fix indentation.
nasko
2012/06/19 22:22:40
Done.
|
| + cert_info != container->server_bound_cert_list_.end(); |
| + ++cert_info) { |
| + GURL origin(cert_info->server_identifier()); |
| + if (!origin.is_valid()) { |
| + // Domain Bound Cert. Make a valid URL to satisfy the |
| + // CookieTreeRootNode::GetOrCreateOriginNode interface. |
| + origin = GURL(std::string(chrome::kHttpsScheme) + |
| + content::kStandardSchemeSeparator + |
| + cert_info->server_identifier() + "/"); |
| + } |
| + string16 title = CookieTreeOriginNode::TitleForUrl(origin); |
| + |
| + if (!filter.size() || title.find(filter) != string16::npos) { |
| + CookieTreeOriginNode* origin_node = |
| + app_node->GetOrCreateOriginNode(origin); |
| + CookieTreeServerBoundCertsNode* server_bound_certs_node = |
| + origin_node->GetOrCreateServerBoundCertsNode(); |
| + server_bound_certs_node->AddServerBoundCertNode( |
| + new CookieTreeServerBoundCertNode(cert_info)); |
| + } |
| + } |
| + } |
| + if (begin_batch) { |
| + NotifyObserverTreeNodeChanged(root); |
| + NotifyObserverEndBatch(); |
| + } |
| } |
| void CookiesTreeModel::PopulateFileSystemInfoWithFilter( |
| - const std::wstring& filter) { |
| - if (file_system_info_list_.empty()) |
| - return; |
| + const string16* app_id, |
| + const string16& filter) { |
| CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| - NotifyObserverBeginBatch(); |
| - for (FileSystemInfoList::iterator file_system_info = |
| - file_system_info_list_.begin(); |
| - file_system_info != file_system_info_list_.end(); |
| - ++file_system_info) { |
| - GURL origin(file_system_info->origin); |
| - |
| - if (!filter.size() || |
| - (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != |
| - std::wstring::npos)) { |
| - CookieTreeOriginNode* origin_node = |
| - root->GetOrCreateOriginNode(origin); |
| - CookieTreeFileSystemsNode* file_systems_node = |
| - origin_node->GetOrCreateFileSystemsNode(); |
| - file_systems_node->AddFileSystemNode( |
| - new CookieTreeFileSystemNode(file_system_info)); |
| + bool begin_batch = false; |
| + |
| + for (ContainerMap::iterator ait = app_data_map_.begin(); |
| + ait != app_data_map_.end(); ++ait ) { |
|
markusheintz_
2012/06/19 20:01:34
Please fix indentation here.
nasko
2012/06/19 22:22:40
Done.
|
| + LocalDataContainer* container = ait->second; |
| + |
| + if (container->file_system_info_list_.empty()) |
| + continue; |
| + |
| + if (app_id && *app_id != container->app_id()) |
| + continue; |
| + |
| + if (!begin_batch) { |
| + NotifyObserverBeginBatch(); |
| + begin_batch = true; |
| } |
| - } |
| - NotifyObserverTreeNodeChanged(root); |
| - NotifyObserverEndBatch(); |
| -} |
| -void CookiesTreeModel::OnQuotaModelInfoLoaded( |
| - const QuotaInfoArray& quota_info) { |
| - quota_info_list_ = quota_info; |
| - PopulateQuotaInfoWithFilter(std::wstring()); |
| + CookieTreeAppNode* app_node = |
| + root->GetOrCreateAppNode(container->app_name(), container->app_id()); |
| + |
| + for (FileSystemInfoList::iterator file_system_info = |
| + container->file_system_info_list_.begin(); |
|
markusheintz_
2012/06/19 20:01:34
Please fix indentation
nasko
2012/06/19 22:22:40
Done.
|
| + file_system_info != container->file_system_info_list_.end(); |
| + ++file_system_info) { |
| + GURL origin(file_system_info->origin); |
| + |
| + if (!filter.size() || |
| + (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != |
| + string16::npos)) { |
| + CookieTreeOriginNode* origin_node = |
| + app_node->GetOrCreateOriginNode(origin); |
| + CookieTreeFileSystemsNode* file_systems_node = |
| + origin_node->GetOrCreateFileSystemsNode(); |
| + file_systems_node->AddFileSystemNode( |
| + new CookieTreeFileSystemNode(file_system_info)); |
| + } |
| + } |
| + } |
| + if (begin_batch) { |
| + NotifyObserverTreeNodeChanged(root); |
| + NotifyObserverEndBatch(); |
| + } |
| } |
| void CookiesTreeModel::PopulateQuotaInfoWithFilter( |
| - const std::wstring& filter) { |
| - if (quota_info_list_.empty()) |
| - return; |
| + const string16* app_id, |
| + const string16& filter) { |
| CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| - NotifyObserverBeginBatch(); |
| - for (QuotaInfoArray::iterator quota_info = quota_info_list_.begin(); |
| - quota_info != quota_info_list_.end(); |
| - ++quota_info) { |
| - if (!filter.size() || |
| - (UTF8ToWide(quota_info->host).find(filter) != std::wstring::npos)) { |
| - CookieTreeOriginNode* origin_node = |
| - root->GetOrCreateOriginNode(GURL("http://" + quota_info->host)); |
| - origin_node->UpdateOrCreateQuotaNode(quota_info); |
| - } |
| - } |
| - NotifyObserverTreeNodeChanged(root); |
| - NotifyObserverEndBatch(); |
| -} |
| + bool begin_batch = false; |
| -void CookiesTreeModel::OnServerBoundCertModelInfoLoaded( |
| - const ServerBoundCertList& cert_list) { |
| - server_bound_cert_list_ = cert_list; |
| - PopulateServerBoundCertInfoWithFilter(std::wstring()); |
| -} |
| + for (ContainerMap::iterator ait = app_data_map_.begin(); |
| + ait != app_data_map_.end(); ++ait ) { |
|
markusheintz_
2012/06/19 20:01:34
Pls fix intendation.
nasko
2012/06/19 22:22:40
Done.
|
| + LocalDataContainer* container = ait->second; |
| -void CookiesTreeModel::PopulateServerBoundCertInfoWithFilter( |
| - const std::wstring& filter) { |
| - if (server_bound_cert_list_.empty()) |
| - return; |
| - CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| - NotifyObserverBeginBatch(); |
| - for (ServerBoundCertList::iterator cert_info = |
| - server_bound_cert_list_.begin(); |
| - cert_info != server_bound_cert_list_.end(); |
| - ++cert_info) { |
| - GURL origin(cert_info->server_identifier()); |
| - if (!origin.is_valid()) { |
| - // Domain Bound Cert. Make a valid URL to satisfy the |
| - // CookieTreeRootNode::GetOrCreateOriginNode interface. |
| - origin = GURL(std::string(chrome::kHttpsScheme) + |
| - content::kStandardSchemeSeparator + |
| - cert_info->server_identifier() + "/"); |
| + if (container->quota_info_list_.empty()) |
| + continue; |
| + |
| + if (app_id && *app_id != container->app_id()) |
| + continue; |
| + |
| + if (!begin_batch) { |
| + NotifyObserverBeginBatch(); |
| + begin_batch = true; |
| } |
| - std::wstring title = CookieTreeOriginNode::TitleForUrl(origin); |
| - |
| - if (!filter.size() || title.find(filter) != std::wstring::npos) { |
| - CookieTreeOriginNode* origin_node = |
| - root->GetOrCreateOriginNode(origin); |
| - CookieTreeServerBoundCertsNode* server_bound_certs_node = |
| - origin_node->GetOrCreateServerBoundCertsNode(); |
| - server_bound_certs_node->AddServerBoundCertNode( |
| - new CookieTreeServerBoundCertNode(cert_info)); |
| + |
| + CookieTreeAppNode* app_node = |
| + root->GetOrCreateAppNode(container->app_name(), container->app_id()); |
| + |
| + for (QuotaInfoList::iterator quota_info = |
| + container->quota_info_list_.begin(); |
|
markusheintz_
2012/06/19 20:01:34
Please fix indentation here
nasko
2012/06/19 22:22:40
Done.
|
| + quota_info != container->quota_info_list_.end(); |
| + ++quota_info) { |
| + if (!filter.size() || |
| + (UTF8ToUTF16(quota_info->host).find(filter) != string16::npos)) { |
| + CookieTreeOriginNode* origin_node = |
| + app_node->GetOrCreateOriginNode(GURL("http://" + quota_info->host)); |
| + origin_node->UpdateOrCreateQuotaNode(quota_info); |
| + } |
| } |
| } |
| - NotifyObserverTreeNodeChanged(root); |
| - NotifyObserverEndBatch(); |
| + if (begin_batch) { |
| + NotifyObserverTreeNodeChanged(root); |
| + NotifyObserverEndBatch(); |
| + } |
| } |
| void CookiesTreeModel::NotifyObserverBeginBatch() { |
| @@ -1138,3 +1330,174 @@ void CookiesTreeModel::NotifyObserverEndBatch() { |
| TreeModelEndBatch(this)); |
| } |
| } |
| + |
| +LocalDataContainer* CookiesTreeModel::GetLocalDataContainer( |
| + const string16& app_id) { |
| + LocalDataContainer* container = app_data_map_[app_id]; |
| + return container; |
| +} |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| +// LocalDataContainer, public: |
| + |
| +LocalDataContainer::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) |
| + : app_name_(app_name), |
| + app_id_(app_id), |
| + appcache_helper_(appcache_helper), |
| + cookie_helper_(cookie_helper), |
| + database_helper_(database_helper), |
| + local_storage_helper_(local_storage_helper), |
| + session_storage_helper_(session_storage_helper), |
| + indexed_db_helper_(indexed_db_helper), |
| + file_system_helper_(file_system_helper), |
| + quota_helper_(quota_helper), |
| + server_bound_cert_helper_(server_bound_cert_helper), |
| + delegate_(NULL), |
| + ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {} |
| + |
| +LocalDataContainer::~LocalDataContainer() {} |
| + |
| +void LocalDataContainer::Init(CookiesTreeModelDelegate* d) { |
|
markusheintz_
2012/06/19 20:01:34
nit: s/d/delegate/
nasko
2012/06/19 22:22:40
Done.
|
| + DCHECK(!delegate_); |
| + delegate_ = d; |
| + |
| + DCHECK(cookie_helper_); |
| + cookie_helper_->StartFetching( |
| + base::Bind(&LocalDataContainer::OnCookiesModelInfoLoaded, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + DCHECK(database_helper_); |
| + database_helper_->StartFetching( |
| + base::Bind(&LocalDataContainer::OnDatabaseModelInfoLoaded, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + DCHECK(local_storage_helper_); |
| + local_storage_helper_->StartFetching( |
| + base::Bind(&LocalDataContainer::OnLocalStorageModelInfoLoaded, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + if (session_storage_helper_) { |
| + session_storage_helper_->StartFetching( |
| + base::Bind(&LocalDataContainer::OnSessionStorageModelInfoLoaded, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + } |
| + |
| + // TODO(michaeln): When all of the UI implementations have been updated, make |
| + // this a required parameter. |
| + if (appcache_helper_) { |
| + appcache_helper_->StartFetching( |
| + base::Bind(&LocalDataContainer::OnAppCacheModelInfoLoaded, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + } |
| + |
| + if (indexed_db_helper_) { |
| + indexed_db_helper_->StartFetching( |
| + base::Bind(&LocalDataContainer::OnIndexedDBModelInfoLoaded, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + } |
| + |
| + if (file_system_helper_) { |
| + file_system_helper_->StartFetching( |
| + base::Bind(&LocalDataContainer::OnFileSystemModelInfoLoaded, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + } |
| + |
| + if (quota_helper_) { |
| + quota_helper_->StartFetching( |
| + base::Bind(&LocalDataContainer::OnQuotaModelInfoLoaded, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + } |
| + |
| + if (server_bound_cert_helper_) { |
| + server_bound_cert_helper_->StartFetching( |
| + base::Bind(&LocalDataContainer::OnServerBoundCertModelInfoLoaded, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + } |
| +} |
| + |
| +void LocalDataContainer::OnAppCacheModelInfoLoaded() { |
| + 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()); |
| + } |
| + |
| + delegate_->PopulateAppCacheInfoWithFilter(&app_name_, string16()); |
| +} |
| + |
| +void LocalDataContainer::OnCookiesModelInfoLoaded( |
| + const net::CookieList& cookie_list) { |
| + cookie_list_.insert(cookie_list_.begin(), |
| + cookie_list.begin(), |
| + cookie_list.end()); |
| + DCHECK(delegate_); |
| + delegate_->PopulateCookieInfoWithFilter(&app_id_, string16()); |
| +} |
| + |
| +void LocalDataContainer::OnDatabaseModelInfoLoaded( |
| + const DatabaseInfoList& database_info) { |
| + database_info_list_ = database_info; |
| + DCHECK(delegate_); |
| + delegate_->PopulateDatabaseInfoWithFilter(&app_id_, string16()); |
| +} |
| + |
| +void LocalDataContainer::OnLocalStorageModelInfoLoaded( |
| + const LocalStorageInfoList& local_storage_info) { |
| + local_storage_info_list_ = local_storage_info; |
| + DCHECK(delegate_); |
| + delegate_->PopulateLocalStorageInfoWithFilter(&app_id_, string16()); |
| +} |
| + |
| +void LocalDataContainer::OnSessionStorageModelInfoLoaded( |
| + const LocalStorageInfoList& session_storage_info) { |
| + session_storage_info_list_ = session_storage_info; |
| + DCHECK(delegate_); |
| + delegate_->PopulateSessionStorageInfoWithFilter(&app_id_, string16()); |
| +} |
| + |
| +void LocalDataContainer::OnIndexedDBModelInfoLoaded( |
| + const IndexedDBInfoList& indexed_db_info) { |
| + indexed_db_info_list_ = indexed_db_info; |
| + DCHECK(delegate_); |
| + delegate_->PopulateIndexedDBInfoWithFilter(&app_id_, string16()); |
| +} |
|
markusheintz_
2012/06/19 20:01:34
nit: Please add an empty line here.
nasko
2012/06/19 22:22:40
Done.
|
| +void LocalDataContainer::OnFileSystemModelInfoLoaded( |
| + const FileSystemInfoList& file_system_info) { |
| + file_system_info_list_ = file_system_info; |
| + DCHECK(delegate_); |
| + delegate_->PopulateFileSystemInfoWithFilter(&app_id_, string16()); |
| +} |
| + |
| +void LocalDataContainer::OnQuotaModelInfoLoaded( |
| + const QuotaInfoList& quota_info) { |
| + quota_info_list_ = quota_info; |
| + DCHECK(delegate_); |
| + delegate_->PopulateQuotaInfoWithFilter(&app_id_, string16()); |
| +} |
| + |
| +void LocalDataContainer::OnServerBoundCertModelInfoLoaded( |
| + const ServerBoundCertList& cert_list) { |
| + server_bound_cert_list_ = cert_list; |
| + DCHECK(delegate_); |
| + delegate_->PopulateServerBoundCertInfoWithFilter(&app_id_, string16()); |
| +} |