| 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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 | 590 |
| 591 /////////////////////////////////////////////////////////////////////////////// | 591 /////////////////////////////////////////////////////////////////////////////// |
| 592 // CookieTreeRootNode, public: | 592 // CookieTreeRootNode, public: |
| 593 | 593 |
| 594 CookieTreeRootNode::CookieTreeRootNode(CookiesTreeModel* model) | 594 CookieTreeRootNode::CookieTreeRootNode(CookiesTreeModel* model) |
| 595 : model_(model) { | 595 : model_(model) { |
| 596 } | 596 } |
| 597 | 597 |
| 598 CookieTreeRootNode::~CookieTreeRootNode() {} | 598 CookieTreeRootNode::~CookieTreeRootNode() {} |
| 599 | 599 |
| 600 CookieTreeHostNode* CookieTreeRootNode::GetOrCreateHostNode( | 600 CookieTreeHostNode* CookieTreeRootNode::GetOrCreateHostNode(const GURL& url) { |
| 601 const GURL& url) { | |
| 602 scoped_ptr<CookieTreeHostNode> host_node( | 601 scoped_ptr<CookieTreeHostNode> host_node( |
| 603 new CookieTreeHostNode(url)); | 602 new CookieTreeHostNode(url)); |
| 604 | 603 |
| 605 // First see if there is an existing match. | 604 // First see if there is an existing match. |
| 606 std::vector<CookieTreeNode*>::iterator host_node_iterator = | 605 std::vector<CookieTreeNode*>::iterator host_node_iterator = |
| 607 std::lower_bound(children().begin(), children().end(), host_node.get(), | 606 std::lower_bound(children().begin(), children().end(), host_node.get(), |
| 608 HostNodeComparator()); | 607 HostNodeComparator()); |
| 609 if (host_node_iterator != children().end() && | 608 if (host_node_iterator != children().end() && |
| 610 CookieTreeHostNode::TitleForUrl(url) == | 609 CookieTreeHostNode::TitleForUrl(url) == |
| 611 (*host_node_iterator)->GetTitle()) | 610 (*host_node_iterator)->GetTitle()) |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 void CookiesTreeModel::PopulateCookieInfoWithFilter( | 1217 void CookiesTreeModel::PopulateCookieInfoWithFilter( |
| 1219 LocalDataContainer* container, | 1218 LocalDataContainer* container, |
| 1220 ScopedBatchUpdateNotifier* notifier, | 1219 ScopedBatchUpdateNotifier* notifier, |
| 1221 const base::string16& filter) { | 1220 const base::string16& filter) { |
| 1222 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); | 1221 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); |
| 1223 | 1222 |
| 1224 notifier->StartBatchUpdate(); | 1223 notifier->StartBatchUpdate(); |
| 1225 for (CookieList::iterator it = container->cookie_list_.begin(); | 1224 for (CookieList::iterator it = container->cookie_list_.begin(); |
| 1226 it != container->cookie_list_.end(); ++it) { | 1225 it != container->cookie_list_.end(); ++it) { |
| 1227 GURL source = CanonicalizeCookieSource(*it); | 1226 GURL source = CanonicalizeCookieSource(*it); |
| 1227 if (!source.SchemeIsHTTPOrHTTPS()) |
| 1228 continue; |
| 1228 if (source.is_empty() || !group_by_cookie_source_) { | 1229 if (source.is_empty() || !group_by_cookie_source_) { |
| 1229 std::string domain = it->Domain(); | 1230 std::string domain = it->Domain(); |
| 1230 if (domain.length() > 1 && domain[0] == '.') | 1231 if (domain.length() > 1 && domain[0] == '.') |
| 1231 domain = domain.substr(1); | 1232 domain = domain.substr(1); |
| 1232 | 1233 |
| 1233 // We treat secure cookies just the same as normal ones. | 1234 // We treat secure cookies just the same as normal ones. |
| 1234 source = GURL(std::string(url::kHttpScheme) + | 1235 source = GURL(std::string(url::kHttpScheme) + |
| 1235 url::kStandardSchemeSeparator + domain + "/"); | 1236 url::kStandardSchemeSeparator + domain + "/"); |
| 1236 } | 1237 } |
| 1237 | 1238 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 void CookiesTreeModel::MaybeNotifyBatchesEnded() { | 1546 void CookiesTreeModel::MaybeNotifyBatchesEnded() { |
| 1546 // Only notify the observers if this is the outermost call to EndBatch() if | 1547 // Only notify the observers if this is the outermost call to EndBatch() if |
| 1547 // called in a nested manner. | 1548 // called in a nested manner. |
| 1548 if (batches_ended_ == batches_started_ && | 1549 if (batches_ended_ == batches_started_ && |
| 1549 batches_seen_ == batches_expected_) { | 1550 batches_seen_ == batches_expected_) { |
| 1550 FOR_EACH_OBSERVER(Observer, | 1551 FOR_EACH_OBSERVER(Observer, |
| 1551 cookies_observer_list_, | 1552 cookies_observer_list_, |
| 1552 TreeModelEndBatch(this)); | 1553 TreeModelEndBatch(this)); |
| 1553 } | 1554 } |
| 1554 } | 1555 } |
| OLD | NEW |