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

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

Issue 2359393002: Adds media license nodes to cookie tree model and cookies view. (Closed)
Patch Set: Created 4 years, 3 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <functional> 10 #include <functional>
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 switch (type) { 122 switch (type) {
123 // Fall through each below cases to return true. 123 // Fall through each below cases to return true.
124 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: 124 case CookieTreeNode::DetailedInfo::TYPE_DATABASE:
125 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: 125 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE:
126 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE: 126 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE:
127 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: 127 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE:
128 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: 128 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB:
129 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: 129 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM:
130 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER: 130 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER:
131 case CookieTreeNode::DetailedInfo::TYPE_CACHE_STORAGE: 131 case CookieTreeNode::DetailedInfo::TYPE_CACHE_STORAGE:
132 case CookieTreeNode::DetailedInfo::TYPE_MEDIA_LICENSE:
msramek 2016/09/26 18:28:06 Hmm... it seems that media licenses are not protec
jrummell 2016/09/27 18:21:15 Done 1. Will follow up off-line about 2.
msramek 2016/09/28 12:28:59 Acknowledged, discussed this off-line.
132 return true; 133 return true;
133 134
134 // Fall through each below cases to return false. 135 // Fall through each below cases to return false.
135 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: 136 case CookieTreeNode::DetailedInfo::TYPE_COOKIE:
136 case CookieTreeNode::DetailedInfo::TYPE_QUOTA: 137 case CookieTreeNode::DetailedInfo::TYPE_QUOTA:
137 case CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID: 138 case CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID:
138 case CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO: 139 case CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO:
139 return false; 140 return false;
140 default: 141 default:
141 break; 142 break;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return *this; 265 return *this;
265 } 266 }
266 267
267 CookieTreeNode::DetailedInfo& CookieTreeNode::DetailedInfo::InitFlashLSO( 268 CookieTreeNode::DetailedInfo& CookieTreeNode::DetailedInfo::InitFlashLSO(
268 const std::string& flash_lso_domain) { 269 const std::string& flash_lso_domain) {
269 Init(TYPE_FLASH_LSO); 270 Init(TYPE_FLASH_LSO);
270 this->flash_lso_domain = flash_lso_domain; 271 this->flash_lso_domain = flash_lso_domain;
271 return *this; 272 return *this;
272 } 273 }
273 274
275 CookieTreeNode::DetailedInfo& CookieTreeNode::DetailedInfo::InitMediaLicense(
276 const BrowsingDataMediaLicenseHelper::MediaLicenseInfo*
277 media_license_info) {
278 Init(TYPE_MEDIA_LICENSE);
279 this->media_license_info = media_license_info;
280 this->origin = media_license_info->origin;
281 return *this;
282 }
283
274 /////////////////////////////////////////////////////////////////////////////// 284 ///////////////////////////////////////////////////////////////////////////////
275 // CookieTreeNode, public: 285 // CookieTreeNode, public:
276 286
277 void CookieTreeNode::DeleteStoredObjects() { 287 void CookieTreeNode::DeleteStoredObjects() {
278 for (auto* child : children()) 288 for (auto* child : children())
279 child->DeleteStoredObjects(); 289 child->DeleteStoredObjects();
280 } 290 }
281 291
282 CookiesTreeModel* CookieTreeNode::GetModel() const { 292 CookiesTreeModel* CookieTreeNode::GetModel() const {
283 if (parent()) 293 if (parent())
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 container->cache_storage_info_list_.erase(cache_storage_info_); 578 container->cache_storage_info_list_.erase(cache_storage_info_);
569 } 579 }
570 } 580 }
571 581
572 CookieTreeNode::DetailedInfo CookieTreeCacheStorageNode::GetDetailedInfo() 582 CookieTreeNode::DetailedInfo CookieTreeCacheStorageNode::GetDetailedInfo()
573 const { 583 const {
574 return DetailedInfo().InitCacheStorage(&*cache_storage_info_); 584 return DetailedInfo().InitCacheStorage(&*cache_storage_info_);
575 } 585 }
576 586
577 /////////////////////////////////////////////////////////////////////////////// 587 ///////////////////////////////////////////////////////////////////////////////
588 // CookieTreeMediaLicenseNode, public:
589
590 CookieTreeMediaLicenseNode::CookieTreeMediaLicenseNode(
591 const std::list<BrowsingDataMediaLicenseHelper::MediaLicenseInfo>::iterator
592 media_license_info)
593 : CookieTreeNode(base::UTF8ToUTF16(media_license_info->origin.spec())),
594 media_license_info_(media_license_info) {}
595
596 CookieTreeMediaLicenseNode::~CookieTreeMediaLicenseNode() {}
597
598 void CookieTreeMediaLicenseNode::DeleteStoredObjects() {
599 LocalDataContainer* container = GetLocalDataContainerForNode(this);
600
601 if (container) {
602 container->media_license_helper_->DeleteMediaLicenseOrigin(
603 media_license_info_->origin);
604 container->media_license_info_list_.erase(media_license_info_);
605 }
606 }
607
608 CookieTreeNode::DetailedInfo CookieTreeMediaLicenseNode::GetDetailedInfo()
609 const {
610 return DetailedInfo().InitMediaLicense(&*media_license_info_);
611 }
612
613 ///////////////////////////////////////////////////////////////////////////////
578 // CookieTreeRootNode, public: 614 // CookieTreeRootNode, public:
579 615
580 CookieTreeRootNode::CookieTreeRootNode(CookiesTreeModel* model) 616 CookieTreeRootNode::CookieTreeRootNode(CookiesTreeModel* model)
581 : model_(model) { 617 : model_(model) {
582 } 618 }
583 619
584 CookieTreeRootNode::~CookieTreeRootNode() {} 620 CookieTreeRootNode::~CookieTreeRootNode() {}
585 621
586 CookieTreeHostNode* CookieTreeRootNode::GetOrCreateHostNode(const GURL& url) { 622 CookieTreeHostNode* CookieTreeRootNode::GetOrCreateHostNode(const GURL& url) {
587 std::unique_ptr<CookieTreeHostNode> host_node(new CookieTreeHostNode(url)); 623 std::unique_ptr<CookieTreeHostNode> host_node(new CookieTreeHostNode(url));
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 CookieTreeFlashLSONode* CookieTreeHostNode::GetOrCreateFlashLSONode( 770 CookieTreeFlashLSONode* CookieTreeHostNode::GetOrCreateFlashLSONode(
735 const std::string& domain) { 771 const std::string& domain) {
736 DCHECK_EQ(GetHost(), domain); 772 DCHECK_EQ(GetHost(), domain);
737 if (flash_lso_child_) 773 if (flash_lso_child_)
738 return flash_lso_child_; 774 return flash_lso_child_;
739 flash_lso_child_ = new CookieTreeFlashLSONode(domain); 775 flash_lso_child_ = new CookieTreeFlashLSONode(domain);
740 AddChildSortedByTitle(flash_lso_child_); 776 AddChildSortedByTitle(flash_lso_child_);
741 return flash_lso_child_; 777 return flash_lso_child_;
742 } 778 }
743 779
780 CookieTreeMediaLicensesNode*
781 CookieTreeHostNode::GetOrCreateMediaLicensesNode() {
782 if (media_licenses_child_)
783 return media_licenses_child_;
784 media_licenses_child_ = new CookieTreeMediaLicensesNode();
785 AddChildSortedByTitle(media_licenses_child_);
786 return media_licenses_child_;
787 }
788
744 void CookieTreeHostNode::CreateContentException( 789 void CookieTreeHostNode::CreateContentException(
745 content_settings::CookieSettings* cookie_settings, 790 content_settings::CookieSettings* cookie_settings,
746 ContentSetting setting) const { 791 ContentSetting setting) const {
747 DCHECK(setting == CONTENT_SETTING_ALLOW || 792 DCHECK(setting == CONTENT_SETTING_ALLOW ||
748 setting == CONTENT_SETTING_BLOCK || 793 setting == CONTENT_SETTING_BLOCK ||
749 setting == CONTENT_SETTING_SESSION_ONLY); 794 setting == CONTENT_SETTING_SESSION_ONLY);
750 if (CanCreateContentException()) { 795 if (CanCreateContentException()) {
751 cookie_settings->ResetCookieSetting(url_); 796 cookie_settings->ResetCookieSetting(url_);
752 cookie_settings->SetCookieSetting(url_, setting); 797 cookie_settings->SetCookieSetting(url_, setting);
753 } 798 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 LocalDataContainer* container = GetModel()->data_container(); 965 LocalDataContainer* container = GetModel()->data_container();
921 container->flash_lso_helper_->DeleteFlashLSOsForSite( 966 container->flash_lso_helper_->DeleteFlashLSOsForSite(
922 domain_, base::Closure()); 967 domain_, base::Closure());
923 } 968 }
924 969
925 CookieTreeNode::DetailedInfo CookieTreeFlashLSONode::GetDetailedInfo() const { 970 CookieTreeNode::DetailedInfo CookieTreeFlashLSONode::GetDetailedInfo() const {
926 return DetailedInfo().InitFlashLSO(domain_); 971 return DetailedInfo().InitFlashLSO(domain_);
927 } 972 }
928 973
929 /////////////////////////////////////////////////////////////////////////////// 974 ///////////////////////////////////////////////////////////////////////////////
975 // CookieTreeMediaLicensesNode
976 CookieTreeMediaLicensesNode::CookieTreeMediaLicensesNode()
977 : CookieTreeNode(l10n_util::GetStringUTF16(IDS_COOKIES_MEDIA_LICENSES)) {}
978
979 CookieTreeMediaLicensesNode::~CookieTreeMediaLicensesNode() {}
980
981 CookieTreeNode::DetailedInfo CookieTreeMediaLicensesNode::GetDetailedInfo()
982 const {
983 return DetailedInfo().Init(DetailedInfo::TYPE_MEDIA_LICENSES);
984 }
985
986 ///////////////////////////////////////////////////////////////////////////////
930 // ScopedBatchUpdateNotifier 987 // ScopedBatchUpdateNotifier
931 CookiesTreeModel::ScopedBatchUpdateNotifier::ScopedBatchUpdateNotifier( 988 CookiesTreeModel::ScopedBatchUpdateNotifier::ScopedBatchUpdateNotifier(
932 CookiesTreeModel* model, 989 CookiesTreeModel* model,
933 CookieTreeNode* node) 990 CookieTreeNode* node)
934 : model_(model), node_(node) { 991 : model_(model), node_(node) {
935 model_->RecordBatchSeen(); 992 model_->RecordBatchSeen();
936 } 993 }
937 994
938 CookiesTreeModel::ScopedBatchUpdateNotifier::~ScopedBatchUpdateNotifier() { 995 CookiesTreeModel::ScopedBatchUpdateNotifier::~ScopedBatchUpdateNotifier() {
939 if (batch_in_progress_) { 996 if (batch_in_progress_) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 1069
1013 // Fall through each below cases to return DATABASE. 1070 // Fall through each below cases to return DATABASE.
1014 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: 1071 case CookieTreeNode::DetailedInfo::TYPE_DATABASE:
1015 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: 1072 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE:
1016 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE: 1073 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE:
1017 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: 1074 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE:
1018 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: 1075 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB:
1019 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: 1076 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM:
1020 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER: 1077 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER:
1021 case CookieTreeNode::DetailedInfo::TYPE_CACHE_STORAGE: 1078 case CookieTreeNode::DetailedInfo::TYPE_CACHE_STORAGE:
1079 case CookieTreeNode::DetailedInfo::TYPE_MEDIA_LICENSE:
1022 return DATABASE; 1080 return DATABASE;
1023 case CookieTreeNode::DetailedInfo::TYPE_QUOTA: 1081 case CookieTreeNode::DetailedInfo::TYPE_QUOTA:
1024 return -1; 1082 return -1;
1025 default: 1083 default:
1026 break; 1084 break;
1027 } 1085 }
1028 return -1; 1086 return -1;
1029 } 1087 }
1030 1088
1031 void CookiesTreeModel::DeleteAllStoredObjects() { 1089 void CookiesTreeModel::DeleteAllStoredObjects() {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 PopulateCacheStorageUsageInfoWithFilter(container, &notifier, 1217 PopulateCacheStorageUsageInfoWithFilter(container, &notifier,
1160 base::string16()); 1218 base::string16());
1161 } 1219 }
1162 1220
1163 void CookiesTreeModel::PopulateFlashLSOInfo( 1221 void CookiesTreeModel::PopulateFlashLSOInfo(
1164 LocalDataContainer* container) { 1222 LocalDataContainer* container) {
1165 ScopedBatchUpdateNotifier notifier(this, GetRoot()); 1223 ScopedBatchUpdateNotifier notifier(this, GetRoot());
1166 PopulateFlashLSOInfoWithFilter(container, &notifier, base::string16()); 1224 PopulateFlashLSOInfoWithFilter(container, &notifier, base::string16());
1167 } 1225 }
1168 1226
1227 void CookiesTreeModel::PopulateMediaLicenseInfo(LocalDataContainer* container) {
1228 ScopedBatchUpdateNotifier notifier(this, GetRoot());
1229 PopulateMediaLicenseInfoWithFilter(container, &notifier, base::string16());
1230 }
1231
1169 void CookiesTreeModel::PopulateAppCacheInfoWithFilter( 1232 void CookiesTreeModel::PopulateAppCacheInfoWithFilter(
1170 LocalDataContainer* container, 1233 LocalDataContainer* container,
1171 ScopedBatchUpdateNotifier* notifier, 1234 ScopedBatchUpdateNotifier* notifier,
1172 const base::string16& filter) { 1235 const base::string16& filter) {
1173 using content::AppCacheInfo; 1236 using content::AppCacheInfo;
1174 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1237 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1175 1238
1176 if (container->appcache_info_.empty()) 1239 if (container->appcache_info_.empty())
1177 return; 1240 return;
1178 1241
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 it != container->flash_lso_domain_list_.end(); ++it) { 1545 it != container->flash_lso_domain_list_.end(); ++it) {
1483 if (filter_utf8.empty() || it->find(filter_utf8) != std::string::npos) { 1546 if (filter_utf8.empty() || it->find(filter_utf8) != std::string::npos) {
1484 // Create a fake origin for GetOrCreateHostNode(). 1547 // Create a fake origin for GetOrCreateHostNode().
1485 GURL origin("http://" + *it); 1548 GURL origin("http://" + *it);
1486 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); 1549 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1487 host_node->GetOrCreateFlashLSONode(*it); 1550 host_node->GetOrCreateFlashLSONode(*it);
1488 } 1551 }
1489 } 1552 }
1490 } 1553 }
1491 1554
1555 void CookiesTreeModel::PopulateMediaLicenseInfoWithFilter(
1556 LocalDataContainer* container,
1557 ScopedBatchUpdateNotifier* notifier,
1558 const base::string16& filter) {
1559 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1560
1561 if (container->media_license_info_list_.empty())
1562 return;
1563
1564 notifier->StartBatchUpdate();
1565 for (MediaLicenseInfoList::iterator media_license_info =
1566 container->media_license_info_list_.begin();
1567 media_license_info != container->media_license_info_list_.end();
1568 ++media_license_info) {
1569 GURL origin(media_license_info->origin);
1570
1571 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin).find(
1572 filter) != base::string16::npos)) {
1573 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1574 CookieTreeMediaLicensesNode* media_license_node =
msramek 2016/09/26 18:28:06 nit: license*s* (this file is full of singular vs
jrummell 2016/09/27 18:21:15 Done.
1575 host_node->GetOrCreateMediaLicensesNode();
1576 media_license_node->AddMediaLicenseNode(
1577 new CookieTreeMediaLicenseNode(media_license_info));
1578 }
1579 }
1580 }
1581
1492 void CookiesTreeModel::SetBatchExpectation(int batches_expected, bool reset) { 1582 void CookiesTreeModel::SetBatchExpectation(int batches_expected, bool reset) {
1493 batches_expected_ = batches_expected; 1583 batches_expected_ = batches_expected;
1494 if (reset) { 1584 if (reset) {
1495 batches_seen_ = 0; 1585 batches_seen_ = 0;
1496 batches_started_ = 0; 1586 batches_started_ = 0;
1497 batches_ended_ = 0; 1587 batches_ended_ = 0;
1498 } else { 1588 } else {
1499 MaybeNotifyBatchesEnded(); 1589 MaybeNotifyBatchesEnded();
1500 } 1590 }
1501 } 1591 }
(...skipping 20 matching lines...) Expand all
1522 // Only notify the observers if this is the outermost call to EndBatch() if 1612 // Only notify the observers if this is the outermost call to EndBatch() if
1523 // called in a nested manner. 1613 // called in a nested manner.
1524 if (batches_ended_ == batches_started_ && 1614 if (batches_ended_ == batches_started_ &&
1525 batches_seen_ == batches_expected_) { 1615 batches_seen_ == batches_expected_) {
1526 FOR_EACH_OBSERVER(Observer, 1616 FOR_EACH_OBSERVER(Observer,
1527 cookies_observer_list_, 1617 cookies_observer_list_,
1528 TreeModelEndBatch(this)); 1618 TreeModelEndBatch(this));
1529 SetBatchExpectation(0, true); 1619 SetBatchExpectation(0, true);
1530 } 1620 }
1531 } 1621 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698