OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // C++ controller for the bookmark menu; one per AppController (which | 5 // C++ controller for the bookmark menu; one per AppController (which |
6 // means there is only one). When bookmarks are changed, this class | 6 // means there is only one). When bookmarks are changed, this class |
7 // takes care of updating Cocoa bookmark menus. This is not named | 7 // takes care of updating Cocoa bookmark menus. This is not named |
8 // BookmarkMenuController to help avoid confusion between languages. | 8 // BookmarkMenuController to help avoid confusion between languages. |
9 // This class needs to be C++, not ObjC, since it derives from | 9 // This class needs to be C++, not ObjC, since it derives from |
10 // BookmarkModelObserver. | 10 // BookmarkModelObserver. |
11 // | 11 // |
12 // Most Chromium Cocoa menu items are static from a nib (e.g. New | 12 // Most Chromium Cocoa menu items are static from a nib (e.g. New |
13 // Tab), but may be enabled/disabled under certain circumstances | 13 // Tab), but may be enabled/disabled under certain circumstances |
14 // (e.g. Cut and Paste). In addition, most Cocoa menu items have | 14 // (e.g. Cut and Paste). In addition, most Cocoa menu items have |
15 // firstResponder: as a target. Unusually, bookmark menu items are | 15 // firstResponder: as a target. Unusually, bookmark menu items are |
16 // created dynamically. They also have a target of | 16 // created dynamically. They also have a target of |
17 // BookmarkMenuCocoaController instead of firstResponder. | 17 // BookmarkMenuCocoaController instead of firstResponder. |
18 // See BookmarkMenuBridge::AddNodeToMenu()). | 18 // See BookmarkMenuBridge::AddNodeToMenu()). |
19 | 19 |
20 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_BRIDGE_H_ | 20 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_BRIDGE_H_ |
21 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_BRIDGE_H_ | 21 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_BRIDGE_H_ |
22 | 22 |
23 #include <map> | 23 #include <map> |
24 | 24 |
25 #include "base/memory/scoped_nsobject.h" | 25 #include "base/mac/scoped_nsobject.h" |
26 #include "chrome/browser/bookmarks/bookmark_model_observer.h" | 26 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
27 #import "chrome/browser/ui/cocoa/main_menu_item.h" | 27 #import "chrome/browser/ui/cocoa/main_menu_item.h" |
28 | 28 |
29 class BookmarkNode; | 29 class BookmarkNode; |
30 class Profile; | 30 class Profile; |
31 @class NSImage; | 31 @class NSImage; |
32 @class NSMenu; | 32 @class NSMenu; |
33 @class NSMenuItem; | 33 @class NSMenuItem; |
34 @class BookmarkMenuCocoaController; | 34 @class BookmarkMenuCocoaController; |
35 | 35 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 private: | 132 private: |
133 friend class BookmarkMenuBridgeTest; | 133 friend class BookmarkMenuBridgeTest; |
134 | 134 |
135 // True iff the menu is up-to-date with the actual BookmarkModel. | 135 // True iff the menu is up-to-date with the actual BookmarkModel. |
136 bool menuIsValid_; | 136 bool menuIsValid_; |
137 | 137 |
138 Profile* profile_; // weak | 138 Profile* profile_; // weak |
139 BookmarkMenuCocoaController* controller_; // strong | 139 BookmarkMenuCocoaController* controller_; // strong |
140 | 140 |
141 // The folder image so we can use one copy for all. | 141 // The folder image so we can use one copy for all. |
142 scoped_nsobject<NSImage> folder_image_; | 142 base::scoped_nsobject<NSImage> folder_image_; |
143 | 143 |
144 // In order to appropriately update items in the bookmark menu, without | 144 // In order to appropriately update items in the bookmark menu, without |
145 // forcing a rebuild, map the model's nodes to menu items. | 145 // forcing a rebuild, map the model's nodes to menu items. |
146 std::map<const BookmarkNode*, NSMenuItem*> bookmark_nodes_; | 146 std::map<const BookmarkNode*, NSMenuItem*> bookmark_nodes_; |
147 }; | 147 }; |
148 | 148 |
149 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_BRIDGE_H_ | 149 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_BRIDGE_H_ |
OLD | NEW |