diff options
author | ian@chromium.org <ian@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-10 18:44:48 +0000 |
---|---|---|
committer | ian@chromium.org <ian@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-10 18:44:48 +0000 |
commit | 0457c6bb559c2cebf47235388f0441be51817d60 (patch) | |
tree | c0cabb4c18a45d1f5d48df8bb19e6442ad95b357 /app | |
parent | e06131db8c610bca50a025fc876755d0aa42e53c (diff) | |
download | chromium_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')
-rw-r--r-- | app/tree_model.h | 7 | ||||
-rw-r--r-- | app/tree_node_model.h | 36 |
2 files changed, 26 insertions, 17 deletions
diff --git a/app/tree_model.h b/app/tree_model.h index 9ce6cb1..fceb22d 100644 --- a/app/tree_model.h +++ b/app/tree_model.h @@ -74,8 +74,11 @@ class TreeModel { // Returns the parent of a node, or NULL if node is the root. virtual TreeModelNode* GetParent(TreeModelNode* node) = 0; - // Sets the observer of the model. - virtual void SetObserver(TreeModelObserver* observer) = 0; + // Adds an observer of the model. + virtual void AddObserver(TreeModelObserver* observer) = 0; + + // Removes an observer of the model. + virtual void RemoveObserver(TreeModelObserver* observer) = 0; // Sets the title of the specified node. // This is only invoked if the node is editable and the user edits a node. 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); }; |