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. |
(...skipping 19 matching lines...) Expand all Loading... |
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 |
36 class BookmarkMenuBridge : public BookmarkModelObserver, | 36 class BookmarkMenuBridge : public BookmarkModelObserver, |
37 public MainMenuItem { | 37 public MainMenuItem { |
38 public: | 38 public: |
39 BookmarkMenuBridge(Profile* profile, NSMenu* menu); | 39 BookmarkMenuBridge(Profile* profile, NSMenu* menu); |
40 virtual ~BookmarkMenuBridge(); | 40 ~BookmarkMenuBridge() override; |
41 | 41 |
42 // BookmarkModelObserver: | 42 // BookmarkModelObserver: |
43 virtual void BookmarkModelLoaded(BookmarkModel* model, | 43 void BookmarkModelLoaded(BookmarkModel* model, bool ids_reassigned) override; |
44 bool ids_reassigned) override; | 44 void BookmarkModelBeingDeleted(BookmarkModel* model) override; |
45 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) override; | 45 void BookmarkNodeMoved(BookmarkModel* model, |
46 virtual void BookmarkNodeMoved(BookmarkModel* model, | 46 const BookmarkNode* old_parent, |
47 const BookmarkNode* old_parent, | 47 int old_index, |
48 int old_index, | 48 const BookmarkNode* new_parent, |
49 const BookmarkNode* new_parent, | 49 int new_index) override; |
50 int new_index) override; | 50 void BookmarkNodeAdded(BookmarkModel* model, |
51 virtual void BookmarkNodeAdded(BookmarkModel* model, | 51 const BookmarkNode* parent, |
52 const BookmarkNode* parent, | 52 int index) override; |
53 int index) override; | 53 void BookmarkNodeRemoved(BookmarkModel* model, |
54 virtual void BookmarkNodeRemoved(BookmarkModel* model, | 54 const BookmarkNode* parent, |
55 const BookmarkNode* parent, | 55 int old_index, |
56 int old_index, | 56 const BookmarkNode* node, |
57 const BookmarkNode* node, | 57 const std::set<GURL>& removed_urls) override; |
| 58 void BookmarkAllUserNodesRemoved(BookmarkModel* model, |
58 const std::set<GURL>& removed_urls) override; | 59 const std::set<GURL>& removed_urls) override; |
59 virtual void BookmarkAllUserNodesRemoved( | 60 void BookmarkNodeChanged(BookmarkModel* model, |
60 BookmarkModel* model, | 61 const BookmarkNode* node) override; |
61 const std::set<GURL>& removed_urls) override; | 62 void BookmarkNodeFaviconChanged(BookmarkModel* model, |
62 virtual void BookmarkNodeChanged(BookmarkModel* model, | 63 const BookmarkNode* node) override; |
63 const BookmarkNode* node) override; | 64 void BookmarkNodeChildrenReordered(BookmarkModel* model, |
64 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model, | 65 const BookmarkNode* node) override; |
65 const BookmarkNode* node) override; | |
66 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, | |
67 const BookmarkNode* node) override; | |
68 | 66 |
69 // MainMenuItem: | 67 // MainMenuItem: |
70 virtual void ResetMenu() override; | 68 void ResetMenu() override; |
71 virtual void BuildMenu() override; | 69 void BuildMenu() override; |
72 | 70 |
73 // Rebuilds the main bookmark menu, if it has been marked invalid. | 71 // Rebuilds the main bookmark menu, if it has been marked invalid. |
74 void UpdateMenu(NSMenu* bookmark_menu); | 72 void UpdateMenu(NSMenu* bookmark_menu); |
75 | 73 |
76 // Rebuilds a bookmark menu that's a submenu of another menu. | 74 // Rebuilds a bookmark menu that's a submenu of another menu. |
77 void UpdateSubMenu(NSMenu* bookmark_menu); | 75 void UpdateSubMenu(NSMenu* bookmark_menu); |
78 | 76 |
79 // I wish I had a "friend @class" construct. | 77 // I wish I had a "friend @class" construct. |
80 BookmarkModel* GetBookmarkModel(); | 78 BookmarkModel* GetBookmarkModel(); |
81 Profile* GetProfile(); | 79 Profile* GetProfile(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 143 |
146 // The folder image so we can use one copy for all. | 144 // The folder image so we can use one copy for all. |
147 base::scoped_nsobject<NSImage> folder_image_; | 145 base::scoped_nsobject<NSImage> folder_image_; |
148 | 146 |
149 // In order to appropriately update items in the bookmark menu, without | 147 // In order to appropriately update items in the bookmark menu, without |
150 // forcing a rebuild, map the model's nodes to menu items. | 148 // forcing a rebuild, map the model's nodes to menu items. |
151 std::map<const BookmarkNode*, NSMenuItem*> bookmark_nodes_; | 149 std::map<const BookmarkNode*, NSMenuItem*> bookmark_nodes_; |
152 }; | 150 }; |
153 | 151 |
154 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_BRIDGE_H_ | 152 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_BRIDGE_H_ |
OLD | NEW |