diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-22 20:28:00 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-22 20:28:00 +0000 |
commit | bca14bc4a3d8d82e817f01d0bb105aaa6e3c081a (patch) | |
tree | 70e34ef2265cb64373290c2b745cfb36e2b0ffda /chrome/browser/ui/cocoa/bookmarks | |
parent | b69aaa3563503d5ce21f2d7b6308f89adb135694 (diff) | |
download | chromium_src-bca14bc4a3d8d82e817f01d0bb105aaa6e3c081a.zip chromium_src-bca14bc4a3d8d82e817f01d0bb105aaa6e3c081a.tar.gz chromium_src-bca14bc4a3d8d82e817f01d0bb105aaa6e3c081a.tar.bz2 |
Out of line cleanups for Mac.
BUG=none
TEST=compiles
Review URL: http://codereview.chromium.org/6542027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75626 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/cocoa/bookmarks')
-rw-r--r-- | chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h | 42 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.mm | 64 |
2 files changed, 72 insertions, 34 deletions
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h b/chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h index 0a7da34..9061132 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h @@ -41,46 +41,22 @@ class BookmarkModelObserverForCocoa : public BookmarkModelObserver { BookmarkModelObserverForCocoa(const BookmarkNode* node, BookmarkModel* model, NSObject* object, - SEL selector) { - DCHECK(model); - node_ = node; - model_ = model; - object_ = object; - selector_ = selector; - model_->AddObserver(this); - } - virtual ~BookmarkModelObserverForCocoa() { - model_->RemoveObserver(this); - } + SEL selector); + virtual ~BookmarkModelObserverForCocoa(); - virtual void BookmarkModelBeingDeleted(BookmarkModel* model) { - Notify(); - } + virtual void BookmarkModelBeingDeleted(BookmarkModel* model); virtual void BookmarkNodeMoved(BookmarkModel* model, const BookmarkNode* old_parent, int old_index, const BookmarkNode* new_parent, - int new_index) { - // Editors often have a tree of parents, so movement of folders - // must cause a cancel. - Notify(); - } + int new_index); virtual void BookmarkNodeRemoved(BookmarkModel* model, const BookmarkNode* parent, int old_index, - const BookmarkNode* node) { - // See comment in BookmarkNodeMoved. - Notify(); - } + const BookmarkNode* node); virtual void BookmarkNodeChanged(BookmarkModel* model, - const BookmarkNode* node) { - if ((node_ == node) || (!node_)) - Notify(); - } - virtual void BookmarkImportBeginning(BookmarkModel* model) { - // Be conservative. - Notify(); - } + const BookmarkNode* node); + virtual void BookmarkImportBeginning(BookmarkModel* model); // Some notifications we don't care about, but by being pure virtual // in the base class we must implement them. @@ -106,9 +82,7 @@ class BookmarkModelObserverForCocoa : public BookmarkModelObserver { NSObject* object_; // Weak, like a delegate. SEL selector_; - void Notify() { - [object_ performSelector:selector_ withObject:nil]; - } + void Notify(); DISALLOW_COPY_AND_ASSIGN(BookmarkModelObserverForCocoa); }; diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.mm new file mode 100644 index 0000000..3345497 --- /dev/null +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.mm @@ -0,0 +1,64 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h" + +BookmarkModelObserverForCocoa::BookmarkModelObserverForCocoa( + const BookmarkNode* node, + BookmarkModel* model, + NSObject* object, + SEL selector) { + DCHECK(model); + node_ = node; + model_ = model; + object_ = object; + selector_ = selector; + model_->AddObserver(this); +} + +BookmarkModelObserverForCocoa::~BookmarkModelObserverForCocoa() { + model_->RemoveObserver(this); +} + +void BookmarkModelObserverForCocoa::BookmarkModelBeingDeleted( + BookmarkModel* model) { + Notify(); +} + +void BookmarkModelObserverForCocoa::BookmarkNodeMoved( + BookmarkModel* model, + const BookmarkNode* old_parent, + int old_index, + const BookmarkNode* new_parent, + int new_index) { + // Editors often have a tree of parents, so movement of folders + // must cause a cancel. + Notify(); +} + +void BookmarkModelObserverForCocoa::BookmarkNodeRemoved( + BookmarkModel* model, + const BookmarkNode* parent, + int old_index, + const BookmarkNode* node) { + // See comment in BookmarkNodeMoved. + Notify(); +} + +void BookmarkModelObserverForCocoa::BookmarkNodeChanged( + BookmarkModel* model, + const BookmarkNode* node) { + if ((node_ == node) || (!node_)) + Notify(); +} + +void BookmarkModelObserverForCocoa::BookmarkImportBeginning( + BookmarkModel* model) { + // Be conservative. + Notify(); +} + +void BookmarkModelObserverForCocoa::Notify() { + [object_ performSelector:selector_ withObject:nil]; +} |