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

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

Issue 2379863002: Fix object ownership in ui/base/models. (Closed)
Patch Set: fix Created 4 years, 2 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>
11 #include <map> 11 #include <map>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/memory/linked_ptr.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" 18 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
19 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" 19 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
20 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" 20 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h"
21 #include "chrome/browser/content_settings/cookie_settings_factory.h" 21 #include "chrome/browser/content_settings/cookie_settings_factory.h"
22 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
23 #include "chrome/grit/theme_resources.h" 23 #include "chrome/grit/theme_resources.h"
24 #include "components/content_settings/core/browser/cookie_settings.h" 24 #include "components/content_settings/core/browser/cookie_settings.h"
25 #include "content/public/common/url_constants.h" 25 #include "content/public/common/url_constants.h"
26 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 26 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
27 #include "net/cookies/canonical_cookie.h" 27 #include "net/cookies/canonical_cookie.h"
28 #include "net/url_request/url_request_context.h" 28 #include "net/url_request/url_request_context.h"
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/gfx/image/image_skia.h" 31 #include "ui/gfx/image/image_skia.h"
32 #include "ui/resources/grit/ui_resources.h" 32 #include "ui/resources/grit/ui_resources.h"
33 33
34 #if defined(ENABLE_EXTENSIONS) 34 #if defined(ENABLE_EXTENSIONS)
35 #include "chrome/browser/extensions/extension_special_storage_policy.h" 35 #include "chrome/browser/extensions/extension_special_storage_policy.h"
36 #include "extensions/common/extension_set.h" 36 #include "extensions/common/extension_set.h"
37 #endif 37 #endif
38 38
39 namespace { 39 namespace {
40 40
41 struct NodeTitleComparator { 41 struct NodeTitleComparator {
42 bool operator()(const CookieTreeNode* lhs, const CookieTreeNode* rhs) { 42 bool operator()(const std::unique_ptr<CookieTreeNode>& lhs,
43 const std::unique_ptr<CookieTreeNode>& rhs) {
43 return lhs->GetTitle() < rhs->GetTitle(); 44 return lhs->GetTitle() < rhs->GetTitle();
44 } 45 }
45 }; 46 };
46 47
47 // Comparison functor, for use in CookieTreeRootNode. 48 // Comparison functor, for use in CookieTreeRootNode.
48 struct HostNodeComparator { 49 struct HostNodeComparator {
49 bool operator()(const CookieTreeNode* lhs, const CookieTreeNode* rhs) { 50 bool operator()(const std::unique_ptr<CookieTreeNode>& lhs,
51 const std::unique_ptr<CookieTreeHostNode>& rhs) {
50 // This comparator is only meant to compare CookieTreeHostNode types. Make 52 // This comparator is only meant to compare CookieTreeHostNode types. Make
51 // sure we check this, as the static cast below is dangerous if we get the 53 // sure we check this, as the static cast below is dangerous if we get the
52 // wrong object type. 54 // wrong object type.
53 CHECK_EQ(CookieTreeNode::DetailedInfo::TYPE_HOST, 55 CHECK_EQ(CookieTreeNode::DetailedInfo::TYPE_HOST,
54 lhs->GetDetailedInfo().node_type); 56 lhs->GetDetailedInfo().node_type);
55 CHECK_EQ(CookieTreeNode::DetailedInfo::TYPE_HOST, 57 CHECK_EQ(CookieTreeNode::DetailedInfo::TYPE_HOST,
56 rhs->GetDetailedInfo().node_type); 58 rhs->GetDetailedInfo().node_type);
57 59
58 const CookieTreeHostNode* ltn = 60 const CookieTreeHostNode* ltn =
59 static_cast<const CookieTreeHostNode*>(lhs); 61 static_cast<const CookieTreeHostNode*>(lhs.get());
60 const CookieTreeHostNode* rtn = 62 const CookieTreeHostNode* rtn = rhs.get();
61 static_cast<const CookieTreeHostNode*>(rhs);
62 63
63 // We want to order by registry controlled domain, so we would get 64 // We want to order by registry controlled domain, so we would get
64 // google.com, ad.google.com, www.google.com, 65 // google.com, ad.google.com, www.google.com,
65 // microsoft.com, ad.microsoft.com. CanonicalizeHost transforms the origins 66 // microsoft.com, ad.microsoft.com. CanonicalizeHost transforms the origins
66 // into a form like google.com.www so that string comparisons work. 67 // into a form like google.com.www so that string comparisons work.
67 return (ltn->canonicalized_host() < 68 return ltn->canonicalized_host() < rtn->canonicalized_host();
68 rtn->canonicalized_host());
69 } 69 }
70 }; 70 };
71 71
72 std::string CanonicalizeHost(const GURL& url) { 72 std::string CanonicalizeHost(const GURL& url) {
73 // The canonicalized representation makes the registry controlled domain 73 // The canonicalized representation makes the registry controlled domain
74 // come first, and then adds subdomains in reverse order, e.g. 74 // come first, and then adds subdomains in reverse order, e.g.
75 // 1.mail.google.com would become google.com.mail.1, and then a standard 75 // 1.mail.google.com would become google.com.mail.1, and then a standard
76 // string comparison works to order hosts by registry controlled domain 76 // string comparison works to order hosts by registry controlled domain
77 // first. Leading dots are ignored, ".google.com" is the same as 77 // first. Leading dots are ignored, ".google.com" is the same as
78 // "google.com". 78 // "google.com".
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 const std::string& flash_lso_domain) { 268 const std::string& flash_lso_domain) {
269 Init(TYPE_FLASH_LSO); 269 Init(TYPE_FLASH_LSO);
270 this->flash_lso_domain = flash_lso_domain; 270 this->flash_lso_domain = flash_lso_domain;
271 return *this; 271 return *this;
272 } 272 }
273 273
274 /////////////////////////////////////////////////////////////////////////////// 274 ///////////////////////////////////////////////////////////////////////////////
275 // CookieTreeNode, public: 275 // CookieTreeNode, public:
276 276
277 void CookieTreeNode::DeleteStoredObjects() { 277 void CookieTreeNode::DeleteStoredObjects() {
278 for (auto* child : children()) 278 for (const auto& child : children())
279 child->DeleteStoredObjects(); 279 child->DeleteStoredObjects();
280 } 280 }
281 281
282 CookiesTreeModel* CookieTreeNode::GetModel() const { 282 CookiesTreeModel* CookieTreeNode::GetModel() const {
283 if (parent()) 283 if (parent())
284 return parent()->GetModel(); 284 return parent()->GetModel();
285 return nullptr; 285 return nullptr;
286 } 286 }
287 287
288 /////////////////////////////////////////////////////////////////////////////// 288 ///////////////////////////////////////////////////////////////////////////////
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 /////////////////////////////////////////////////////////////////////////////// 577 ///////////////////////////////////////////////////////////////////////////////
578 // CookieTreeRootNode, public: 578 // CookieTreeRootNode, public:
579 579
580 CookieTreeRootNode::CookieTreeRootNode(CookiesTreeModel* model) 580 CookieTreeRootNode::CookieTreeRootNode(CookiesTreeModel* model)
581 : model_(model) { 581 : model_(model) {
582 } 582 }
583 583
584 CookieTreeRootNode::~CookieTreeRootNode() {} 584 CookieTreeRootNode::~CookieTreeRootNode() {}
585 585
586 CookieTreeHostNode* CookieTreeRootNode::GetOrCreateHostNode(const GURL& url) { 586 CookieTreeHostNode* CookieTreeRootNode::GetOrCreateHostNode(const GURL& url) {
587 std::unique_ptr<CookieTreeHostNode> host_node(new CookieTreeHostNode(url)); 587 std::unique_ptr<CookieTreeHostNode> host_node =
588 base::MakeUnique<CookieTreeHostNode>(url);
588 589
589 // First see if there is an existing match. 590 // First see if there is an existing match.
590 std::vector<CookieTreeNode*>::iterator host_node_iterator = 591 auto host_node_iterator = std::lower_bound(
591 std::lower_bound(children().begin(), children().end(), host_node.get(), 592 children().begin(), children().end(), host_node, HostNodeComparator());
592 HostNodeComparator());
593 if (host_node_iterator != children().end() && 593 if (host_node_iterator != children().end() &&
594 CookieTreeHostNode::TitleForUrl(url) == 594 CookieTreeHostNode::TitleForUrl(url) ==
595 (*host_node_iterator)->GetTitle()) 595 (*host_node_iterator)->GetTitle())
596 return static_cast<CookieTreeHostNode*>(*host_node_iterator); 596 return static_cast<CookieTreeHostNode*>(host_node_iterator->get());
597 // Node doesn't exist, insert the new one into the (ordered) children. 597 // Node doesn't exist, insert the new one into the (ordered) children.
598 DCHECK(model_); 598 DCHECK(model_);
599 model_->Add(this, host_node.get(), 599 return static_cast<CookieTreeHostNode*>(model_->Add(
600 (host_node_iterator - children().begin())); 600 this, std::move(host_node), (host_node_iterator - children().begin())));
601 return host_node.release();
602 } 601 }
603 602
604 CookiesTreeModel* CookieTreeRootNode::GetModel() const { 603 CookiesTreeModel* CookieTreeRootNode::GetModel() const {
605 return model_; 604 return model_;
606 } 605 }
607 606
608 CookieTreeNode::DetailedInfo CookieTreeRootNode::GetDetailedInfo() const { 607 CookieTreeNode::DetailedInfo CookieTreeRootNode::GetDetailedInfo() const {
609 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); 608 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT);
610 } 609 }
611 610
(...skipping 22 matching lines...) Expand all
634 } 633 }
635 634
636 CookieTreeNode::DetailedInfo CookieTreeHostNode::GetDetailedInfo() const { 635 CookieTreeNode::DetailedInfo CookieTreeHostNode::GetDetailedInfo() const {
637 return DetailedInfo().InitHost(); 636 return DetailedInfo().InitHost();
638 } 637 }
639 638
640 CookieTreeCookiesNode* CookieTreeHostNode::GetOrCreateCookiesNode() { 639 CookieTreeCookiesNode* CookieTreeHostNode::GetOrCreateCookiesNode() {
641 if (cookies_child_) 640 if (cookies_child_)
642 return cookies_child_; 641 return cookies_child_;
643 cookies_child_ = new CookieTreeCookiesNode; 642 cookies_child_ = new CookieTreeCookiesNode;
644 AddChildSortedByTitle(cookies_child_); 643 AddChildSortedByTitle(base::WrapUnique(cookies_child_));
645 return cookies_child_; 644 return cookies_child_;
646 } 645 }
647 646
648 CookieTreeDatabasesNode* CookieTreeHostNode::GetOrCreateDatabasesNode() { 647 CookieTreeDatabasesNode* CookieTreeHostNode::GetOrCreateDatabasesNode() {
649 if (databases_child_) 648 if (databases_child_)
650 return databases_child_; 649 return databases_child_;
651 databases_child_ = new CookieTreeDatabasesNode; 650 databases_child_ = new CookieTreeDatabasesNode;
652 AddChildSortedByTitle(databases_child_); 651 AddChildSortedByTitle(base::WrapUnique(databases_child_));
653 return databases_child_; 652 return databases_child_;
654 } 653 }
655 654
656 CookieTreeLocalStoragesNode* 655 CookieTreeLocalStoragesNode*
657 CookieTreeHostNode::GetOrCreateLocalStoragesNode() { 656 CookieTreeHostNode::GetOrCreateLocalStoragesNode() {
658 if (local_storages_child_) 657 if (local_storages_child_)
659 return local_storages_child_; 658 return local_storages_child_;
660 local_storages_child_ = new CookieTreeLocalStoragesNode; 659 local_storages_child_ = new CookieTreeLocalStoragesNode;
661 AddChildSortedByTitle(local_storages_child_); 660 AddChildSortedByTitle(base::WrapUnique(local_storages_child_));
662 return local_storages_child_; 661 return local_storages_child_;
663 } 662 }
664 663
665 CookieTreeSessionStoragesNode* 664 CookieTreeSessionStoragesNode*
666 CookieTreeHostNode::GetOrCreateSessionStoragesNode() { 665 CookieTreeHostNode::GetOrCreateSessionStoragesNode() {
667 if (session_storages_child_) 666 if (session_storages_child_)
668 return session_storages_child_; 667 return session_storages_child_;
669 session_storages_child_ = new CookieTreeSessionStoragesNode; 668 session_storages_child_ = new CookieTreeSessionStoragesNode;
670 AddChildSortedByTitle(session_storages_child_); 669 AddChildSortedByTitle(base::WrapUnique(session_storages_child_));
671 return session_storages_child_; 670 return session_storages_child_;
672 } 671 }
673 672
674 CookieTreeAppCachesNode* CookieTreeHostNode::GetOrCreateAppCachesNode() { 673 CookieTreeAppCachesNode* CookieTreeHostNode::GetOrCreateAppCachesNode() {
675 if (appcaches_child_) 674 if (appcaches_child_)
676 return appcaches_child_; 675 return appcaches_child_;
677 appcaches_child_ = new CookieTreeAppCachesNode; 676 appcaches_child_ = new CookieTreeAppCachesNode;
678 AddChildSortedByTitle(appcaches_child_); 677 AddChildSortedByTitle(base::WrapUnique(appcaches_child_));
679 return appcaches_child_; 678 return appcaches_child_;
680 } 679 }
681 680
682 CookieTreeIndexedDBsNode* CookieTreeHostNode::GetOrCreateIndexedDBsNode() { 681 CookieTreeIndexedDBsNode* CookieTreeHostNode::GetOrCreateIndexedDBsNode() {
683 if (indexed_dbs_child_) 682 if (indexed_dbs_child_)
684 return indexed_dbs_child_; 683 return indexed_dbs_child_;
685 indexed_dbs_child_ = new CookieTreeIndexedDBsNode; 684 indexed_dbs_child_ = new CookieTreeIndexedDBsNode;
686 AddChildSortedByTitle(indexed_dbs_child_); 685 AddChildSortedByTitle(base::WrapUnique(indexed_dbs_child_));
687 return indexed_dbs_child_; 686 return indexed_dbs_child_;
688 } 687 }
689 688
690 CookieTreeFileSystemsNode* CookieTreeHostNode::GetOrCreateFileSystemsNode() { 689 CookieTreeFileSystemsNode* CookieTreeHostNode::GetOrCreateFileSystemsNode() {
691 if (file_systems_child_) 690 if (file_systems_child_)
692 return file_systems_child_; 691 return file_systems_child_;
693 file_systems_child_ = new CookieTreeFileSystemsNode; 692 file_systems_child_ = new CookieTreeFileSystemsNode;
694 AddChildSortedByTitle(file_systems_child_); 693 AddChildSortedByTitle(base::WrapUnique(file_systems_child_));
695 return file_systems_child_; 694 return file_systems_child_;
696 } 695 }
697 696
698 CookieTreeQuotaNode* CookieTreeHostNode::UpdateOrCreateQuotaNode( 697 CookieTreeQuotaNode* CookieTreeHostNode::UpdateOrCreateQuotaNode(
699 std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info) { 698 std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info) {
700 if (quota_child_) 699 if (quota_child_)
701 return quota_child_; 700 return quota_child_;
702 quota_child_ = new CookieTreeQuotaNode(quota_info); 701 quota_child_ = new CookieTreeQuotaNode(quota_info);
703 AddChildSortedByTitle(quota_child_); 702 AddChildSortedByTitle(base::WrapUnique(quota_child_));
704 return quota_child_; 703 return quota_child_;
705 } 704 }
706 705
707 CookieTreeChannelIDsNode* 706 CookieTreeChannelIDsNode*
708 CookieTreeHostNode::GetOrCreateChannelIDsNode() { 707 CookieTreeHostNode::GetOrCreateChannelIDsNode() {
709 if (channel_ids_child_) 708 if (channel_ids_child_)
710 return channel_ids_child_; 709 return channel_ids_child_;
711 channel_ids_child_ = new CookieTreeChannelIDsNode; 710 channel_ids_child_ = new CookieTreeChannelIDsNode;
712 AddChildSortedByTitle(channel_ids_child_); 711 AddChildSortedByTitle(base::WrapUnique(channel_ids_child_));
713 return channel_ids_child_; 712 return channel_ids_child_;
714 } 713 }
715 714
716 CookieTreeServiceWorkersNode* 715 CookieTreeServiceWorkersNode*
717 CookieTreeHostNode::GetOrCreateServiceWorkersNode() { 716 CookieTreeHostNode::GetOrCreateServiceWorkersNode() {
718 if (service_workers_child_) 717 if (service_workers_child_)
719 return service_workers_child_; 718 return service_workers_child_;
720 service_workers_child_ = new CookieTreeServiceWorkersNode; 719 service_workers_child_ = new CookieTreeServiceWorkersNode;
721 AddChildSortedByTitle(service_workers_child_); 720 AddChildSortedByTitle(base::WrapUnique(service_workers_child_));
722 return service_workers_child_; 721 return service_workers_child_;
723 } 722 }
724 723
725 CookieTreeCacheStoragesNode* 724 CookieTreeCacheStoragesNode*
726 CookieTreeHostNode::GetOrCreateCacheStoragesNode() { 725 CookieTreeHostNode::GetOrCreateCacheStoragesNode() {
727 if (cache_storages_child_) 726 if (cache_storages_child_)
728 return cache_storages_child_; 727 return cache_storages_child_;
729 cache_storages_child_ = new CookieTreeCacheStoragesNode; 728 cache_storages_child_ = new CookieTreeCacheStoragesNode;
730 AddChildSortedByTitle(cache_storages_child_); 729 AddChildSortedByTitle(base::WrapUnique(cache_storages_child_));
731 return cache_storages_child_; 730 return cache_storages_child_;
732 } 731 }
733 732
734 CookieTreeFlashLSONode* CookieTreeHostNode::GetOrCreateFlashLSONode( 733 CookieTreeFlashLSONode* CookieTreeHostNode::GetOrCreateFlashLSONode(
735 const std::string& domain) { 734 const std::string& domain) {
736 DCHECK_EQ(GetHost(), domain); 735 DCHECK_EQ(GetHost(), domain);
737 if (flash_lso_child_) 736 if (flash_lso_child_)
738 return flash_lso_child_; 737 return flash_lso_child_;
739 flash_lso_child_ = new CookieTreeFlashLSONode(domain); 738 flash_lso_child_ = new CookieTreeFlashLSONode(domain);
740 AddChildSortedByTitle(flash_lso_child_); 739 AddChildSortedByTitle(base::WrapUnique(flash_lso_child_));
741 return flash_lso_child_; 740 return flash_lso_child_;
742 } 741 }
743 742
744 void CookieTreeHostNode::CreateContentException( 743 void CookieTreeHostNode::CreateContentException(
745 content_settings::CookieSettings* cookie_settings, 744 content_settings::CookieSettings* cookie_settings,
746 ContentSetting setting) const { 745 ContentSetting setting) const {
747 DCHECK(setting == CONTENT_SETTING_ALLOW || 746 DCHECK(setting == CONTENT_SETTING_ALLOW ||
748 setting == CONTENT_SETTING_BLOCK || 747 setting == CONTENT_SETTING_BLOCK ||
749 setting == CONTENT_SETTING_SESSION_ONLY); 748 setting == CONTENT_SETTING_SESSION_ONLY);
750 if (CanCreateContentException()) { 749 if (CanCreateContentException()) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 l10n_util::GetStringUTF16(IDS_COOKIES_CHANNEL_IDS)) { 861 l10n_util::GetStringUTF16(IDS_COOKIES_CHANNEL_IDS)) {
863 } 862 }
864 863
865 CookieTreeChannelIDsNode::~CookieTreeChannelIDsNode() {} 864 CookieTreeChannelIDsNode::~CookieTreeChannelIDsNode() {}
866 865
867 CookieTreeNode::DetailedInfo 866 CookieTreeNode::DetailedInfo
868 CookieTreeChannelIDsNode::GetDetailedInfo() const { 867 CookieTreeChannelIDsNode::GetDetailedInfo() const {
869 return DetailedInfo().Init(DetailedInfo::TYPE_CHANNEL_IDS); 868 return DetailedInfo().Init(DetailedInfo::TYPE_CHANNEL_IDS);
870 } 869 }
871 870
872 void CookieTreeNode::AddChildSortedByTitle(CookieTreeNode* new_child) { 871 void CookieTreeNode::AddChildSortedByTitle(
872 std::unique_ptr<CookieTreeNode> new_child) {
873 DCHECK(new_child); 873 DCHECK(new_child);
874 std::vector<CookieTreeNode*>::iterator iter = 874 auto iter = std::lower_bound(children().begin(), children().end(), new_child,
875 std::lower_bound(children().begin(), children().end(), new_child, 875 NodeTitleComparator());
876 NodeTitleComparator()); 876 GetModel()->Add(this, std::move(new_child), iter - children().begin());
877 GetModel()->Add(this, new_child, iter - children().begin());
878 } 877 }
879 878
880 /////////////////////////////////////////////////////////////////////////////// 879 ///////////////////////////////////////////////////////////////////////////////
881 // CookieTreeServiceWorkersNode, public: 880 // CookieTreeServiceWorkersNode, public:
882 881
883 CookieTreeServiceWorkersNode::CookieTreeServiceWorkersNode() 882 CookieTreeServiceWorkersNode::CookieTreeServiceWorkersNode()
884 : CookieTreeNode(l10n_util::GetStringUTF16(IDS_COOKIES_SERVICE_WORKERS)) { 883 : CookieTreeNode(l10n_util::GetStringUTF16(IDS_COOKIES_SERVICE_WORKERS)) {
885 } 884 }
886 885
887 CookieTreeServiceWorkersNode::~CookieTreeServiceWorkersNode() { 886 CookieTreeServiceWorkersNode::~CookieTreeServiceWorkersNode() {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 model_->NotifyObserverBeginBatch(); 950 model_->NotifyObserverBeginBatch();
952 batch_in_progress_ = true; 951 batch_in_progress_ = true;
953 } 952 }
954 } 953 }
955 954
956 /////////////////////////////////////////////////////////////////////////////// 955 ///////////////////////////////////////////////////////////////////////////////
957 // CookiesTreeModel, public: 956 // CookiesTreeModel, public:
958 CookiesTreeModel::CookiesTreeModel( 957 CookiesTreeModel::CookiesTreeModel(
959 LocalDataContainer* data_container, 958 LocalDataContainer* data_container,
960 ExtensionSpecialStoragePolicy* special_storage_policy) 959 ExtensionSpecialStoragePolicy* special_storage_policy)
961 : ui::TreeNodeModel<CookieTreeNode>(new CookieTreeRootNode(this)), 960 : ui::TreeNodeModel<CookieTreeNode>(
961 base::MakeUnique<CookieTreeRootNode>(this)),
962 #if defined(ENABLE_EXTENSIONS) 962 #if defined(ENABLE_EXTENSIONS)
963 special_storage_policy_(special_storage_policy), 963 special_storage_policy_(special_storage_policy),
964 #endif 964 #endif
965 data_container_(data_container) { 965 data_container_(data_container) {
966 data_container_->Init(this); 966 data_container_->Init(this);
967 } 967 }
968 968
969 CookiesTreeModel::~CookiesTreeModel() { 969 CookiesTreeModel::~CookiesTreeModel() {
970 } 970 }
971 971
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 default: 1025 default:
1026 break; 1026 break;
1027 } 1027 }
1028 return -1; 1028 return -1;
1029 } 1029 }
1030 1030
1031 void CookiesTreeModel::DeleteAllStoredObjects() { 1031 void CookiesTreeModel::DeleteAllStoredObjects() {
1032 NotifyObserverBeginBatch(); 1032 NotifyObserverBeginBatch();
1033 CookieTreeNode* root = GetRoot(); 1033 CookieTreeNode* root = GetRoot();
1034 root->DeleteStoredObjects(); 1034 root->DeleteStoredObjects();
1035 int num_children = root->child_count(); 1035 root->DeleteAll();
1036 for (int i = num_children - 1; i >= 0; --i)
1037 delete Remove(root, root->GetChild(i));
1038 NotifyObserverTreeNodeChanged(root); 1036 NotifyObserverTreeNodeChanged(root);
1039 NotifyObserverEndBatch(); 1037 NotifyObserverEndBatch();
1040 } 1038 }
1041 1039
1042 void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) { 1040 void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) {
1043 if (cookie_node == GetRoot()) 1041 if (cookie_node == GetRoot())
1044 return; 1042 return;
1045 cookie_node->DeleteStoredObjects(); 1043 cookie_node->DeleteStoredObjects();
1046 CookieTreeNode* parent_node = cookie_node->parent(); 1044 CookieTreeNode* parent_node = cookie_node->parent();
1047 delete Remove(parent_node, cookie_node); 1045 Remove(parent_node, cookie_node);
1048 if (parent_node->empty()) 1046 if (parent_node->empty())
1049 DeleteCookieNode(parent_node); 1047 DeleteCookieNode(parent_node);
1050 } 1048 }
1051 1049
1052 void CookiesTreeModel::UpdateSearchResults(const base::string16& filter) { 1050 void CookiesTreeModel::UpdateSearchResults(const base::string16& filter) {
1053 CookieTreeNode* root = GetRoot(); 1051 CookieTreeNode* root = GetRoot();
1054 SetBatchExpectation(1, true); 1052 SetBatchExpectation(1, true);
1055 ScopedBatchUpdateNotifier notifier(this, root); 1053 ScopedBatchUpdateNotifier notifier(this, root);
1056 int num_children = root->child_count();
1057 notifier.StartBatchUpdate(); 1054 notifier.StartBatchUpdate();
1058 for (int i = num_children - 1; i >= 0; --i) 1055 root->DeleteAll();
1059 delete Remove(root, root->GetChild(i));
1060 1056
1061 PopulateCookieInfoWithFilter(data_container(), &notifier, filter); 1057 PopulateCookieInfoWithFilter(data_container(), &notifier, filter);
1062 PopulateDatabaseInfoWithFilter(data_container(), &notifier, filter); 1058 PopulateDatabaseInfoWithFilter(data_container(), &notifier, filter);
1063 PopulateLocalStorageInfoWithFilter(data_container(), &notifier, filter); 1059 PopulateLocalStorageInfoWithFilter(data_container(), &notifier, filter);
1064 PopulateSessionStorageInfoWithFilter(data_container(), &notifier, filter); 1060 PopulateSessionStorageInfoWithFilter(data_container(), &notifier, filter);
1065 PopulateAppCacheInfoWithFilter(data_container(), &notifier, filter); 1061 PopulateAppCacheInfoWithFilter(data_container(), &notifier, filter);
1066 PopulateIndexedDBInfoWithFilter(data_container(), &notifier, filter); 1062 PopulateIndexedDBInfoWithFilter(data_container(), &notifier, filter);
1067 PopulateFileSystemInfoWithFilter(data_container(), &notifier, filter); 1063 PopulateFileSystemInfoWithFilter(data_container(), &notifier, filter);
1068 PopulateQuotaInfoWithFilter(data_container(), &notifier, filter); 1064 PopulateQuotaInfoWithFilter(data_container(), &notifier, filter);
1069 PopulateChannelIDInfoWithFilter(data_container(), &notifier, filter); 1065 PopulateChannelIDInfoWithFilter(data_container(), &notifier, filter);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 base::string16 host_node_name = base::UTF8ToUTF16(origin.first.host()); 1177 base::string16 host_node_name = base::UTF8ToUTF16(origin.first.host());
1182 if (filter.empty() || 1178 if (filter.empty() ||
1183 (host_node_name.find(filter) != base::string16::npos)) { 1179 (host_node_name.find(filter) != base::string16::npos)) {
1184 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin.first); 1180 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin.first);
1185 CookieTreeAppCachesNode* appcaches_node = 1181 CookieTreeAppCachesNode* appcaches_node =
1186 host_node->GetOrCreateAppCachesNode(); 1182 host_node->GetOrCreateAppCachesNode();
1187 1183
1188 for (std::list<AppCacheInfo>::iterator info = origin.second.begin(); 1184 for (std::list<AppCacheInfo>::iterator info = origin.second.begin();
1189 info != origin.second.end(); ++info) { 1185 info != origin.second.end(); ++info) {
1190 appcaches_node->AddAppCacheNode( 1186 appcaches_node->AddAppCacheNode(
1191 new CookieTreeAppCacheNode(origin.first, info)); 1187 base::MakeUnique<CookieTreeAppCacheNode>(origin.first, info));
1192 } 1188 }
1193 } 1189 }
1194 } 1190 }
1195 } 1191 }
1196 1192
1197 void CookiesTreeModel::PopulateCookieInfoWithFilter( 1193 void CookiesTreeModel::PopulateCookieInfoWithFilter(
1198 LocalDataContainer* container, 1194 LocalDataContainer* container,
1199 ScopedBatchUpdateNotifier* notifier, 1195 ScopedBatchUpdateNotifier* notifier,
1200 const base::string16& filter) { 1196 const base::string16& filter) {
1201 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1197 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1202 1198
1203 notifier->StartBatchUpdate(); 1199 notifier->StartBatchUpdate();
1204 for (CookieList::iterator it = container->cookie_list_.begin(); 1200 for (CookieList::iterator it = container->cookie_list_.begin();
1205 it != container->cookie_list_.end(); ++it) { 1201 it != container->cookie_list_.end(); ++it) {
1206 std::string domain = it->Domain(); 1202 std::string domain = it->Domain();
1207 if (domain.length() > 1 && domain[0] == '.') 1203 if (domain.length() > 1 && domain[0] == '.')
1208 domain = domain.substr(1); 1204 domain = domain.substr(1);
1209 1205
1210 // Cookies ignore schemes, so group all HTTP and HTTPS cookies together. 1206 // Cookies ignore schemes, so group all HTTP and HTTPS cookies together.
1211 GURL source(std::string(url::kHttpScheme) + url::kStandardSchemeSeparator + 1207 GURL source(std::string(url::kHttpScheme) + url::kStandardSchemeSeparator +
1212 domain + "/"); 1208 domain + "/");
1213 1209
1214 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(source) 1210 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(source)
1215 .find(filter) != base::string16::npos)) { 1211 .find(filter) != base::string16::npos)) {
1216 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(source); 1212 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(source);
1217 CookieTreeCookiesNode* cookies_node = 1213 CookieTreeCookiesNode* cookies_node =
1218 host_node->GetOrCreateCookiesNode(); 1214 host_node->GetOrCreateCookiesNode();
1219 CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(it); 1215 cookies_node->AddCookieNode(base::MakeUnique<CookieTreeCookieNode>(it));
1220 cookies_node->AddCookieNode(new_cookie);
1221 } 1216 }
1222 } 1217 }
1223 } 1218 }
1224 1219
1225 void CookiesTreeModel::PopulateDatabaseInfoWithFilter( 1220 void CookiesTreeModel::PopulateDatabaseInfoWithFilter(
1226 LocalDataContainer* container, 1221 LocalDataContainer* container,
1227 ScopedBatchUpdateNotifier* notifier, 1222 ScopedBatchUpdateNotifier* notifier,
1228 const base::string16& filter) { 1223 const base::string16& filter) {
1229 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1224 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1230 1225
1231 if (container->database_info_list_.empty()) 1226 if (container->database_info_list_.empty())
1232 return; 1227 return;
1233 1228
1234 notifier->StartBatchUpdate(); 1229 notifier->StartBatchUpdate();
1235 for (DatabaseInfoList::iterator database_info = 1230 for (DatabaseInfoList::iterator database_info =
1236 container->database_info_list_.begin(); 1231 container->database_info_list_.begin();
1237 database_info != container->database_info_list_.end(); 1232 database_info != container->database_info_list_.end();
1238 ++database_info) { 1233 ++database_info) {
1239 GURL origin(database_info->identifier.ToOrigin()); 1234 GURL origin(database_info->identifier.ToOrigin());
1240 1235
1241 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin) 1236 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin)
1242 .find(filter) != base::string16::npos)) { 1237 .find(filter) != base::string16::npos)) {
1243 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); 1238 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1244 CookieTreeDatabasesNode* databases_node = 1239 CookieTreeDatabasesNode* databases_node =
1245 host_node->GetOrCreateDatabasesNode(); 1240 host_node->GetOrCreateDatabasesNode();
1246 databases_node->AddDatabaseNode( 1241 databases_node->AddDatabaseNode(
1247 new CookieTreeDatabaseNode(database_info)); 1242 base::MakeUnique<CookieTreeDatabaseNode>(database_info));
1248 } 1243 }
1249 } 1244 }
1250 } 1245 }
1251 1246
1252 void CookiesTreeModel::PopulateLocalStorageInfoWithFilter( 1247 void CookiesTreeModel::PopulateLocalStorageInfoWithFilter(
1253 LocalDataContainer* container, 1248 LocalDataContainer* container,
1254 ScopedBatchUpdateNotifier* notifier, 1249 ScopedBatchUpdateNotifier* notifier,
1255 const base::string16& filter) { 1250 const base::string16& filter) {
1256 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1251 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1257 1252
1258 if (container->local_storage_info_list_.empty()) 1253 if (container->local_storage_info_list_.empty())
1259 return; 1254 return;
1260 1255
1261 notifier->StartBatchUpdate(); 1256 notifier->StartBatchUpdate();
1262 for (LocalStorageInfoList::iterator local_storage_info = 1257 for (LocalStorageInfoList::iterator local_storage_info =
1263 container->local_storage_info_list_.begin(); 1258 container->local_storage_info_list_.begin();
1264 local_storage_info != container->local_storage_info_list_.end(); 1259 local_storage_info != container->local_storage_info_list_.end();
1265 ++local_storage_info) { 1260 ++local_storage_info) {
1266 const GURL& origin(local_storage_info->origin_url); 1261 const GURL& origin(local_storage_info->origin_url);
1267 1262
1268 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin) 1263 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin)
1269 .find(filter) != std::string::npos)) { 1264 .find(filter) != std::string::npos)) {
1270 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); 1265 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1271 CookieTreeLocalStoragesNode* local_storages_node = 1266 CookieTreeLocalStoragesNode* local_storages_node =
1272 host_node->GetOrCreateLocalStoragesNode(); 1267 host_node->GetOrCreateLocalStoragesNode();
1273 local_storages_node->AddLocalStorageNode( 1268 local_storages_node->AddLocalStorageNode(
1274 new CookieTreeLocalStorageNode(local_storage_info)); 1269 base::MakeUnique<CookieTreeLocalStorageNode>(local_storage_info));
1275 } 1270 }
1276 } 1271 }
1277 } 1272 }
1278 1273
1279 void CookiesTreeModel::PopulateSessionStorageInfoWithFilter( 1274 void CookiesTreeModel::PopulateSessionStorageInfoWithFilter(
1280 LocalDataContainer* container, 1275 LocalDataContainer* container,
1281 ScopedBatchUpdateNotifier* notifier, 1276 ScopedBatchUpdateNotifier* notifier,
1282 const base::string16& filter) { 1277 const base::string16& filter) {
1283 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1278 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1284 1279
1285 if (container->session_storage_info_list_.empty()) 1280 if (container->session_storage_info_list_.empty())
1286 return; 1281 return;
1287 1282
1288 notifier->StartBatchUpdate(); 1283 notifier->StartBatchUpdate();
1289 for (LocalStorageInfoList::iterator session_storage_info = 1284 for (LocalStorageInfoList::iterator session_storage_info =
1290 container->session_storage_info_list_.begin(); 1285 container->session_storage_info_list_.begin();
1291 session_storage_info != container->session_storage_info_list_.end(); 1286 session_storage_info != container->session_storage_info_list_.end();
1292 ++session_storage_info) { 1287 ++session_storage_info) {
1293 const GURL& origin = session_storage_info->origin_url; 1288 const GURL& origin = session_storage_info->origin_url;
1294 1289
1295 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin) 1290 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin)
1296 .find(filter) != base::string16::npos)) { 1291 .find(filter) != base::string16::npos)) {
1297 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); 1292 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1298 CookieTreeSessionStoragesNode* session_storages_node = 1293 CookieTreeSessionStoragesNode* session_storages_node =
1299 host_node->GetOrCreateSessionStoragesNode(); 1294 host_node->GetOrCreateSessionStoragesNode();
1300 session_storages_node->AddSessionStorageNode( 1295 session_storages_node->AddSessionStorageNode(
1301 new CookieTreeSessionStorageNode(session_storage_info)); 1296 base::MakeUnique<CookieTreeSessionStorageNode>(session_storage_info));
1302 } 1297 }
1303 } 1298 }
1304 } 1299 }
1305 1300
1306 void CookiesTreeModel::PopulateIndexedDBInfoWithFilter( 1301 void CookiesTreeModel::PopulateIndexedDBInfoWithFilter(
1307 LocalDataContainer* container, 1302 LocalDataContainer* container,
1308 ScopedBatchUpdateNotifier* notifier, 1303 ScopedBatchUpdateNotifier* notifier,
1309 const base::string16& filter) { 1304 const base::string16& filter) {
1310 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1305 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1311 1306
1312 if (container->indexed_db_info_list_.empty()) 1307 if (container->indexed_db_info_list_.empty())
1313 return; 1308 return;
1314 1309
1315 notifier->StartBatchUpdate(); 1310 notifier->StartBatchUpdate();
1316 for (IndexedDBInfoList::iterator indexed_db_info = 1311 for (IndexedDBInfoList::iterator indexed_db_info =
1317 container->indexed_db_info_list_.begin(); 1312 container->indexed_db_info_list_.begin();
1318 indexed_db_info != container->indexed_db_info_list_.end(); 1313 indexed_db_info != container->indexed_db_info_list_.end();
1319 ++indexed_db_info) { 1314 ++indexed_db_info) {
1320 const GURL& origin = indexed_db_info->origin; 1315 const GURL& origin = indexed_db_info->origin;
1321 1316
1322 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin) 1317 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin)
1323 .find(filter) != base::string16::npos)) { 1318 .find(filter) != base::string16::npos)) {
1324 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); 1319 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1325 CookieTreeIndexedDBsNode* indexed_dbs_node = 1320 CookieTreeIndexedDBsNode* indexed_dbs_node =
1326 host_node->GetOrCreateIndexedDBsNode(); 1321 host_node->GetOrCreateIndexedDBsNode();
1327 indexed_dbs_node->AddIndexedDBNode( 1322 indexed_dbs_node->AddIndexedDBNode(
1328 new CookieTreeIndexedDBNode(indexed_db_info)); 1323 base::MakeUnique<CookieTreeIndexedDBNode>(indexed_db_info));
1329 } 1324 }
1330 } 1325 }
1331 } 1326 }
1332 1327
1333 void CookiesTreeModel::PopulateChannelIDInfoWithFilter( 1328 void CookiesTreeModel::PopulateChannelIDInfoWithFilter(
1334 LocalDataContainer* container, 1329 LocalDataContainer* container,
1335 ScopedBatchUpdateNotifier* notifier, 1330 ScopedBatchUpdateNotifier* notifier,
1336 const base::string16& filter) { 1331 const base::string16& filter) {
1337 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1332 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1338 1333
(...skipping 12 matching lines...) Expand all
1351 origin = GURL(std::string(url::kHttpsScheme) + 1346 origin = GURL(std::string(url::kHttpsScheme) +
1352 url::kStandardSchemeSeparator + 1347 url::kStandardSchemeSeparator +
1353 channel_id_info->server_identifier() + "/"); 1348 channel_id_info->server_identifier() + "/");
1354 } 1349 }
1355 base::string16 title = CookieTreeHostNode::TitleForUrl(origin); 1350 base::string16 title = CookieTreeHostNode::TitleForUrl(origin);
1356 if (filter.empty() || title.find(filter) != base::string16::npos) { 1351 if (filter.empty() || title.find(filter) != base::string16::npos) {
1357 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); 1352 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1358 CookieTreeChannelIDsNode* channel_ids_node = 1353 CookieTreeChannelIDsNode* channel_ids_node =
1359 host_node->GetOrCreateChannelIDsNode(); 1354 host_node->GetOrCreateChannelIDsNode();
1360 channel_ids_node->AddChannelIDNode( 1355 channel_ids_node->AddChannelIDNode(
1361 new CookieTreeChannelIDNode(channel_id_info)); 1356 base::MakeUnique<CookieTreeChannelIDNode>(channel_id_info));
1362 } 1357 }
1363 } 1358 }
1364 } 1359 }
1365 1360
1366 void CookiesTreeModel::PopulateServiceWorkerUsageInfoWithFilter( 1361 void CookiesTreeModel::PopulateServiceWorkerUsageInfoWithFilter(
1367 LocalDataContainer* container, 1362 LocalDataContainer* container,
1368 ScopedBatchUpdateNotifier* notifier, 1363 ScopedBatchUpdateNotifier* notifier,
1369 const base::string16& filter) { 1364 const base::string16& filter) {
1370 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1365 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1371 1366
1372 if (container->service_worker_info_list_.empty()) 1367 if (container->service_worker_info_list_.empty())
1373 return; 1368 return;
1374 1369
1375 notifier->StartBatchUpdate(); 1370 notifier->StartBatchUpdate();
1376 for (ServiceWorkerUsageInfoList::iterator service_worker_info = 1371 for (ServiceWorkerUsageInfoList::iterator service_worker_info =
1377 container->service_worker_info_list_.begin(); 1372 container->service_worker_info_list_.begin();
1378 service_worker_info != container->service_worker_info_list_.end(); 1373 service_worker_info != container->service_worker_info_list_.end();
1379 ++service_worker_info) { 1374 ++service_worker_info) {
1380 const GURL& origin = service_worker_info->origin; 1375 const GURL& origin = service_worker_info->origin;
1381 1376
1382 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin) 1377 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin)
1383 .find(filter) != base::string16::npos)) { 1378 .find(filter) != base::string16::npos)) {
1384 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); 1379 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1385 CookieTreeServiceWorkersNode* service_workers_node = 1380 CookieTreeServiceWorkersNode* service_workers_node =
1386 host_node->GetOrCreateServiceWorkersNode(); 1381 host_node->GetOrCreateServiceWorkersNode();
1387 service_workers_node->AddServiceWorkerNode( 1382 service_workers_node->AddServiceWorkerNode(
1388 new CookieTreeServiceWorkerNode(service_worker_info)); 1383 base::MakeUnique<CookieTreeServiceWorkerNode>(service_worker_info));
1389 } 1384 }
1390 } 1385 }
1391 } 1386 }
1392 1387
1393 void CookiesTreeModel::PopulateCacheStorageUsageInfoWithFilter( 1388 void CookiesTreeModel::PopulateCacheStorageUsageInfoWithFilter(
1394 LocalDataContainer* container, 1389 LocalDataContainer* container,
1395 ScopedBatchUpdateNotifier* notifier, 1390 ScopedBatchUpdateNotifier* notifier,
1396 const base::string16& filter) { 1391 const base::string16& filter) {
1397 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1392 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1398 1393
1399 if (container->cache_storage_info_list_.empty()) 1394 if (container->cache_storage_info_list_.empty())
1400 return; 1395 return;
1401 1396
1402 notifier->StartBatchUpdate(); 1397 notifier->StartBatchUpdate();
1403 for (CacheStorageUsageInfoList::iterator cache_storage_info = 1398 for (CacheStorageUsageInfoList::iterator cache_storage_info =
1404 container->cache_storage_info_list_.begin(); 1399 container->cache_storage_info_list_.begin();
1405 cache_storage_info != container->cache_storage_info_list_.end(); 1400 cache_storage_info != container->cache_storage_info_list_.end();
1406 ++cache_storage_info) { 1401 ++cache_storage_info) {
1407 const GURL& origin = cache_storage_info->origin; 1402 const GURL& origin = cache_storage_info->origin;
1408 1403
1409 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin) 1404 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin)
1410 .find(filter) != base::string16::npos)) { 1405 .find(filter) != base::string16::npos)) {
1411 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); 1406 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1412 CookieTreeCacheStoragesNode* cache_storages_node = 1407 CookieTreeCacheStoragesNode* cache_storages_node =
1413 host_node->GetOrCreateCacheStoragesNode(); 1408 host_node->GetOrCreateCacheStoragesNode();
1414 cache_storages_node->AddCacheStorageNode( 1409 cache_storages_node->AddCacheStorageNode(
1415 new CookieTreeCacheStorageNode(cache_storage_info)); 1410 base::MakeUnique<CookieTreeCacheStorageNode>(cache_storage_info));
1416 } 1411 }
1417 } 1412 }
1418 } 1413 }
1419 1414
1420 void CookiesTreeModel::PopulateFileSystemInfoWithFilter( 1415 void CookiesTreeModel::PopulateFileSystemInfoWithFilter(
1421 LocalDataContainer* container, 1416 LocalDataContainer* container,
1422 ScopedBatchUpdateNotifier* notifier, 1417 ScopedBatchUpdateNotifier* notifier,
1423 const base::string16& filter) { 1418 const base::string16& filter) {
1424 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1419 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1425 1420
1426 if (container->file_system_info_list_.empty()) 1421 if (container->file_system_info_list_.empty())
1427 return; 1422 return;
1428 1423
1429 notifier->StartBatchUpdate(); 1424 notifier->StartBatchUpdate();
1430 for (FileSystemInfoList::iterator file_system_info = 1425 for (FileSystemInfoList::iterator file_system_info =
1431 container->file_system_info_list_.begin(); 1426 container->file_system_info_list_.begin();
1432 file_system_info != container->file_system_info_list_.end(); 1427 file_system_info != container->file_system_info_list_.end();
1433 ++file_system_info) { 1428 ++file_system_info) {
1434 GURL origin(file_system_info->origin); 1429 GURL origin(file_system_info->origin);
1435 1430
1436 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin) 1431 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(origin)
1437 .find(filter) != base::string16::npos)) { 1432 .find(filter) != base::string16::npos)) {
1438 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); 1433 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin);
1439 CookieTreeFileSystemsNode* file_systems_node = 1434 CookieTreeFileSystemsNode* file_systems_node =
1440 host_node->GetOrCreateFileSystemsNode(); 1435 host_node->GetOrCreateFileSystemsNode();
1441 file_systems_node->AddFileSystemNode( 1436 file_systems_node->AddFileSystemNode(
1442 new CookieTreeFileSystemNode(file_system_info)); 1437 base::MakeUnique<CookieTreeFileSystemNode>(file_system_info));
1443 } 1438 }
1444 } 1439 }
1445 } 1440 }
1446 1441
1447 void CookiesTreeModel::PopulateQuotaInfoWithFilter( 1442 void CookiesTreeModel::PopulateQuotaInfoWithFilter(
1448 LocalDataContainer* container, 1443 LocalDataContainer* container,
1449 ScopedBatchUpdateNotifier* notifier, 1444 ScopedBatchUpdateNotifier* notifier,
1450 const base::string16& filter) { 1445 const base::string16& filter) {
1451 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1446 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1452 1447
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 // Only notify the observers if this is the outermost call to EndBatch() if 1517 // Only notify the observers if this is the outermost call to EndBatch() if
1523 // called in a nested manner. 1518 // called in a nested manner.
1524 if (batches_ended_ == batches_started_ && 1519 if (batches_ended_ == batches_started_ &&
1525 batches_seen_ == batches_expected_) { 1520 batches_seen_ == batches_expected_) {
1526 FOR_EACH_OBSERVER(Observer, 1521 FOR_EACH_OBSERVER(Observer,
1527 cookies_observer_list_, 1522 cookies_observer_list_,
1528 TreeModelEndBatch(this)); 1523 TreeModelEndBatch(this));
1529 SetBatchExpectation(0, true); 1524 SetBatchExpectation(0, true);
1530 } 1525 }
1531 } 1526 }
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