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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
6 | 6 |
7 #include "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 [button setTarget:self]; | 1217 [button setTarget:self]; |
1218 // Make sure this button, like all other BookmarkButtons, lives | 1218 // Make sure this button, like all other BookmarkButtons, lives |
1219 // until the end of the current event loop. | 1219 // until the end of the current event loop. |
1220 [[button retain] autorelease]; | 1220 [[button retain] autorelease]; |
1221 return button; | 1221 return button; |
1222 } | 1222 } |
1223 | 1223 |
1224 // Creates the button for "Managed Bookmarks", but does not position it. | 1224 // Creates the button for "Managed Bookmarks", but does not position it. |
1225 - (void)createManagedBookmarksButton { | 1225 - (void)createManagedBookmarksButton { |
1226 if (managedBookmarksButton_.get()) { | 1226 if (managedBookmarksButton_.get()) { |
| 1227 // The node's title might have changed if the user signed in or out. |
| 1228 // Make sure it's up to date now. |
| 1229 const BookmarkNode* node = bookmarkClient_->managed_node(); |
| 1230 NSString* title = base::SysUTF16ToNSString(node->GetTitle()); |
| 1231 NSCell* cell = [managedBookmarksButton_ cell]; |
| 1232 [cell setTitle:title]; |
| 1233 |
| 1234 // Its visibility may have changed too. |
1227 [self setManagedBookmarksButtonVisibility]; | 1235 [self setManagedBookmarksButtonVisibility]; |
| 1236 |
1228 return; | 1237 return; |
1229 } | 1238 } |
1230 | 1239 |
1231 NSCell* cell = [self cellForBookmarkNode:bookmarkClient_->managed_node()]; | 1240 NSCell* cell = [self cellForBookmarkNode:bookmarkClient_->managed_node()]; |
1232 managedBookmarksButton_.reset([self createCustomBookmarkButtonForCell:cell]); | 1241 managedBookmarksButton_.reset([self createCustomBookmarkButtonForCell:cell]); |
1233 [managedBookmarksButton_ setAction:@selector(openBookmarkFolderFromButton:)]; | 1242 [managedBookmarksButton_ setAction:@selector(openBookmarkFolderFromButton:)]; |
1234 view_id_util::SetID(managedBookmarksButton_.get(), VIEW_ID_MANAGED_BOOKMARKS); | 1243 view_id_util::SetID(managedBookmarksButton_.get(), VIEW_ID_MANAGED_BOOKMARKS); |
1235 [buttonView_ addSubview:managedBookmarksButton_.get()]; | 1244 [buttonView_ addSubview:managedBookmarksButton_.get()]; |
1236 | 1245 |
1237 [self setManagedBookmarksButtonVisibility]; | 1246 [self setManagedBookmarksButtonVisibility]; |
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2782 - (id<BookmarkButtonControllerProtocol>)controllerForNode: | 2791 - (id<BookmarkButtonControllerProtocol>)controllerForNode: |
2783 (const BookmarkNode*)node { | 2792 (const BookmarkNode*)node { |
2784 // See if it's in the bar, then if it is in the hierarchy of visible | 2793 // See if it's in the bar, then if it is in the hierarchy of visible |
2785 // folder menus. | 2794 // folder menus. |
2786 if (bookmarkModel_->bookmark_bar_node() == node) | 2795 if (bookmarkModel_->bookmark_bar_node() == node) |
2787 return self; | 2796 return self; |
2788 return [folderController_ controllerForNode:node]; | 2797 return [folderController_ controllerForNode:node]; |
2789 } | 2798 } |
2790 | 2799 |
2791 @end | 2800 @end |
OLD | NEW |