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

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

Issue 428323002: ifdef remaining extensions code in chrome/browser/browsing_data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang again Created 6 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 | Annotate | Revision Log
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 <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/memory/linked_ptr.h" 12 #include "base/memory/linked_ptr.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" 15 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
16 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" 16 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
17 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" 17 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h"
18 #include "chrome/browser/content_settings/cookie_settings.h" 18 #include "chrome/browser/content_settings/cookie_settings.h"
19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/extension_special_storage_policy.h"
21 #include "content/public/common/url_constants.h" 19 #include "content/public/common/url_constants.h"
22 #include "extensions/common/extension_set.h"
23 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
24 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
25 #include "grit/ui_resources.h" 22 #include "grit/ui_resources.h"
26 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 23 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
27 #include "net/cookies/canonical_cookie.h" 24 #include "net/cookies/canonical_cookie.h"
28 #include "net/url_request/url_request_context.h" 25 #include "net/url_request/url_request_context.h"
29 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/gfx/image/image_skia.h" 28 #include "ui/gfx/image/image_skia.h"
32 29
30 #if defined(ENABLE_EXTENSIONS)
31 #include "chrome/browser/extensions/extension_special_storage_policy.h"
32 #include "extensions/common/extension_set.h"
33 #endif
34
33 namespace { 35 namespace {
34 36
35 struct NodeTitleComparator { 37 struct NodeTitleComparator {
36 bool operator()(const CookieTreeNode* lhs, const CookieTreeNode* rhs) { 38 bool operator()(const CookieTreeNode* lhs, const CookieTreeNode* rhs) {
37 return lhs->GetTitle() < rhs->GetTitle(); 39 return lhs->GetTitle() < rhs->GetTitle();
38 } 40 }
39 }; 41 };
40 42
41 // Comparison functor, for use in CookieTreeRootNode. 43 // Comparison functor, for use in CookieTreeRootNode.
42 struct HostNodeComparator { 44 struct HostNodeComparator {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (next_dot == std::string::npos) { 106 if (next_dot == std::string::npos) {
105 retval += host.substr(0, position); 107 retval += host.substr(0, position);
106 break; 108 break;
107 } 109 }
108 retval += host.substr(next_dot + 1, position - (next_dot + 1)); 110 retval += host.substr(next_dot + 1, position - (next_dot + 1));
109 position = next_dot; 111 position = next_dot;
110 } 112 }
111 return retval; 113 return retval;
112 } 114 }
113 115
116 #if defined(ENABLE_EXTENSIONS)
114 bool TypeIsProtected(CookieTreeNode::DetailedInfo::NodeType type) { 117 bool TypeIsProtected(CookieTreeNode::DetailedInfo::NodeType type) {
115 switch (type) { 118 switch (type) {
116 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: 119 case CookieTreeNode::DetailedInfo::TYPE_COOKIE:
117 return false; 120 return false;
118 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: 121 case CookieTreeNode::DetailedInfo::TYPE_DATABASE:
119 return true; 122 return true;
120 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: 123 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE:
121 return true; 124 return true;
122 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE: 125 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE:
123 return true; 126 return true;
124 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: 127 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE:
125 return true; 128 return true;
126 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: 129 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB:
127 return true; 130 return true;
128 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: 131 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM:
129 return true; 132 return true;
130 case CookieTreeNode::DetailedInfo::TYPE_QUOTA: 133 case CookieTreeNode::DetailedInfo::TYPE_QUOTA:
131 return false; 134 return false;
132 case CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID: 135 case CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID:
133 return false; 136 return false;
134 case CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO: 137 case CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO:
135 return false; 138 return false;
136 default: 139 default:
137 break; 140 break;
138 } 141 }
139 return false; 142 return false;
140 } 143 }
144 #endif
141 145
142 // This function returns the local data container associated with a leaf tree 146 // This function returns the local data container associated with a leaf tree
143 // node. The app node is assumed to be 3 levels above the leaf because of the 147 // node. The app node is assumed to be 3 levels above the leaf because of the
144 // following structure: 148 // following structure:
145 // root -> origin -> storage type -> leaf node 149 // root -> origin -> storage type -> leaf node
146 LocalDataContainer* GetLocalDataContainerForNode(CookieTreeNode* node) { 150 LocalDataContainer* GetLocalDataContainerForNode(CookieTreeNode* node) {
147 CookieTreeHostNode* host = static_cast<CookieTreeHostNode*>( 151 CookieTreeHostNode* host = static_cast<CookieTreeHostNode*>(
148 node->parent()->parent()); 152 node->parent()->parent());
149 CHECK_EQ(host->GetDetailedInfo().node_type, 153 CHECK_EQ(host->GetDetailedInfo().node_type,
150 CookieTreeNode::DetailedInfo::TYPE_HOST); 154 CookieTreeNode::DetailedInfo::TYPE_HOST);
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 } 864 }
861 865
862 /////////////////////////////////////////////////////////////////////////////// 866 ///////////////////////////////////////////////////////////////////////////////
863 // CookiesTreeModel, public: 867 // CookiesTreeModel, public:
864 CookiesTreeModel::CookiesTreeModel( 868 CookiesTreeModel::CookiesTreeModel(
865 LocalDataContainer* data_container, 869 LocalDataContainer* data_container,
866 ExtensionSpecialStoragePolicy* special_storage_policy, 870 ExtensionSpecialStoragePolicy* special_storage_policy,
867 bool group_by_cookie_source) 871 bool group_by_cookie_source)
868 : ui::TreeNodeModel<CookieTreeNode>(new CookieTreeRootNode(this)), 872 : ui::TreeNodeModel<CookieTreeNode>(new CookieTreeRootNode(this)),
869 data_container_(data_container), 873 data_container_(data_container),
874 #if defined(ENABLE_EXTENSIONS)
870 special_storage_policy_(special_storage_policy), 875 special_storage_policy_(special_storage_policy),
876 #endif
871 group_by_cookie_source_(group_by_cookie_source), 877 group_by_cookie_source_(group_by_cookie_source),
872 batch_update_(0) { 878 batch_update_(0) {
873 data_container_->Init(this); 879 data_container_->Init(this);
874 } 880 }
875 881
876 CookiesTreeModel::~CookiesTreeModel() { 882 CookiesTreeModel::~CookiesTreeModel() {
877 } 883 }
878 884
879 /////////////////////////////////////////////////////////////////////////////// 885 ///////////////////////////////////////////////////////////////////////////////
880 // CookiesTreeModel, TreeModel methods (public): 886 // CookiesTreeModel, TreeModel methods (public):
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 PopulateDatabaseInfoWithFilter(data_container(), &notifier, filter); 962 PopulateDatabaseInfoWithFilter(data_container(), &notifier, filter);
957 PopulateLocalStorageInfoWithFilter(data_container(), &notifier, filter); 963 PopulateLocalStorageInfoWithFilter(data_container(), &notifier, filter);
958 PopulateSessionStorageInfoWithFilter(data_container(), &notifier, filter); 964 PopulateSessionStorageInfoWithFilter(data_container(), &notifier, filter);
959 PopulateAppCacheInfoWithFilter(data_container(), &notifier, filter); 965 PopulateAppCacheInfoWithFilter(data_container(), &notifier, filter);
960 PopulateIndexedDBInfoWithFilter(data_container(), &notifier, filter); 966 PopulateIndexedDBInfoWithFilter(data_container(), &notifier, filter);
961 PopulateFileSystemInfoWithFilter(data_container(), &notifier, filter); 967 PopulateFileSystemInfoWithFilter(data_container(), &notifier, filter);
962 PopulateQuotaInfoWithFilter(data_container(), &notifier, filter); 968 PopulateQuotaInfoWithFilter(data_container(), &notifier, filter);
963 PopulateChannelIDInfoWithFilter(data_container(), &notifier, filter); 969 PopulateChannelIDInfoWithFilter(data_container(), &notifier, filter);
964 } 970 }
965 971
972 #if defined(ENABLE_EXTENSIONS)
966 const extensions::ExtensionSet* CookiesTreeModel::ExtensionsProtectingNode( 973 const extensions::ExtensionSet* CookiesTreeModel::ExtensionsProtectingNode(
967 const CookieTreeNode& cookie_node) { 974 const CookieTreeNode& cookie_node) {
968 if (!special_storage_policy_.get()) 975 if (!special_storage_policy_)
969 return NULL; 976 return NULL;
970 977
971 CookieTreeNode::DetailedInfo info = cookie_node.GetDetailedInfo(); 978 CookieTreeNode::DetailedInfo info = cookie_node.GetDetailedInfo();
972 979
973 if (!TypeIsProtected(info.node_type)) 980 if (!TypeIsProtected(info.node_type))
974 return NULL; 981 return NULL;
975 982
976 DCHECK(!info.origin.is_empty()); 983 DCHECK(!info.origin.is_empty());
977 return special_storage_policy_->ExtensionsProtectingOrigin(info.origin); 984 return special_storage_policy_->ExtensionsProtectingOrigin(info.origin);
978 } 985 }
986 #endif
979 987
980 void CookiesTreeModel::AddCookiesTreeObserver(Observer* observer) { 988 void CookiesTreeModel::AddCookiesTreeObserver(Observer* observer) {
981 cookies_observer_list_.AddObserver(observer); 989 cookies_observer_list_.AddObserver(observer);
982 // Call super so that TreeNodeModel can notify, too. 990 // Call super so that TreeNodeModel can notify, too.
983 ui::TreeNodeModel<CookieTreeNode>::AddObserver(observer); 991 ui::TreeNodeModel<CookieTreeNode>::AddObserver(observer);
984 } 992 }
985 993
986 void CookiesTreeModel::RemoveCookiesTreeObserver(Observer* observer) { 994 void CookiesTreeModel::RemoveCookiesTreeObserver(Observer* observer) {
987 cookies_observer_list_.RemoveObserver(observer); 995 cookies_observer_list_.RemoveObserver(observer);
988 // Call super so that TreeNodeModel doesn't have dead pointers. 996 // Call super so that TreeNodeModel doesn't have dead pointers.
(...skipping 19 matching lines...) Expand all
1008 ScopedBatchUpdateNotifier notifier(this, GetRoot()); 1016 ScopedBatchUpdateNotifier notifier(this, GetRoot());
1009 PopulateLocalStorageInfoWithFilter(container, &notifier, base::string16()); 1017 PopulateLocalStorageInfoWithFilter(container, &notifier, base::string16());
1010 } 1018 }
1011 1019
1012 void CookiesTreeModel::PopulateSessionStorageInfo( 1020 void CookiesTreeModel::PopulateSessionStorageInfo(
1013 LocalDataContainer* container) { 1021 LocalDataContainer* container) {
1014 ScopedBatchUpdateNotifier notifier(this, GetRoot()); 1022 ScopedBatchUpdateNotifier notifier(this, GetRoot());
1015 PopulateSessionStorageInfoWithFilter(container, &notifier, base::string16()); 1023 PopulateSessionStorageInfoWithFilter(container, &notifier, base::string16());
1016 } 1024 }
1017 1025
1018 void CookiesTreeModel::PopulateIndexedDBInfo(LocalDataContainer* container){ 1026 void CookiesTreeModel::PopulateIndexedDBInfo(LocalDataContainer* container) {
1019 ScopedBatchUpdateNotifier notifier(this, GetRoot()); 1027 ScopedBatchUpdateNotifier notifier(this, GetRoot());
1020 PopulateIndexedDBInfoWithFilter(container, &notifier, base::string16()); 1028 PopulateIndexedDBInfoWithFilter(container, &notifier, base::string16());
1021 } 1029 }
1022 1030
1023 void CookiesTreeModel::PopulateFileSystemInfo(LocalDataContainer* container) { 1031 void CookiesTreeModel::PopulateFileSystemInfo(LocalDataContainer* container) {
1024 ScopedBatchUpdateNotifier notifier(this, GetRoot()); 1032 ScopedBatchUpdateNotifier notifier(this, GetRoot());
1025 PopulateFileSystemInfoWithFilter(container, &notifier, base::string16()); 1033 PopulateFileSystemInfoWithFilter(container, &notifier, base::string16());
1026 } 1034 }
1027 1035
1028 void CookiesTreeModel::PopulateQuotaInfo(LocalDataContainer* container) { 1036 void CookiesTreeModel::PopulateQuotaInfo(LocalDataContainer* container) {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 1343
1336 void CookiesTreeModel::NotifyObserverEndBatch() { 1344 void CookiesTreeModel::NotifyObserverEndBatch() {
1337 // Only notify the observers if this is the outermost call to EndBatch() if 1345 // Only notify the observers if this is the outermost call to EndBatch() if
1338 // called in a nested manner. 1346 // called in a nested manner.
1339 if (--batch_update_ == 0) { 1347 if (--batch_update_ == 0) {
1340 FOR_EACH_OBSERVER(Observer, 1348 FOR_EACH_OBSERVER(Observer,
1341 cookies_observer_list_, 1349 cookies_observer_list_,
1342 TreeModelEndBatch(this)); 1350 TreeModelEndBatch(this));
1343 } 1351 }
1344 } 1352 }
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