Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_model_bridge_observer.mm

Issue 2586993002: Upstream Chrome on iOS source code [3/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ios/chrome/browser/ui/bookmarks/bookmark_model_bridge_observer.h"
6
7 #include <Foundation/Foundation.h>
8
9 #include "base/logging.h"
10 #include "components/bookmarks/browser/bookmark_model.h"
11
12 namespace bookmarks {
13
14 BookmarkModelBridge::BookmarkModelBridge(
15 id<BookmarkModelBridgeObserver> observer,
16 BookmarkModel* model)
17 : observer_(observer), model_(model) {
18 DCHECK(observer_);
19 DCHECK(model_);
20 model_->AddObserver(this);
21 }
22
23 BookmarkModelBridge::~BookmarkModelBridge() {
24 DCHECK(model_);
25 model_->RemoveObserver(this);
26 }
27
28 void BookmarkModelBridge::BookmarkModelLoaded(BookmarkModel* model,
29 bool ids_reassigned) {
30 [observer_ bookmarkModelLoaded];
31 }
32
33 void BookmarkModelBridge::BookmarkModelBeingDeleted(BookmarkModel* model) {
34 // This is an inconsistent state in the application lifecycle. The bookmark
35 // model shouldn't disappear.
36 NOTREACHED();
37 }
38
39 void BookmarkModelBridge::BookmarkNodeMoved(BookmarkModel* model,
40 const BookmarkNode* old_parent,
41 int old_index,
42 const BookmarkNode* new_parent,
43 int new_index) {
44 const BookmarkNode* node = new_parent->GetChild(new_index);
45 [observer_ bookmarkNode:node movedFromParent:old_parent toParent:new_parent];
46 }
47
48 void BookmarkModelBridge::BookmarkNodeAdded(BookmarkModel* model,
49 const BookmarkNode* parent,
50 int index) {
51 [observer_ bookmarkNodeChildrenChanged:parent];
52 }
53
54 void BookmarkModelBridge::BookmarkNodeRemoved(
55 BookmarkModel* model,
56 const BookmarkNode* parent,
57 int old_index,
58 const BookmarkNode* node,
59 const std::set<GURL>& removed_urls) {
60 [observer_ bookmarkNodeDeleted:node fromFolder:parent];
61 [observer_ bookmarkNodeChildrenChanged:parent];
62 }
63
64 void BookmarkModelBridge::BookmarkNodeChanged(BookmarkModel* model,
65 const BookmarkNode* node) {
66 [observer_ bookmarkNodeChanged:node];
67 }
68
69 void BookmarkModelBridge::BookmarkNodeFaviconChanged(BookmarkModel* model,
70 const BookmarkNode* node) {
71 SEL selector = @selector(bookmarkNodeFaviconChanged:);
72 if ([observer_ respondsToSelector:selector]) {
73 [observer_ bookmarkNodeFaviconChanged:node];
74 }
75 }
76
77 void BookmarkModelBridge::BookmarkNodeChildrenReordered(
78 BookmarkModel* model,
79 const BookmarkNode* node) {
80 [observer_ bookmarkNodeChildrenChanged:node];
81 }
82
83 void BookmarkModelBridge::BookmarkAllUserNodesRemoved(
84 BookmarkModel* model,
85 const std::set<GURL>& removed_urls) {
86 [observer_ bookmarkModelRemovedAllNodes];
87 }
88
89 } // namespace bookmarks
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698