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" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 10 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
12 #include "components/bookmarks/browser/bookmark_model.h" | 12 #include "components/bookmarks/browser/bookmark_model.h" |
13 | 13 |
14 | 14 |
15 BookmarkBarBridge::BookmarkBarBridge(Profile* profile, | 15 BookmarkBarBridge::BookmarkBarBridge(Profile* profile, |
16 BookmarkBarController* controller, | 16 BookmarkBarController* controller, |
17 BookmarkModel* model) | 17 BookmarkModel* model) |
18 : controller_(controller), | 18 : controller_(controller), |
19 model_(model), | 19 model_(model), |
20 batch_mode_(false) { | 20 batch_mode_(false) { |
21 model_->AddObserver(this); | 21 model_->AddObserver(this); |
22 | 22 |
23 // Bookmark loading is async; it may may not have happened yet. | 23 // Bookmark loading is async; it may may not have happened yet. |
24 // We will be notified when that happens with the AddObserver() call. | 24 // We will be notified when that happens with the AddObserver() call. |
25 if (model->loaded()) | 25 if (model->loaded()) |
26 BookmarkModelLoaded(model, false); | 26 BookmarkModelLoaded(model, false); |
27 | 27 |
28 profile_pref_registrar_.Init(profile->GetPrefs()); | 28 profile_pref_registrar_.Init(profile->GetPrefs()); |
29 profile_pref_registrar_.Add( | 29 profile_pref_registrar_.Add( |
30 prefs::kShowAppsShortcutInBookmarkBar, | 30 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
31 base::Bind(&BookmarkBarBridge::OnExtraButtonsVisibilityChanged, | 31 base::Bind(&BookmarkBarBridge::OnExtraButtonsVisibilityChanged, |
32 base::Unretained(this))); | 32 base::Unretained(this))); |
33 profile_pref_registrar_.Add( | 33 profile_pref_registrar_.Add( |
34 prefs::kShowManagedBookmarksInBookmarkBar, | 34 bookmarks::prefs::kShowManagedBookmarksInBookmarkBar, |
35 base::Bind(&BookmarkBarBridge::OnExtraButtonsVisibilityChanged, | 35 base::Bind(&BookmarkBarBridge::OnExtraButtonsVisibilityChanged, |
36 base::Unretained(this))); | 36 base::Unretained(this))); |
37 | 37 |
38 OnExtraButtonsVisibilityChanged(); | 38 OnExtraButtonsVisibilityChanged(); |
39 } | 39 } |
40 | 40 |
41 BookmarkBarBridge::~BookmarkBarBridge() { | 41 BookmarkBarBridge::~BookmarkBarBridge() { |
42 model_->RemoveObserver(this); | 42 model_->RemoveObserver(this); |
43 } | 43 } |
44 | 44 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 void BookmarkBarBridge::ExtensiveBookmarkChangesEnded(BookmarkModel* model) { | 112 void BookmarkBarBridge::ExtensiveBookmarkChangesEnded(BookmarkModel* model) { |
113 batch_mode_ = false; | 113 batch_mode_ = false; |
114 [controller_ loaded:model]; | 114 [controller_ loaded:model]; |
115 } | 115 } |
116 | 116 |
117 void BookmarkBarBridge::OnExtraButtonsVisibilityChanged() { | 117 void BookmarkBarBridge::OnExtraButtonsVisibilityChanged() { |
118 [controller_ updateExtraButtonsVisibility]; | 118 [controller_ updateExtraButtonsVisibility]; |
119 } | 119 } |
OLD | NEW |