summaryrefslogtreecommitdiffstats
path: root/app/tree_node_model.h
diff options
context:
space:
mode:
authorian@chromium.org <ian@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 18:44:48 +0000
committerian@chromium.org <ian@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 18:44:48 +0000
commit0457c6bb559c2cebf47235388f0441be51817d60 (patch)
treec0cabb4c18a45d1f5d48df8bb19e6442ad95b357 /app/tree_node_model.h
parente06131db8c610bca50a025fc876755d0aa42e53c (diff)
downloadchromium_src-0457c6bb559c2cebf47235388f0441be51817d60.zip
chromium_src-0457c6bb559c2cebf47235388f0441be51817d60.tar.gz
chromium_src-0457c6bb559c2cebf47235388f0441be51817d60.tar.bz2
Fixes a bug where if there are only localstorage nodes, but nocookies nodes, the Remove and Remove All buttons are disabled.BUG=34886
TEST=clear all cookies, go to www.ianfette.com/localstorage.html and open cookies dialog, check that remove button is enabled. Review URL: http://codereview.chromium.org/596002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38640 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/tree_node_model.h')
-rw-r--r--app/tree_node_model.h36
1 files changed, 21 insertions, 15 deletions
diff --git a/app/tree_node_model.h b/app/tree_node_model.h
index b47fe03..0d9f2b9 100644
--- a/app/tree_node_model.h
+++ b/app/tree_node_model.h
@@ -11,6 +11,7 @@
#include "app/tree_model.h"
#include "base/basictypes.h"
+#include "base/observer_list.h"
#include "base/scoped_ptr.h"
#include "base/scoped_vector.h"
#include "base/stl_util-inl.h"
@@ -231,18 +232,18 @@ class TreeNodeModel : public TreeModel {
// Creates a TreeNodeModel with the specified root node. The root is owned
// by the TreeNodeModel.
explicit TreeNodeModel(NodeType* root)
- : root_(root),
- observer_(NULL) {
+ : root_(root) {
}
virtual ~TreeNodeModel() {}
- virtual void SetObserver(TreeModelObserver* observer) {
- observer_ = observer;
+ // Observer methods, calls into ObserverList.
+ virtual void AddObserver(TreeModelObserver* observer) {
+ observer_list_.AddObserver(observer);
}
- TreeModelObserver* GetObserver() {
- return observer_;
+ virtual void RemoveObserver(TreeModelObserver* observer) {
+ observer_list_.RemoveObserver(observer);
}
// TreeModel methods, all forward to the nodes.
@@ -294,27 +295,32 @@ class TreeNodeModel : public TreeModel {
}
void NotifyObserverTreeNodesAdded(NodeType* parent, int start, int count) {
- if (observer_)
- observer_->TreeNodesAdded(this, parent, start, count);
+ FOR_EACH_OBSERVER(TreeModelObserver,
+ observer_list_,
+ TreeNodesAdded(this, parent, start, count));
}
void NotifyObserverTreeNodesRemoved(NodeType* parent, int start, int count) {
- if (observer_)
- observer_->TreeNodesRemoved(this, parent, start, count);
+ FOR_EACH_OBSERVER(TreeModelObserver,
+ observer_list_,
+ TreeNodesRemoved(this, parent, start, count));
}
virtual void NotifyObserverTreeNodeChanged(TreeModelNode* node) {
- if (observer_)
- observer_->TreeNodeChanged(this, node);
+ FOR_EACH_OBSERVER(TreeModelObserver,
+ observer_list_,
+ TreeNodeChanged(this, node));
}
+ protected:
+ ObserverList<TreeModelObserver>& observer_list() { return observer_list_; }
+
private:
+ // The observers.
+ ObserverList<TreeModelObserver> observer_list_;
// The root.
scoped_ptr<NodeType> root_;
- // The observer.
- TreeModelObserver* observer_;
-
DISALLOW_COPY_AND_ASSIGN(TreeNodeModel);
};