summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_bar_bridge.mm
blob: 54b3f5b8bc2faae34395a37b56a2d160e742e7f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2009 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/cocoa/bookmark_bar_bridge.h"
#include "chrome/browser/cocoa/bookmark_bar_controller.h"

BookmarkBarBridge::BookmarkBarBridge(BookmarkBarController* controller,
                                     BookmarkModel* model)
    : controller_(controller), model_(model) {
  model_->AddObserver(this);

  // Bookmark loading is async; it may may not have happened yet.
  // We will be notified when that happens with the AddObserver() call.
  if (model->IsLoaded())
    Loaded(model);
}

BookmarkBarBridge::~BookmarkBarBridge() {
  model_->RemoveObserver(this);
}

void BookmarkBarBridge::Loaded(BookmarkModel* model) {
  [controller_ loaded:model];
}

void BookmarkBarBridge::BookmarkModelBeingDeleted(BookmarkModel* model) {
  [controller_ beingDeleted:model];
}

void BookmarkBarBridge::BookmarkNodeMoved(BookmarkModel* model,
                                          BookmarkNode* old_parent,
                                          int old_index,
                                          BookmarkNode* new_parent,
                                          int new_index) {
  [controller_ nodeMoved:model
               oldParent:old_parent oldIndex:old_index
               newParent:new_parent newIndex:new_index];
}

void BookmarkBarBridge::BookmarkNodeAdded(BookmarkModel* model,
                                          BookmarkNode* parent,
                                          int index) {
  [controller_ nodeAdded:model parent:parent index:index];
}

void BookmarkBarBridge::BookmarkNodeChanged(BookmarkModel* model,
                                            BookmarkNode* node) {
  [controller_ nodeChanged:model node:node];
}

void BookmarkBarBridge::BookmarkNodeFavIconLoaded(BookmarkModel* model,
                                                  BookmarkNode* node) {
  [controller_ nodeFavIconLoaded:model node:node];
}

void BookmarkBarBridge::BookmarkNodeChildrenReordered(BookmarkModel* model,
                                                      BookmarkNode* node) {
  [controller_ nodeChildrenReordered:model node:node];
}