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 8a001f69135072f5b3a019474b1a25945bb49eb3..e780f76e67529de894fde8ef50efbf48e3baab2b 100644 |
| --- a/chrome/browser/cookies_tree_model.cc |
| +++ b/chrome/browser/cookies_tree_model.cc |
| @@ -68,7 +68,7 @@ void CookieTreeCookieNode::DeleteStoredObjects() { |
| CookieTreeNode::DetailedInfo CookieTreeCookieNode::GetDetailedInfo() const { |
| return DetailedInfo(parent()->parent()->GetTitle(), |
| DetailedInfo::TYPE_COOKIE, |
| - cookie_, NULL, NULL, NULL, NULL, NULL, NULL); |
| + cookie_, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| } |
| namespace { |
| @@ -148,7 +148,7 @@ void CookieTreeAppCacheNode::DeleteStoredObjects() { |
| 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, appcache_info_, NULL, NULL, NULL); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -172,7 +172,7 @@ void CookieTreeDatabaseNode::DeleteStoredObjects() { |
| CookieTreeNode::DetailedInfo CookieTreeDatabaseNode::GetDetailedInfo() const { |
| return DetailedInfo(parent()->parent()->GetTitle(), |
| DetailedInfo::TYPE_DATABASE, |
| - NULL, database_info_, NULL, NULL, NULL, NULL, NULL); |
| + NULL, database_info_, NULL, NULL, NULL, NULL, NULL, NULL); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -198,7 +198,8 @@ 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); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -220,7 +221,7 @@ CookieTreeSessionStorageNode::GetDetailedInfo() const { |
| return DetailedInfo(parent()->parent()->GetTitle(), |
| DetailedInfo::TYPE_SESSION_STORAGE, |
| NULL, NULL, NULL, session_storage_info_, NULL, NULL, |
| - NULL); |
| + NULL, NULL); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -245,7 +246,8 @@ void CookieTreeIndexedDBNode::DeleteStoredObjects() { |
| 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); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -268,7 +270,29 @@ void CookieTreeFileSystemNode::DeleteStoredObjects() { |
| 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); |
| +} |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| +// CookieTreeQuotaNode, public: |
| + |
| +CookieTreeQuotaNode::CookieTreeQuotaNode( |
| + BrowsingDataQuotaHelper::QuotaInfo* quota_info) |
| + : CookieTreeNode(UTF8ToUTF16(quota_info->host)), |
| + quota_info_(quota_info) { |
| +} |
| + |
| +CookieTreeQuotaNode::~CookieTreeQuotaNode() {} |
| + |
| +void CookieTreeQuotaNode::DeleteStoredObjects() { |
| + GetModel()->quota_helper_->DeleteQuotaHost(quota_info_->host); |
| +} |
| + |
| +CookieTreeNode::DetailedInfo CookieTreeQuotaNode::GetDetailedInfo() const { |
| + return DetailedInfo(parent()->parent()->GetTitle(), |
| + DetailedInfo::TYPE_QUOTA, |
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, quota_info_); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -310,7 +334,7 @@ CookiesTreeModel* CookieTreeRootNode::GetModel() const { |
| CookieTreeNode::DetailedInfo CookieTreeRootNode::GetDetailedInfo() const { |
| return DetailedInfo(string16(), |
| DetailedInfo::TYPE_ROOT, |
| - NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -331,6 +355,7 @@ CookieTreeOriginNode::CookieTreeOriginNode(const GURL& url) |
| appcaches_child_(NULL), |
| indexed_dbs_child_(NULL), |
| file_systems_child_(NULL), |
| + quota_child_(NULL), |
| url_(url) {} |
| CookieTreeOriginNode::~CookieTreeOriginNode() {} |
| @@ -338,7 +363,7 @@ CookieTreeOriginNode::~CookieTreeOriginNode() {} |
| CookieTreeNode::DetailedInfo CookieTreeOriginNode::GetDetailedInfo() const { |
| return DetailedInfo(GetTitle(), |
| DetailedInfo::TYPE_ORIGIN, |
| - NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| } |
| CookieTreeCookiesNode* CookieTreeOriginNode::GetOrCreateCookiesNode() { |
| @@ -399,6 +424,15 @@ CookieTreeFileSystemsNode* CookieTreeOriginNode::GetOrCreateFileSystemsNode() { |
| return file_systems_child_; |
| } |
| +CookieTreeQuotaNode* CookieTreeOriginNode::UpdateOrCreateQuotaNode( |
| + BrowsingDataQuotaHelper::QuotaInfo* quota_info) { |
| + if (quota_child_) |
| + return quota_child_; |
| + quota_child_ = new CookieTreeQuotaNode(quota_info); |
| + AddChildSortedByTitle(quota_child_); |
| + return quota_child_; |
| +} |
| + |
| void CookieTreeOriginNode::CreateContentException( |
| HostContentSettingsMap* content_settings, ContentSetting setting) const { |
| if (CanCreateContentException()) { |
| @@ -427,7 +461,7 @@ CookieTreeCookiesNode::~CookieTreeCookiesNode() { |
| CookieTreeNode::DetailedInfo CookieTreeCookiesNode::GetDetailedInfo() const { |
| return DetailedInfo(parent()->GetTitle(), |
| DetailedInfo::TYPE_COOKIES, |
| - NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -443,7 +477,7 @@ CookieTreeAppCachesNode::~CookieTreeAppCachesNode() {} |
| CookieTreeNode::DetailedInfo CookieTreeAppCachesNode::GetDetailedInfo() const { |
| return DetailedInfo(parent()->GetTitle(), |
| DetailedInfo::TYPE_APPCACHES, |
| - NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -458,7 +492,7 @@ CookieTreeDatabasesNode::~CookieTreeDatabasesNode() {} |
| CookieTreeNode::DetailedInfo CookieTreeDatabasesNode::GetDetailedInfo() const { |
| return DetailedInfo(parent()->GetTitle(), |
| DetailedInfo::TYPE_DATABASES, |
| - NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -474,7 +508,7 @@ CookieTreeNode::DetailedInfo |
| CookieTreeLocalStoragesNode::GetDetailedInfo() const { |
| return DetailedInfo(parent()->GetTitle(), |
| DetailedInfo::TYPE_LOCAL_STORAGES, |
| - NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -490,7 +524,7 @@ CookieTreeNode::DetailedInfo |
| CookieTreeSessionStoragesNode::GetDetailedInfo() const { |
| return DetailedInfo(parent()->GetTitle(), |
| DetailedInfo::TYPE_SESSION_STORAGES, |
| - NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -506,7 +540,7 @@ CookieTreeNode::DetailedInfo |
| CookieTreeIndexedDBsNode::GetDetailedInfo() const { |
| return DetailedInfo(parent()->GetTitle(), |
| DetailedInfo::TYPE_INDEXED_DBS, |
| - NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -522,7 +556,7 @@ CookieTreeNode::DetailedInfo |
| CookieTreeFileSystemsNode::GetDetailedInfo() const { |
| return DetailedInfo(parent()->GetTitle(), |
| DetailedInfo::TYPE_FILE_SYSTEMS, |
| - NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -558,6 +592,7 @@ CookiesTreeModel::CookiesTreeModel( |
| BrowsingDataAppCacheHelper* appcache_helper, |
| BrowsingDataIndexedDBHelper* indexed_db_helper, |
| BrowsingDataFileSystemHelper* file_system_helper, |
| + BrowsingDataQuotaHelper* quota_helper, |
| bool use_cookie_source) |
| : ALLOW_THIS_IN_INITIALIZER_LIST(ui::TreeNodeModel<CookieTreeNode>( |
| new CookieTreeRootNode(this))), |
| @@ -568,6 +603,7 @@ CookiesTreeModel::CookiesTreeModel( |
| session_storage_helper_(session_storage_helper), |
| indexed_db_helper_(indexed_db_helper), |
| file_system_helper_(file_system_helper), |
| + quota_helper_(quota_helper), |
| batch_update_(0), |
| use_cookie_source_(use_cookie_source) { |
| LoadCookies(); |
| @@ -598,6 +634,11 @@ CookiesTreeModel::CookiesTreeModel( |
| file_system_helper_->StartFetching(NewCallback( |
| this, &CookiesTreeModel::OnFileSystemModelInfoLoaded)); |
| } |
| + |
| + if (quota_helper_) { |
| + quota_helper_->StartFetching(NewCallback( |
| + this, &CookiesTreeModel::OnQuotaModelInfoLoaded)); |
| + } |
| } |
| CookiesTreeModel::~CookiesTreeModel() { |
| @@ -611,6 +652,8 @@ CookiesTreeModel::~CookiesTreeModel() { |
| indexed_db_helper_->CancelNotification(); |
| if (file_system_helper_) |
| file_system_helper_->CancelNotification(); |
| + if (quota_helper_) |
| + quota_helper_->CancelNotification(); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -650,6 +693,8 @@ int CookiesTreeModel::GetIconIndex(ui::TreeModelNode* node) { |
| return DATABASE; // ditto |
| case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: |
| return DATABASE; // ditto |
| + case CookieTreeNode::DetailedInfo::TYPE_QUOTA: |
| + return -1; |
| default: |
| break; |
| } |
| @@ -726,6 +771,7 @@ void CookiesTreeModel::UpdateSearchResults(const std::wstring& filter) { |
| PopulateAppCacheInfoWithFilter(filter); |
| PopulateIndexedDBInfoWithFilter(filter); |
| PopulateFileSystemInfoWithFilter(filter); |
| + PopulateQuotaInfoWithFilter(filter); |
| NotifyObserverTreeNodeChanged(root); |
| NotifyObserverEndBatch(); |
| } |
| @@ -944,6 +990,32 @@ void CookiesTreeModel::PopulateFileSystemInfoWithFilter( |
| NotifyObserverEndBatch(); |
| } |
| +void CookiesTreeModel::OnQuotaModelInfoLoaded( |
| + const QuotaInfoList& quota_info) { |
| + quota_info_list_ = quota_info; |
| + PopulateQuotaInfoWithFilter(std::wstring()); |
| +} |
| + |
| +void CookiesTreeModel::PopulateQuotaInfoWithFilter( |
| + const std::wstring& filter) { |
| + if (quota_info_list_.empty()) |
| + return; |
| + CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| + NotifyObserverBeginBatch(); |
| + for (QuotaInfoList::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)); |
|
tzik
2011/07/25 04:40:58
CookiesTreeOriginNode looks not fully host-based,
|
| + origin_node->UpdateOrCreateQuotaNode(&*quota_info); |
| + } |
| + } |
| + NotifyObserverTreeNodeChanged(root); |
| + NotifyObserverEndBatch(); |
| +} |
| + |
| void CookiesTreeModel::NotifyObserverBeginBatch() { |
| // Only notify the model once if we're batching in a nested manner. |
| if (batch_update_++ == 0) { |