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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
12 #include "chrome/common/pref_names.h"
15 BookmarkBarBridge::BookmarkBarBridge(Profile* profile,
16 BookmarkBarController* controller,
18 : controller_(controller),
21 model_->AddObserver(this);
23 // Bookmark loading is async; it may may not have happened yet.
24 // We will be notified when that happens with the AddObserver() call.
26 BookmarkModelLoaded(model, false);
28 profile_pref_registrar_.Init(profile->GetPrefs());
29 profile_pref_registrar_.Add(
30 prefs::kShowAppsShortcutInBookmarkBar,
31 base::Bind(&BookmarkBarBridge::OnAppsPageShortcutVisibilityPrefChanged,
32 base::Unretained(this)));
34 [controller_ updateAppsPageShortcutButtonVisibility];
37 BookmarkBarBridge::~BookmarkBarBridge() {
38 model_->RemoveObserver(this);
41 void BookmarkBarBridge::BookmarkModelLoaded(BookmarkModel* model,
42 bool ids_reassigned) {
43 [controller_ loaded:model];
46 void BookmarkBarBridge::BookmarkModelBeingDeleted(BookmarkModel* model) {
47 [controller_ beingDeleted:model];
50 void BookmarkBarBridge::BookmarkNodeMoved(BookmarkModel* model,
51 const BookmarkNode* old_parent,
53 const BookmarkNode* new_parent,
56 [controller_ nodeMoved:model
57 oldParent:old_parent oldIndex:old_index
58 newParent:new_parent newIndex:new_index];
62 void BookmarkBarBridge::BookmarkNodeAdded(BookmarkModel* model,
63 const BookmarkNode* parent,
66 [controller_ nodeAdded:model parent:parent index:index];
69 void BookmarkBarBridge::BookmarkNodeRemoved(BookmarkModel* model,
70 const BookmarkNode* parent,
72 const BookmarkNode* node) {
74 [controller_ nodeRemoved:model parent:parent index:old_index];
77 void BookmarkBarBridge::BookmarkAllNodesRemoved(BookmarkModel* model) {
78 [controller_ loaded:model];
81 void BookmarkBarBridge::BookmarkNodeChanged(BookmarkModel* model,
82 const BookmarkNode* node) {
84 [controller_ nodeChanged:model node:node];
87 void BookmarkBarBridge::BookmarkNodeFaviconChanged(BookmarkModel* model,
88 const BookmarkNode* node) {
90 [controller_ nodeFaviconLoaded:model node:node];
93 void BookmarkBarBridge::BookmarkNodeChildrenReordered(
94 BookmarkModel* model, const BookmarkNode* node) {
96 [controller_ nodeChildrenReordered:model node:node];
99 void BookmarkBarBridge::ExtensiveBookmarkChangesBeginning(
100 BookmarkModel* model) {
104 void BookmarkBarBridge::ExtensiveBookmarkChangesEnded(BookmarkModel* model) {
106 [controller_ loaded:model];
109 void BookmarkBarBridge::OnAppsPageShortcutVisibilityPrefChanged() {
110 [controller_ updateAppsPageShortcutButtonVisibility];