Chromium Code Reviews| 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 // C++ bridge class to send a selector to a Cocoa object when the | 5 // C++ bridge class to send a selector to a Cocoa object when the |
| 6 // bookmark model changes. Some Cocoa objects edit the bookmark model | 6 // bookmark model changes. Some Cocoa objects edit the bookmark model |
| 7 // and temporarily save a copy of the state (e.g. bookmark button | 7 // and temporarily save a copy of the state (e.g. bookmark button |
| 8 // editor). As a fail-safe, these objects want an easy cancel if the | 8 // editor). As a fail-safe, these objects want an easy cancel if the |
| 9 // model changes out from under them. For example, if you have the | 9 // model changes out from under them. For example, if you have the |
| 10 // bookmark button editor sheet open, then edit the bookmark in the | 10 // bookmark button editor sheet open, then edit the bookmark in the |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 #include <set> | 24 #include <set> |
| 25 | 25 |
| 26 #include "base/basictypes.h" | 26 #include "base/basictypes.h" |
| 27 #include "base/mac/scoped_block.h" | 27 #include "base/mac/scoped_block.h" |
| 28 #include "components/bookmarks/browser/bookmark_model.h" | 28 #include "components/bookmarks/browser/bookmark_model.h" |
| 29 #include "components/bookmarks/browser/bookmark_model_observer.h" | 29 #include "components/bookmarks/browser/bookmark_model_observer.h" |
| 30 | 30 |
| 31 class BookmarkModelObserverForCocoa : public bookmarks::BookmarkModelObserver { | 31 class BookmarkModelObserverForCocoa : public bookmarks::BookmarkModelObserver { |
| 32 public: | 32 public: |
| 33 // Callback called on a significant model change. |nodeWasDeleted| will | 33 // Callback called on a significant model change. |nodeWasDeleted| will |
|
tapted
2015/08/25 05:46:34
update comment
jackhou1
2015/08/25 07:01:10
Done.
| |
| 34 // be YES if an observed node was deleted in the change. | 34 // be YES if an observed node was deleted in the change. |
| 35 typedef void(^ChangeCallback)(BOOL nodeWasDeleted); | 35 typedef void (^ChangeCallback)(); |
| 36 | 36 |
| 37 // When a |model| changes, or an observed node within it does, call a | 37 // When a |model| changes, or an observed node within it does, call a |
| 38 // |callback|. | 38 // |callback|. |
| 39 BookmarkModelObserverForCocoa(bookmarks::BookmarkModel* model, | 39 BookmarkModelObserverForCocoa(bookmarks::BookmarkModel* model, |
| 40 ChangeCallback callback); | 40 ChangeCallback callback); |
| 41 ~BookmarkModelObserverForCocoa() override; | 41 ~BookmarkModelObserverForCocoa() override; |
| 42 | 42 |
| 43 // Starts and stops observing a specified |node|; the node must be contained | 43 // Starts and stops observing a specified |node|; the node must be contained |
| 44 // within the model. | 44 // within the model. |
| 45 void StartObservingNode(const bookmarks::BookmarkNode* node); | 45 void StartObservingNode(const bookmarks::BookmarkNode* node); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 | 82 |
| 83 void ExtensiveBookmarkChangesEnded(bookmarks::BookmarkModel* model) override { | 83 void ExtensiveBookmarkChangesEnded(bookmarks::BookmarkModel* model) override { |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 bookmarks::BookmarkModel* model_; // Weak; it is owned by a Profile. | 87 bookmarks::BookmarkModel* model_; // Weak; it is owned by a Profile. |
| 88 std::set<const bookmarks::BookmarkNode*> | 88 std::set<const bookmarks::BookmarkNode*> |
| 89 nodes_; // Weak items owned by a BookmarkModel. | 89 nodes_; // Weak items owned by a BookmarkModel. |
| 90 base::mac::ScopedBlock<ChangeCallback> callback_; | 90 base::mac::ScopedBlock<ChangeCallback> callback_; |
| 91 | 91 |
| 92 // Send a notification to the client; |deleted| is YES if an observed node was | 92 // Send a notification to the client. |
| 93 // deleted in the change. | 93 void Notify(); |
| 94 void Notify(BOOL deleted); | |
| 95 | 94 |
| 96 DISALLOW_COPY_AND_ASSIGN(BookmarkModelObserverForCocoa); | 95 DISALLOW_COPY_AND_ASSIGN(BookmarkModelObserverForCocoa); |
| 97 }; | 96 }; |
| 98 | 97 |
| 99 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MODEL_OBSERVER_FOR_COCOA_H | 98 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MODEL_OBSERVER_FOR_COCOA_H |
| OLD | NEW |