OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cookies_tree_model.h" | 5 #include "chrome/browser/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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 } | 51 } |
52 | 52 |
53 void CookieTreeCookieNode::DeleteStoredObjects() { | 53 void CookieTreeCookieNode::DeleteStoredObjects() { |
54 GetModel()->DeleteCookie(*cookie_); | 54 GetModel()->DeleteCookie(*cookie_); |
55 } | 55 } |
56 | 56 |
57 namespace { | 57 namespace { |
58 // comparison functor, for use in CookieTreeRootNode | 58 // comparison functor, for use in CookieTreeRootNode |
59 class OriginNodeComparator { | 59 class OriginNodeComparator { |
60 public: | 60 public: |
61 bool operator() (const CookieTreeNode* lhs, | 61 bool operator() (const CookieTreeNode* lhs, |
Evan Martin
2009/11/20 18:52:31
May as well make this one static too?
| |
62 const CookieTreeNode* rhs) { | 62 const CookieTreeNode* rhs) { |
63 // We want to order by registry controlled domain, so we would get | 63 // We want to order by registry controlled domain, so we would get |
64 // google.com, ad.google.com, www.google.com, | 64 // google.com, ad.google.com, www.google.com, |
65 // microsoft.com, ad.microsoft.com. CanonicalizeHost transforms the origins | 65 // microsoft.com, ad.microsoft.com. CanonicalizeHost transforms the origins |
66 // into a form like google.com.www so that string comparisons work. | 66 // into a form like google.com.www so that string comparisons work. |
67 return (CanonicalizeHost(lhs->GetTitle()) < | 67 return (CanonicalizeHost(lhs->GetTitle()) < |
68 CanonicalizeHost(rhs->GetTitle())); | 68 CanonicalizeHost(rhs->GetTitle())); |
69 } | 69 } |
70 | 70 |
71 private: | 71 private: |
72 std::string CanonicalizeHost(const std::wstring& host_w) { | 72 static std::string CanonicalizeHost(const std::wstring& host_w) { |
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". |
79 | 79 |
80 std::string host = WideToUTF8(host_w); | 80 std::string host = WideToUTF8(host_w); |
81 std::string retval = net::RegistryControlledDomainService:: | 81 std::string retval = net::RegistryControlledDomainService:: |
82 GetDomainAndRegistry(host); | 82 GetDomainAndRegistry(host); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 NotifyObserverTreeNodeChanged(root); | 270 NotifyObserverTreeNodeChanged(root); |
271 } | 271 } |
272 | 272 |
273 void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) { | 273 void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) { |
274 cookie_node->DeleteStoredObjects(); | 274 cookie_node->DeleteStoredObjects(); |
275 // find the parent and index | 275 // find the parent and index |
276 CookieTreeNode* parent_node = cookie_node->GetParent(); | 276 CookieTreeNode* parent_node = cookie_node->GetParent(); |
277 int cookie_node_index = parent_node->IndexOfChild(cookie_node); | 277 int cookie_node_index = parent_node->IndexOfChild(cookie_node); |
278 delete Remove(parent_node, cookie_node_index); | 278 delete Remove(parent_node, cookie_node_index); |
279 } | 279 } |
OLD | NEW |