OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 NotifyObserverTreeNodeChanged(root); | 701 NotifyObserverTreeNodeChanged(root); |
702 NotifyObserverEndBatch(); | 702 NotifyObserverEndBatch(); |
703 } | 703 } |
704 | 704 |
705 void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) { | 705 void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) { |
706 if (cookie_node == GetRoot()) | 706 if (cookie_node == GetRoot()) |
707 return; | 707 return; |
708 cookie_node->DeleteStoredObjects(); | 708 cookie_node->DeleteStoredObjects(); |
709 CookieTreeNode* parent_node = cookie_node->parent(); | 709 CookieTreeNode* parent_node = cookie_node->parent(); |
710 delete Remove(parent_node, cookie_node); | 710 delete Remove(parent_node, cookie_node); |
711 if (parent_node->child_count() == 0) | 711 if (parent_node->empty()) |
712 DeleteCookieNode(parent_node); | 712 DeleteCookieNode(parent_node); |
713 } | 713 } |
714 | 714 |
715 void CookiesTreeModel::UpdateSearchResults(const std::wstring& filter) { | 715 void CookiesTreeModel::UpdateSearchResults(const std::wstring& filter) { |
716 CookieTreeNode* root = GetRoot(); | 716 CookieTreeNode* root = GetRoot(); |
717 int num_children = root->child_count(); | 717 int num_children = root->child_count(); |
718 NotifyObserverBeginBatch(); | 718 NotifyObserverBeginBatch(); |
719 for (int i = num_children - 1; i >= 0; --i) | 719 for (int i = num_children - 1; i >= 0; --i) |
720 delete Remove(root, root->GetChild(i)); | 720 delete Remove(root, root->GetChild(i)); |
721 LoadCookiesWithFilter(filter); | 721 LoadCookiesWithFilter(filter); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 | 953 |
954 void CookiesTreeModel::NotifyObserverEndBatch() { | 954 void CookiesTreeModel::NotifyObserverEndBatch() { |
955 // Only notify the observers if this is the outermost call to EndBatch() if | 955 // Only notify the observers if this is the outermost call to EndBatch() if |
956 // called in a nested manner. | 956 // called in a nested manner. |
957 if (--batch_update_ == 0) { | 957 if (--batch_update_ == 0) { |
958 FOR_EACH_OBSERVER(Observer, | 958 FOR_EACH_OBSERVER(Observer, |
959 cookies_observer_list_, | 959 cookies_observer_list_, |
960 TreeModelEndBatch(this)); | 960 TreeModelEndBatch(this)); |
961 } | 961 } |
962 } | 962 } |
OLD | NEW |