| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_context_menu_cocoa_controlle
r.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_context_menu_cocoa_controlle
r.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 menuController_.reset([[MenuController alloc] initWithModel:menuModel | 81 menuController_.reset([[MenuController alloc] initWithModel:menuModel |
| 82 useWithPopUpButtonCell:NO]); | 82 useWithPopUpButtonCell:NO]); |
| 83 } | 83 } |
| 84 | 84 |
| 85 - (NSMenu*)menuForBookmarkNode:(const BookmarkNode*)node { | 85 - (NSMenu*)menuForBookmarkNode:(const BookmarkNode*)node { |
| 86 // Depending on timing, the model may not yet have been loaded. | 86 // Depending on timing, the model may not yet have been loaded. |
| 87 BookmarkModel* bookmarkModel = [bookmarkBarController_ bookmarkModel]; | 87 BookmarkModel* bookmarkModel = [bookmarkBarController_ bookmarkModel]; |
| 88 if (!bookmarkModel || !bookmarkModel->IsLoaded()) | 88 if (!bookmarkModel || !bookmarkModel->IsLoaded()) |
| 89 return nil; | 89 return nil; |
| 90 | 90 |
| 91 // This may be called before the BMB view has been added to the window. In |
| 92 // that case, simply return nil so that BookmarkContextMenuController doesn't |
| 93 // get created with a nil window. |
| 94 if (![bookmarkBarController_ browserWindow]) |
| 95 return nil; |
| 96 |
| 91 if (!node) | 97 if (!node) |
| 92 node = bookmarkModel->bookmark_bar_node(); | 98 node = bookmarkModel->bookmark_bar_node(); |
| 93 | 99 |
| 94 // Rebuild the menu if it's for a different node than the last request. | 100 // Rebuild the menu if it's for a different node than the last request. |
| 95 if (!menuController_ || node != bookmarkNode_) { | 101 if (!menuController_ || node != bookmarkNode_) { |
| 96 bookmarkNode_ = node; | 102 bookmarkNode_ = node; |
| 97 [self createMenuControllers:bookmarkModel]; | 103 [self createMenuControllers:bookmarkModel]; |
| 98 } | 104 } |
| 99 return [menuController_ menu]; | 105 return [menuController_ menu]; |
| 100 } | 106 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 111 | 117 |
| 112 [bookmarkBarController_ closeFolderAndStopTrackingMenus]; | 118 [bookmarkBarController_ closeFolderAndStopTrackingMenus]; |
| 113 [bookmarkBarController_ unhighlightBookmark:bookmarkNode_]; | 119 [bookmarkBarController_ unhighlightBookmark:bookmarkNode_]; |
| 114 } | 120 } |
| 115 | 121 |
| 116 - (void)cancelTracking { | 122 - (void)cancelTracking { |
| 117 [[menuController_ menu] cancelTracking]; | 123 [[menuController_ menu] cancelTracking]; |
| 118 } | 124 } |
| 119 | 125 |
| 120 @end | 126 @end |
| OLD | NEW |