| 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 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h" | 5 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/prefs/pref_service.h" |
| 7 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 11 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 12 #include "chrome/common/pref_names.h" |
| 9 | 13 |
| 10 BookmarkBarBridge::BookmarkBarBridge(BookmarkBarController* controller, | 14 |
| 15 BookmarkBarBridge::BookmarkBarBridge(Profile* profile, |
| 16 BookmarkBarController* controller, |
| 11 BookmarkModel* model) | 17 BookmarkModel* model) |
| 12 : controller_(controller), | 18 : controller_(controller), |
| 13 model_(model), | 19 model_(model), |
| 14 batch_mode_(false) { | 20 batch_mode_(false) { |
| 15 model_->AddObserver(this); | 21 model_->AddObserver(this); |
| 16 | 22 |
| 17 // Bookmark loading is async; it may may not have happened yet. | 23 // Bookmark loading is async; it may may not have happened yet. |
| 18 // We will be notified when that happens with the AddObserver() call. | 24 // We will be notified when that happens with the AddObserver() call. |
| 19 if (model->IsLoaded()) | 25 if (model->IsLoaded()) |
| 20 Loaded(model, false); | 26 Loaded(model, false); |
| 27 |
| 28 profile_pref_registrar_.Init(profile->GetPrefs()); |
| 29 profile_pref_registrar_.Add( |
| 30 prefs::kShowAppsShortcutInBookmarkBar, |
| 31 base::Bind(&BookmarkBarBridge::OnAppsPageShortcutVisibilityChanged, |
| 32 base::Unretained(this))); |
| 21 } | 33 } |
| 22 | 34 |
| 23 BookmarkBarBridge::~BookmarkBarBridge() { | 35 BookmarkBarBridge::~BookmarkBarBridge() { |
| 24 model_->RemoveObserver(this); | 36 model_->RemoveObserver(this); |
| 25 } | 37 } |
| 26 | 38 |
| 27 void BookmarkBarBridge::Loaded(BookmarkModel* model, bool ids_reassigned) { | 39 void BookmarkBarBridge::Loaded(BookmarkModel* model, bool ids_reassigned) { |
| 28 [controller_ loaded:model]; | 40 [controller_ loaded:model]; |
| 29 } | 41 } |
| 30 | 42 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 86 |
| 75 void BookmarkBarBridge::ExtensiveBookmarkChangesBeginning( | 87 void BookmarkBarBridge::ExtensiveBookmarkChangesBeginning( |
| 76 BookmarkModel* model) { | 88 BookmarkModel* model) { |
| 77 batch_mode_ = true; | 89 batch_mode_ = true; |
| 78 } | 90 } |
| 79 | 91 |
| 80 void BookmarkBarBridge::ExtensiveBookmarkChangesEnded(BookmarkModel* model) { | 92 void BookmarkBarBridge::ExtensiveBookmarkChangesEnded(BookmarkModel* model) { |
| 81 batch_mode_ = false; | 93 batch_mode_ = false; |
| 82 [controller_ loaded:model]; | 94 [controller_ loaded:model]; |
| 83 } | 95 } |
| 96 |
| 97 void BookmarkBarBridge::OnAppsPageShortcutVisibilityChanged() { |
| 98 [controller_ updateAppsPageShortcutButtonVisibility]; |
| 99 } |
| OLD | NEW |