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 <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "extensions/common/extension_set.h" | 22 #include "extensions/common/extension_set.h" |
23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
24 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
25 #include "grit/ui_resources.h" | 25 #include "grit/ui_resources.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 "url/url_constants.h" |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 struct NodeTitleComparator { | 36 struct NodeTitleComparator { |
36 bool operator()(const CookieTreeNode* lhs, const CookieTreeNode* rhs) { | 37 bool operator()(const CookieTreeNode* lhs, const CookieTreeNode* rhs) { |
37 return lhs->GetTitle() < rhs->GetTitle(); | 38 return lhs->GetTitle() < rhs->GetTitle(); |
38 } | 39 } |
39 }; | 40 }; |
40 | 41 |
41 // Comparison functor, for use in CookieTreeRootNode. | 42 // Comparison functor, for use in CookieTreeRootNode. |
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 notifier->StartBatchUpdate(); | 1082 notifier->StartBatchUpdate(); |
1082 for (CookieList::iterator it = container->cookie_list_.begin(); | 1083 for (CookieList::iterator it = container->cookie_list_.begin(); |
1083 it != container->cookie_list_.end(); ++it) { | 1084 it != container->cookie_list_.end(); ++it) { |
1084 std::string source_string = it->Source(); | 1085 std::string source_string = it->Source(); |
1085 if (source_string.empty() || !group_by_cookie_source_) { | 1086 if (source_string.empty() || !group_by_cookie_source_) { |
1086 std::string domain = it->Domain(); | 1087 std::string domain = it->Domain(); |
1087 if (domain.length() > 1 && domain[0] == '.') | 1088 if (domain.length() > 1 && domain[0] == '.') |
1088 domain = domain.substr(1); | 1089 domain = domain.substr(1); |
1089 | 1090 |
1090 // We treat secure cookies just the same as normal ones. | 1091 // We treat secure cookies just the same as normal ones. |
1091 source_string = std::string(content::kHttpScheme) + | 1092 source_string = std::string(url::kHttpScheme) + |
1092 content::kStandardSchemeSeparator + domain + "/"; | 1093 content::kStandardSchemeSeparator + domain + "/"; |
1093 } | 1094 } |
1094 | 1095 |
1095 GURL source(source_string); | 1096 GURL source(source_string); |
1096 if (!filter.size() || | 1097 if (!filter.size() || |
1097 (CookieTreeHostNode::TitleForUrl(source).find(filter) != | 1098 (CookieTreeHostNode::TitleForUrl(source).find(filter) != |
1098 base::string16::npos)) { | 1099 base::string16::npos)) { |
1099 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(source); | 1100 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(source); |
1100 CookieTreeCookiesNode* cookies_node = | 1101 CookieTreeCookiesNode* cookies_node = |
1101 host_node->GetOrCreateCookiesNode(); | 1102 host_node->GetOrCreateCookiesNode(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 | 1229 |
1229 notifier->StartBatchUpdate(); | 1230 notifier->StartBatchUpdate(); |
1230 for (ServerBoundCertList::iterator cert_info = | 1231 for (ServerBoundCertList::iterator cert_info = |
1231 container->server_bound_cert_list_.begin(); | 1232 container->server_bound_cert_list_.begin(); |
1232 cert_info != container->server_bound_cert_list_.end(); | 1233 cert_info != container->server_bound_cert_list_.end(); |
1233 ++cert_info) { | 1234 ++cert_info) { |
1234 GURL origin(cert_info->server_identifier()); | 1235 GURL origin(cert_info->server_identifier()); |
1235 if (!origin.is_valid()) { | 1236 if (!origin.is_valid()) { |
1236 // Domain Bound Cert. Make a valid URL to satisfy the | 1237 // Domain Bound Cert. Make a valid URL to satisfy the |
1237 // CookieTreeRootNode::GetOrCreateHostNode interface. | 1238 // CookieTreeRootNode::GetOrCreateHostNode interface. |
1238 origin = GURL(std::string(content::kHttpsScheme) + | 1239 origin = GURL(std::string(url::kHttpsScheme) + |
1239 content::kStandardSchemeSeparator + | 1240 content::kStandardSchemeSeparator + |
1240 cert_info->server_identifier() + "/"); | 1241 cert_info->server_identifier() + "/"); |
1241 } | 1242 } |
1242 base::string16 title = CookieTreeHostNode::TitleForUrl(origin); | 1243 base::string16 title = CookieTreeHostNode::TitleForUrl(origin); |
1243 if (!filter.size() || title.find(filter) != base::string16::npos) { | 1244 if (!filter.size() || title.find(filter) != base::string16::npos) { |
1244 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); | 1245 CookieTreeHostNode* host_node = root->GetOrCreateHostNode(origin); |
1245 CookieTreeServerBoundCertsNode* server_bound_certs_node = | 1246 CookieTreeServerBoundCertsNode* server_bound_certs_node = |
1246 host_node->GetOrCreateServerBoundCertsNode(); | 1247 host_node->GetOrCreateServerBoundCertsNode(); |
1247 server_bound_certs_node->AddServerBoundCertNode( | 1248 server_bound_certs_node->AddServerBoundCertNode( |
1248 new CookieTreeServerBoundCertNode(cert_info)); | 1249 new CookieTreeServerBoundCertNode(cert_info)); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 | 1336 |
1336 void CookiesTreeModel::NotifyObserverEndBatch() { | 1337 void CookiesTreeModel::NotifyObserverEndBatch() { |
1337 // Only notify the observers if this is the outermost call to EndBatch() if | 1338 // Only notify the observers if this is the outermost call to EndBatch() if |
1338 // called in a nested manner. | 1339 // called in a nested manner. |
1339 if (--batch_update_ == 0) { | 1340 if (--batch_update_ == 0) { |
1340 FOR_EACH_OBSERVER(Observer, | 1341 FOR_EACH_OBSERVER(Observer, |
1341 cookies_observer_list_, | 1342 cookies_observer_list_, |
1342 TreeModelEndBatch(this)); | 1343 TreeModelEndBatch(this)); |
1343 } | 1344 } |
1344 } | 1345 } |
OLD | NEW |