OLD | NEW |
---|---|
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 if (next_dot == std::string::npos) { | 110 if (next_dot == std::string::npos) { |
111 retval += host.substr(0, position); | 111 retval += host.substr(0, position); |
112 break; | 112 break; |
113 } | 113 } |
114 retval += host.substr(next_dot + 1, position - (next_dot + 1)); | 114 retval += host.substr(next_dot + 1, position - (next_dot + 1)); |
115 position = next_dot; | 115 position = next_dot; |
116 } | 116 } |
117 return retval; | 117 return retval; |
118 } | 118 } |
119 | 119 |
120 // When creating a cookie tree node from a cookie, strip the port of the | |
121 // cookie source and treat all non-file:// URLs as http://. | |
122 GURL CanonicalizeCookieSource(const net::CanonicalCookie& cookie) { | |
123 GURL url = cookie.Source(); | |
124 if (url.SchemeIsFile()) | |
125 return url; | |
126 | |
127 url::Replacements<char> replacements; | |
128 replacements.ClearPort(); | |
129 if (url.SchemeIsCryptographic()) | |
130 replacements.SetScheme("http", url::Component(0, 4)); | |
131 | |
132 return url.GetOrigin().ReplaceComponents(replacements); | |
133 } | |
134 | |
135 #if defined(ENABLE_EXTENSIONS) | 120 #if defined(ENABLE_EXTENSIONS) |
136 bool TypeIsProtected(CookieTreeNode::DetailedInfo::NodeType type) { | 121 bool TypeIsProtected(CookieTreeNode::DetailedInfo::NodeType type) { |
137 switch (type) { | 122 switch (type) { |
138 // Fall through each below cases to return true. | 123 // Fall through each below cases to return true. |
139 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: | 124 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: |
140 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: | 125 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: |
141 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE: | 126 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE: |
142 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: | 127 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: |
143 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: | 128 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: |
144 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: | 129 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1212 | 1197 |
1213 void CookiesTreeModel::PopulateCookieInfoWithFilter( | 1198 void CookiesTreeModel::PopulateCookieInfoWithFilter( |
1214 LocalDataContainer* container, | 1199 LocalDataContainer* container, |
1215 ScopedBatchUpdateNotifier* notifier, | 1200 ScopedBatchUpdateNotifier* notifier, |
1216 const base::string16& filter) { | 1201 const base::string16& filter) { |
1217 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); | 1202 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
1218 | 1203 |
1219 notifier->StartBatchUpdate(); | 1204 notifier->StartBatchUpdate(); |
1220 for (CookieList::iterator it = container->cookie_list_.begin(); | 1205 for (CookieList::iterator it = container->cookie_list_.begin(); |
1221 it != container->cookie_list_.end(); ++it) { | 1206 it != container->cookie_list_.end(); ++it) { |
1222 GURL source = CanonicalizeCookieSource(*it); | 1207 std::string domain = it->Domain(); |
1223 if (source.is_empty() || !group_by_cookie_source_) { | 1208 if (domain.length() > 1 && domain[0] == '.') |
Mike West
2016/06/29 05:58:42
I think this is the only spot where `group_by_cook
mmenke
2016/06/30 22:03:43
Done.
| |
1224 std::string domain = it->Domain(); | 1209 domain = domain.substr(1); |
1225 if (domain.length() > 1 && domain[0] == '.') | |
1226 domain = domain.substr(1); | |
1227 | 1210 |
1228 // We treat secure cookies just the same as normal ones. | 1211 // Secure cookies are treated just the same as normal ones. |
Mike West
2016/06/29 05:58:42
Since you're touching it anyway, how about "// Coo
mmenke
2016/06/30 22:03:42
Done.
| |
1229 source = GURL(std::string(url::kHttpScheme) + | 1212 GURL source = GURL(std::string(url::kHttpScheme) + |
1230 url::kStandardSchemeSeparator + domain + "/"); | 1213 url::kStandardSchemeSeparator + domain + "/"); |
1231 } | |
1232 if (!source.SchemeIsHTTPOrHTTPS()) | |
Mike West
2016/06/29 05:58:42
1. Oh how I wish we didn't need to support WebView
mmenke
2016/06/29 13:02:26
We're *already* doing that, for cookies loaded fro
| |
1233 continue; | |
1234 | 1214 |
1235 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(source) | 1215 if (filter.empty() || (CookieTreeHostNode::TitleForUrl(source) |
1236 .find(filter) != base::string16::npos)) { | 1216 .find(filter) != base::string16::npos)) { |
1237 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(source); | 1217 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(source); |
1238 CookieTreeCookiesNode* cookies_node = | 1218 CookieTreeCookiesNode* cookies_node = |
1239 host_node->GetOrCreateCookiesNode(); | 1219 host_node->GetOrCreateCookiesNode(); |
1240 CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(it); | 1220 CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(it); |
1241 cookies_node->AddCookieNode(new_cookie); | 1221 cookies_node->AddCookieNode(new_cookie); |
1242 } | 1222 } |
1243 } | 1223 } |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1542 void CookiesTreeModel::MaybeNotifyBatchesEnded() { | 1522 void CookiesTreeModel::MaybeNotifyBatchesEnded() { |
1543 // Only notify the observers if this is the outermost call to EndBatch() if | 1523 // Only notify the observers if this is the outermost call to EndBatch() if |
1544 // called in a nested manner. | 1524 // called in a nested manner. |
1545 if (batches_ended_ == batches_started_ && | 1525 if (batches_ended_ == batches_started_ && |
1546 batches_seen_ == batches_expected_) { | 1526 batches_seen_ == batches_expected_) { |
1547 FOR_EACH_OBSERVER(Observer, | 1527 FOR_EACH_OBSERVER(Observer, |
1548 cookies_observer_list_, | 1528 cookies_observer_list_, |
1549 TreeModelEndBatch(this)); | 1529 TreeModelEndBatch(this)); |
1550 } | 1530 } |
1551 } | 1531 } |
OLD | NEW |