Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1078)

Side by Side Diff: chrome/browser/browsing_data/cookies_tree_model.cc

Issue 1297093002: Cache Storage API: Hook up to chrome://settings/cookies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto https://codereview.chromium.org/1297023004 Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browsing_data/cookies_tree_model.h" 5 #include "chrome/browser/browsing_data/cookies_tree_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: 146 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB:
147 return true; 147 return true;
148 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: 148 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM:
149 return true; 149 return true;
150 case CookieTreeNode::DetailedInfo::TYPE_QUOTA: 150 case CookieTreeNode::DetailedInfo::TYPE_QUOTA:
151 return false; 151 return false;
152 case CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID: 152 case CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID:
153 return false; 153 return false;
154 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER: 154 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER:
155 return true; 155 return true;
156 case CookieTreeNode::DetailedInfo::TYPE_CACHE_STORAGE:
157 return true;
156 case CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO: 158 case CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO:
157 return false; 159 return false;
158 default: 160 default:
159 break; 161 break;
160 } 162 }
161 return false; 163 return false;
162 } 164 }
163 #endif 165 #endif
164 166
165 // This function returns the local data container associated with a leaf tree 167 // This function returns the local data container associated with a leaf tree
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 267 }
266 268
267 CookieTreeNode::DetailedInfo& CookieTreeNode::DetailedInfo::InitServiceWorker( 269 CookieTreeNode::DetailedInfo& CookieTreeNode::DetailedInfo::InitServiceWorker(
268 const content::ServiceWorkerUsageInfo* service_worker_info) { 270 const content::ServiceWorkerUsageInfo* service_worker_info) {
269 Init(TYPE_SERVICE_WORKER); 271 Init(TYPE_SERVICE_WORKER);
270 this->service_worker_info = service_worker_info; 272 this->service_worker_info = service_worker_info;
271 this->origin = service_worker_info->origin; 273 this->origin = service_worker_info->origin;
272 return *this; 274 return *this;
273 } 275 }
274 276
277 CookieTreeNode::DetailedInfo& CookieTreeNode::DetailedInfo::InitCacheStorage(
278 const content::CacheStorageUsageInfo* cache_storage_info) {
279 Init(TYPE_CACHE_STORAGE);
280 this->cache_storage_info = cache_storage_info;
281 this->origin = cache_storage_info->origin;
282 return *this;
283 }
284
275 CookieTreeNode::DetailedInfo& CookieTreeNode::DetailedInfo::InitFlashLSO( 285 CookieTreeNode::DetailedInfo& CookieTreeNode::DetailedInfo::InitFlashLSO(
276 const std::string& flash_lso_domain) { 286 const std::string& flash_lso_domain) {
277 Init(TYPE_FLASH_LSO); 287 Init(TYPE_FLASH_LSO);
278 this->flash_lso_domain = flash_lso_domain; 288 this->flash_lso_domain = flash_lso_domain;
279 return *this; 289 return *this;
280 } 290 }
281 291
282 /////////////////////////////////////////////////////////////////////////////// 292 ///////////////////////////////////////////////////////////////////////////////
283 // CookieTreeNode, public: 293 // CookieTreeNode, public:
284 294
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 container->service_worker_info_list_.erase(service_worker_info_); 567 container->service_worker_info_list_.erase(service_worker_info_);
558 } 568 }
559 } 569 }
560 570
561 CookieTreeNode::DetailedInfo CookieTreeServiceWorkerNode::GetDetailedInfo() 571 CookieTreeNode::DetailedInfo CookieTreeServiceWorkerNode::GetDetailedInfo()
562 const { 572 const {
563 return DetailedInfo().InitServiceWorker(&*service_worker_info_); 573 return DetailedInfo().InitServiceWorker(&*service_worker_info_);
564 } 574 }
565 575
566 /////////////////////////////////////////////////////////////////////////////// 576 ///////////////////////////////////////////////////////////////////////////////
577 // CookieTreeCacheStorageNode, public:
578
579 CookieTreeCacheStorageNode::CookieTreeCacheStorageNode(
580 std::list<content::CacheStorageUsageInfo>::iterator cache_storage_info)
581 : CookieTreeNode(base::UTF8ToUTF16(cache_storage_info->origin.spec())),
582 cache_storage_info_(cache_storage_info) {}
583
584 CookieTreeCacheStorageNode::~CookieTreeCacheStorageNode() {}
585
586 void CookieTreeCacheStorageNode::DeleteStoredObjects() {
587 LocalDataContainer* container = GetLocalDataContainerForNode(this);
588
589 if (container) {
590 container->cache_storage_helper_->DeleteCacheStorage(
591 cache_storage_info_->origin);
592 container->cache_storage_info_list_.erase(cache_storage_info_);
593 }
594 }
595
596 CookieTreeNode::DetailedInfo CookieTreeCacheStorageNode::GetDetailedInfo()
597 const {
598 return DetailedInfo().InitCacheStorage(&*cache_storage_info_);
599 }
600
601 ///////////////////////////////////////////////////////////////////////////////
567 // CookieTreeRootNode, public: 602 // CookieTreeRootNode, public:
568 603
569 CookieTreeRootNode::CookieTreeRootNode(CookiesTreeModel* model) 604 CookieTreeRootNode::CookieTreeRootNode(CookiesTreeModel* model)
570 : model_(model) { 605 : model_(model) {
571 } 606 }
572 607
573 CookieTreeRootNode::~CookieTreeRootNode() {} 608 CookieTreeRootNode::~CookieTreeRootNode() {}
574 609
575 CookieTreeHostNode* CookieTreeRootNode::GetOrCreateHostNode( 610 CookieTreeHostNode* CookieTreeRootNode::GetOrCreateHostNode(
576 const GURL& url) { 611 const GURL& url) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 741
707 CookieTreeServiceWorkersNode* 742 CookieTreeServiceWorkersNode*
708 CookieTreeHostNode::GetOrCreateServiceWorkersNode() { 743 CookieTreeHostNode::GetOrCreateServiceWorkersNode() {
709 if (service_workers_child_) 744 if (service_workers_child_)
710 return service_workers_child_; 745 return service_workers_child_;
711 service_workers_child_ = new CookieTreeServiceWorkersNode; 746 service_workers_child_ = new CookieTreeServiceWorkersNode;
712 AddChildSortedByTitle(service_workers_child_); 747 AddChildSortedByTitle(service_workers_child_);
713 return service_workers_child_; 748 return service_workers_child_;
714 } 749 }
715 750
751 CookieTreeCacheStoragesNode*
752 CookieTreeHostNode::GetOrCreateCacheStoragesNode() {
753 if (cache_storages_child_)
754 return cache_storages_child_;
755 cache_storages_child_ = new CookieTreeCacheStoragesNode;
756 AddChildSortedByTitle(cache_storages_child_);
757 return cache_storages_child_;
758 }
759
716 CookieTreeFlashLSONode* CookieTreeHostNode::GetOrCreateFlashLSONode( 760 CookieTreeFlashLSONode* CookieTreeHostNode::GetOrCreateFlashLSONode(
717 const std::string& domain) { 761 const std::string& domain) {
718 DCHECK_EQ(GetHost(), domain); 762 DCHECK_EQ(GetHost(), domain);
719 if (flash_lso_child_) 763 if (flash_lso_child_)
720 return flash_lso_child_; 764 return flash_lso_child_;
721 flash_lso_child_ = new CookieTreeFlashLSONode(domain); 765 flash_lso_child_ = new CookieTreeFlashLSONode(domain);
722 AddChildSortedByTitle(flash_lso_child_); 766 AddChildSortedByTitle(flash_lso_child_);
723 return flash_lso_child_; 767 return flash_lso_child_;
724 } 768 }
725 769
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 916
873 CookieTreeServiceWorkersNode::~CookieTreeServiceWorkersNode() { 917 CookieTreeServiceWorkersNode::~CookieTreeServiceWorkersNode() {
874 } 918 }
875 919
876 CookieTreeNode::DetailedInfo CookieTreeServiceWorkersNode::GetDetailedInfo() 920 CookieTreeNode::DetailedInfo CookieTreeServiceWorkersNode::GetDetailedInfo()
877 const { 921 const {
878 return DetailedInfo().Init(DetailedInfo::TYPE_SERVICE_WORKERS); 922 return DetailedInfo().Init(DetailedInfo::TYPE_SERVICE_WORKERS);
879 } 923 }
880 924
881 /////////////////////////////////////////////////////////////////////////////// 925 ///////////////////////////////////////////////////////////////////////////////
926 // CookieTreeCacheStoragesNode, public:
927
928 CookieTreeCacheStoragesNode::CookieTreeCacheStoragesNode()
929 : CookieTreeNode(l10n_util::GetStringUTF16(IDS_COOKIES_CACHE_STORAGE)) {}
930
931 CookieTreeCacheStoragesNode::~CookieTreeCacheStoragesNode() {}
932
933 CookieTreeNode::DetailedInfo CookieTreeCacheStoragesNode::GetDetailedInfo()
934 const {
935 return DetailedInfo().Init(DetailedInfo::TYPE_CACHE_STORAGES);
936 }
937
938 ///////////////////////////////////////////////////////////////////////////////
882 // CookieTreeFlashLSONode 939 // CookieTreeFlashLSONode
883 CookieTreeFlashLSONode::CookieTreeFlashLSONode( 940 CookieTreeFlashLSONode::CookieTreeFlashLSONode(
884 const std::string& domain) 941 const std::string& domain)
885 : domain_(domain) {} 942 : domain_(domain) {}
886 CookieTreeFlashLSONode::~CookieTreeFlashLSONode() {} 943 CookieTreeFlashLSONode::~CookieTreeFlashLSONode() {}
887 944
888 void CookieTreeFlashLSONode::DeleteStoredObjects() { 945 void CookieTreeFlashLSONode::DeleteStoredObjects() {
889 // We are one level below the host node. 946 // We are one level below the host node.
890 CookieTreeHostNode* host = static_cast<CookieTreeHostNode*>(parent()); 947 CookieTreeHostNode* host = static_cast<CookieTreeHostNode*>(parent());
891 CHECK_EQ(host->GetDetailedInfo().node_type, 948 CHECK_EQ(host->GetDetailedInfo().node_type,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: 1048 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB:
992 return DATABASE; // ditto 1049 return DATABASE; // ditto
993 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: 1050 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM:
994 return DATABASE; // ditto 1051 return DATABASE; // ditto
995 case CookieTreeNode::DetailedInfo::TYPE_QUOTA: 1052 case CookieTreeNode::DetailedInfo::TYPE_QUOTA:
996 return -1; 1053 return -1;
997 case CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID: 1054 case CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID:
998 return COOKIE; // It's kinda like a cookie? 1055 return COOKIE; // It's kinda like a cookie?
999 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER: 1056 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER:
1000 return DATABASE; // Just like appcache 1057 return DATABASE; // Just like appcache
1058 case CookieTreeNode::DetailedInfo::TYPE_CACHE_STORAGE:
1059 return DATABASE; // ditto
1001 default: 1060 default:
1002 break; 1061 break;
1003 } 1062 }
1004 return -1; 1063 return -1;
1005 } 1064 }
1006 1065
1007 void CookiesTreeModel::DeleteAllStoredObjects() { 1066 void CookiesTreeModel::DeleteAllStoredObjects() {
1008 NotifyObserverBeginBatch(); 1067 NotifyObserverBeginBatch();
1009 CookieTreeNode* root = GetRoot(); 1068 CookieTreeNode* root = GetRoot();
1010 root->DeleteStoredObjects(); 1069 root->DeleteStoredObjects();
(...skipping 26 matching lines...) Expand all
1037 PopulateCookieInfoWithFilter(data_container(), &notifier, filter); 1096 PopulateCookieInfoWithFilter(data_container(), &notifier, filter);
1038 PopulateDatabaseInfoWithFilter(data_container(), &notifier, filter); 1097 PopulateDatabaseInfoWithFilter(data_container(), &notifier, filter);
1039 PopulateLocalStorageInfoWithFilter(data_container(), &notifier, filter); 1098 PopulateLocalStorageInfoWithFilter(data_container(), &notifier, filter);
1040 PopulateSessionStorageInfoWithFilter(data_container(), &notifier, filter); 1099 PopulateSessionStorageInfoWithFilter(data_container(), &notifier, filter);
1041 PopulateAppCacheInfoWithFilter(data_container(), &notifier, filter); 1100 PopulateAppCacheInfoWithFilter(data_container(), &notifier, filter);
1042 PopulateIndexedDBInfoWithFilter(data_container(), &notifier, filter); 1101 PopulateIndexedDBInfoWithFilter(data_container(), &notifier, filter);
1043 PopulateFileSystemInfoWithFilter(data_container(), &notifier, filter); 1102 PopulateFileSystemInfoWithFilter(data_container(), &notifier, filter);
1044 PopulateQuotaInfoWithFilter(data_container(), &notifier, filter); 1103 PopulateQuotaInfoWithFilter(data_container(), &notifier, filter);
1045 PopulateChannelIDInfoWithFilter(data_container(), &notifier, filter); 1104 PopulateChannelIDInfoWithFilter(data_container(), &notifier, filter);
1046 PopulateServiceWorkerUsageInfoWithFilter(data_container(), &notifier, filter); 1105 PopulateServiceWorkerUsageInfoWithFilter(data_container(), &notifier, filter);
1106 PopulateCacheStorageUsageInfoWithFilter(data_container(), &notifier, filter);
1047 } 1107 }
1048 1108
1049 #if defined(ENABLE_EXTENSIONS) 1109 #if defined(ENABLE_EXTENSIONS)
1050 const extensions::ExtensionSet* CookiesTreeModel::ExtensionsProtectingNode( 1110 const extensions::ExtensionSet* CookiesTreeModel::ExtensionsProtectingNode(
1051 const CookieTreeNode& cookie_node) { 1111 const CookieTreeNode& cookie_node) {
1052 if (!special_storage_policy_.get()) 1112 if (!special_storage_policy_.get())
1053 return nullptr; 1113 return nullptr;
1054 1114
1055 CookieTreeNode::DetailedInfo info = cookie_node.GetDetailedInfo(); 1115 CookieTreeNode::DetailedInfo info = cookie_node.GetDetailedInfo();
1056 1116
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 PopulateChannelIDInfoWithFilter(container, &notifier, base::string16()); 1181 PopulateChannelIDInfoWithFilter(container, &notifier, base::string16());
1122 } 1182 }
1123 1183
1124 void CookiesTreeModel::PopulateServiceWorkerUsageInfo( 1184 void CookiesTreeModel::PopulateServiceWorkerUsageInfo(
1125 LocalDataContainer* container) { 1185 LocalDataContainer* container) {
1126 ScopedBatchUpdateNotifier notifier(this, GetRoot()); 1186 ScopedBatchUpdateNotifier notifier(this, GetRoot());
1127 PopulateServiceWorkerUsageInfoWithFilter( 1187 PopulateServiceWorkerUsageInfoWithFilter(
1128 container, &notifier, base::string16()); 1188 container, &notifier, base::string16());
1129 } 1189 }
1130 1190
1191 void CookiesTreeModel::PopulateCacheStorageUsageInfo(
1192 LocalDataContainer* container) {
1193 ScopedBatchUpdateNotifier notifier(this, GetRoot());
1194 PopulateCacheStorageUsageInfoWithFilter(container, &notifier,
1195 base::string16());
1196 }
1197
1131 void CookiesTreeModel::PopulateFlashLSOInfo( 1198 void CookiesTreeModel::PopulateFlashLSOInfo(
1132 LocalDataContainer* container) { 1199 LocalDataContainer* container) {
1133 ScopedBatchUpdateNotifier notifier(this, GetRoot()); 1200 ScopedBatchUpdateNotifier notifier(this, GetRoot());
1134 PopulateFlashLSOInfoWithFilter(container, &notifier, base::string16()); 1201 PopulateFlashLSOInfoWithFilter(container, &notifier, base::string16());
1135 } 1202 }
1136 1203
1137 void CookiesTreeModel::PopulateAppCacheInfoWithFilter( 1204 void CookiesTreeModel::PopulateAppCacheInfoWithFilter(
1138 LocalDataContainer* container, 1205 LocalDataContainer* container,
1139 ScopedBatchUpdateNotifier* notifier, 1206 ScopedBatchUpdateNotifier* notifier,
1140 const base::string16& filter) { 1207 const base::string16& filter) {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 .find(filter) != base::string16::npos)) { 1421 .find(filter) != base::string16::npos)) {
1355 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); 1422 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1356 CookieTreeServiceWorkersNode* service_workers_node = 1423 CookieTreeServiceWorkersNode* service_workers_node =
1357 host_node->GetOrCreateServiceWorkersNode(); 1424 host_node->GetOrCreateServiceWorkersNode();
1358 service_workers_node->AddServiceWorkerNode( 1425 service_workers_node->AddServiceWorkerNode(
1359 new CookieTreeServiceWorkerNode(service_worker_info)); 1426 new CookieTreeServiceWorkerNode(service_worker_info));
1360 } 1427 }
1361 } 1428 }
1362 } 1429 }
1363 1430
1431 void CookiesTreeModel::PopulateCacheStorageUsageInfoWithFilter(
1432 LocalDataContainer* container,
1433 ScopedBatchUpdateNotifier* notifier,
1434 const base::string16& filter) {
1435 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1436
1437 if (container->cache_storage_info_list_.empty())
1438 return;
1439
1440 notifier->StartBatchUpdate();
1441 for (CacheStorageUsageInfoList::iterator cache_storage_info =
1442 container->cache_storage_info_list_.begin();
1443 cache_storage_info != container->cache_storage_info_list_.end();
1444 ++cache_storage_info) {
1445 const GURL& origin = cache_storage_info->origin;
1446
1447 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin)
1448 .find(filter) != base::string16::npos)) {
1449 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1450 CookieTreeCacheStoragesNode* cache_storages_node =
1451 host_node->GetOrCreateCacheStoragesNode();
1452 cache_storages_node->AddCacheStorageNode(
1453 new CookieTreeCacheStorageNode(cache_storage_info));
1454 }
1455 }
1456 }
1457
1364 void CookiesTreeModel::PopulateFileSystemInfoWithFilter( 1458 void CookiesTreeModel::PopulateFileSystemInfoWithFilter(
1365 LocalDataContainer* container, 1459 LocalDataContainer* container,
1366 ScopedBatchUpdateNotifier* notifier, 1460 ScopedBatchUpdateNotifier* notifier,
1367 const base::string16& filter) { 1461 const base::string16& filter) {
1368 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1462 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1369 1463
1370 if (container->file_system_info_list_.empty()) 1464 if (container->file_system_info_list_.empty())
1371 return; 1465 return;
1372 1466
1373 notifier->StartBatchUpdate(); 1467 notifier->StartBatchUpdate();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 void CookiesTreeModel::MaybeNotifyBatchesEnded() { 1559 void CookiesTreeModel::MaybeNotifyBatchesEnded() {
1466 // Only notify the observers if this is the outermost call to EndBatch() if 1560 // Only notify the observers if this is the outermost call to EndBatch() if
1467 // called in a nested manner. 1561 // called in a nested manner.
1468 if (batches_ended_ == batches_started_ && 1562 if (batches_ended_ == batches_started_ &&
1469 batches_seen_ == batches_expected_) { 1563 batches_seen_ == batches_expected_) {
1470 FOR_EACH_OBSERVER(Observer, 1564 FOR_EACH_OBSERVER(Observer,
1471 cookies_observer_list_, 1565 cookies_observer_list_,
1472 TreeModelEndBatch(this)); 1566 TreeModelEndBatch(this));
1473 } 1567 }
1474 } 1568 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/cookies_tree_model.h ('k') | chrome/browser/browsing_data/cookies_tree_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698