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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/bookmarks/bookmark_model_bridge_observer.mm
diff --git a/ios/chrome/browser/ui/bookmarks/bookmark_model_bridge_observer.mm b/ios/chrome/browser/ui/bookmarks/bookmark_model_bridge_observer.mm
new file mode 100644
index 0000000000000000000000000000000000000000..9282880f58b7f47a196ddc64e7d4dae2cadcac2c
--- /dev/null
+++ b/ios/chrome/browser/ui/bookmarks/bookmark_model_bridge_observer.mm
@@ -0,0 +1,89 @@
+// Copyright 2014 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 "ios/chrome/browser/ui/bookmarks/bookmark_model_bridge_observer.h"
+
+#include <Foundation/Foundation.h>
+
+#include "base/logging.h"
+#include "components/bookmarks/browser/bookmark_model.h"
+
+namespace bookmarks {
+
+BookmarkModelBridge::BookmarkModelBridge(
+ id<BookmarkModelBridgeObserver> observer,
+ BookmarkModel* model)
+ : observer_(observer), model_(model) {
+ DCHECK(observer_);
+ DCHECK(model_);
+ model_->AddObserver(this);
+}
+
+BookmarkModelBridge::~BookmarkModelBridge() {
+ DCHECK(model_);
+ model_->RemoveObserver(this);
+}
+
+void BookmarkModelBridge::BookmarkModelLoaded(BookmarkModel* model,
+ bool ids_reassigned) {
+ [observer_ bookmarkModelLoaded];
+}
+
+void BookmarkModelBridge::BookmarkModelBeingDeleted(BookmarkModel* model) {
+ // This is an inconsistent state in the application lifecycle. The bookmark
+ // model shouldn't disappear.
+ NOTREACHED();
+}
+
+void BookmarkModelBridge::BookmarkNodeMoved(BookmarkModel* model,
+ const BookmarkNode* old_parent,
+ int old_index,
+ const BookmarkNode* new_parent,
+ int new_index) {
+ const BookmarkNode* node = new_parent->GetChild(new_index);
+ [observer_ bookmarkNode:node movedFromParent:old_parent toParent:new_parent];
+}
+
+void BookmarkModelBridge::BookmarkNodeAdded(BookmarkModel* model,
+ const BookmarkNode* parent,
+ int index) {
+ [observer_ bookmarkNodeChildrenChanged:parent];
+}
+
+void BookmarkModelBridge::BookmarkNodeRemoved(
+ BookmarkModel* model,
+ const BookmarkNode* parent,
+ int old_index,
+ const BookmarkNode* node,
+ const std::set<GURL>& removed_urls) {
+ [observer_ bookmarkNodeDeleted:node fromFolder:parent];
+ [observer_ bookmarkNodeChildrenChanged:parent];
+}
+
+void BookmarkModelBridge::BookmarkNodeChanged(BookmarkModel* model,
+ const BookmarkNode* node) {
+ [observer_ bookmarkNodeChanged:node];
+}
+
+void BookmarkModelBridge::BookmarkNodeFaviconChanged(BookmarkModel* model,
+ const BookmarkNode* node) {
+ SEL selector = @selector(bookmarkNodeFaviconChanged:);
+ if ([observer_ respondsToSelector:selector]) {
+ [observer_ bookmarkNodeFaviconChanged:node];
+ }
+}
+
+void BookmarkModelBridge::BookmarkNodeChildrenReordered(
+ BookmarkModel* model,
+ const BookmarkNode* node) {
+ [observer_ bookmarkNodeChildrenChanged:node];
+}
+
+void BookmarkModelBridge::BookmarkAllUserNodesRemoved(
+ BookmarkModel* model,
+ const std::set<GURL>& removed_urls) {
+ [observer_ bookmarkModelRemovedAllNodes];
+}
+
+} // namespace bookmarks

Powered by Google App Engine
This is Rietveld 408576698