Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: chrome/browser/bookmarks/bookmark_folder_tree_model.h

Issue 1730015: Windows/Views: delete native bookmark manager code. (Closed)
Patch Set: Patch with fixed file perms. Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_FOLDER_TREE_MODEL_H_
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_FOLDER_TREE_MODEL_H_
7
8 #include <vector>
9
10 #include "app/tree_node_model.h"
11 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
12
13 // The type of nodes created by BookmarkFolderTreeModel.
14 typedef TreeNodeWithValue<const BookmarkNode*> FolderNode;
15
16 // TreeModel implementation that shows the folders from the BookmarkModel.
17 // The root node contains the following nodes:
18 // bookmark bar, other folders, recently bookmarked and search.
19 class BookmarkFolderTreeModel : public TreeNodeModel<FolderNode>,
20 public BookmarkModelObserver {
21 public:
22 // Type of the node.
23 enum NodeType {
24 // Represents an entry from the BookmarkModel.
25 BOOKMARK,
26 RECENTLY_BOOKMARKED,
27 SEARCH,
28 NONE // Used for no selection.
29 };
30
31 explicit BookmarkFolderTreeModel(BookmarkModel* model);
32 ~BookmarkFolderTreeModel();
33
34 // The tree is not editable.
35 virtual void SetTitle(TreeModelNode* node, const std::wstring& title) {
36 NOTREACHED();
37 }
38
39 // Returns the type of the specified node.
40 NodeType GetNodeType(TreeModelNode* node);
41
42 // Returns the FolderNode for the specified BookmarkNode.
43 FolderNode* GetFolderNodeForBookmarkNode(const BookmarkNode* node);
44
45 // Converts the tree node into a BookmarkNode. Returns NULL if |node| is NULL
46 // or not of NodeType::BOOKMARK.
47 const BookmarkNode* TreeNodeAsBookmarkNode(TreeModelNode* node);
48
49 // Returns the search node.
50 FolderNode* search_node() const { return search_node_; }
51
52 // BookmarkModelObserver implementation.
53 virtual void Loaded(BookmarkModel* model);
54 virtual void BookmarkModelBeingDeleted(BookmarkModel* model);
55 virtual void BookmarkNodeMoved(BookmarkModel* model,
56 const BookmarkNode* old_parent,
57 int old_index,
58 const BookmarkNode* new_parent,
59 int new_index);
60 virtual void BookmarkNodeAdded(BookmarkModel* model,
61 const BookmarkNode* parent,
62 int index);
63 virtual void BookmarkNodeRemoved(BookmarkModel* model,
64 const BookmarkNode* parent,
65 int index,
66 const BookmarkNode* node);
67 virtual void BookmarkNodeChanged(BookmarkModel* model,
68 const BookmarkNode* node);
69 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
70 const BookmarkNode* node);
71 // Folders don't have favicons, so we ignore this.
72 virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
73 const BookmarkNode* node) {}
74
75 // The following are overriden to return custom icons for the recently
76 // bookmarked and search nodes.
77 virtual void GetIcons(std::vector<SkBitmap>* icons);
78 virtual int GetIconIndex(TreeModelNode* node);
79
80 private:
81 // Invoked from the constructor to create the children of the root node.
82 void AddRootChildren();
83
84 // Implementation of GetFolderNodeForBookmarkNode. If the |folder_node|
85 // represents |node|, |folder_node| is returned, otherwise this recurses
86 // through the children.
87 FolderNode* GetFolderNodeForBookmarkNode(FolderNode* folder_node,
88 const BookmarkNode* node);
89
90 // Creates a new folder node for |node| and all its children.
91 FolderNode* CreateFolderNode(const BookmarkNode* node);
92
93 // Returns the number of folders that precede |node| in |node|s parent.
94 // The returned value is the index of the folder node representing |node|
95 // in its parent.
96 // This is used when new bookmarks are created to determine where the
97 // corresponding folder node should be created.
98 int CalculateIndexForChild(const BookmarkNode* node);
99
100 // The model we're getting data from. Owned by the Profile.
101 BookmarkModel* model_;
102
103 // The two special nodes. These are owned by the root tree node owned by
104 // TreeNodeModel.
105 FolderNode* recently_bookmarked_node_;
106 FolderNode* search_node_;
107
108 DISALLOW_COPY_AND_ASSIGN(BookmarkFolderTreeModel);
109 };
110
111 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_FOLDER_TREE_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_folder_editor_controller.cc ('k') | chrome/browser/bookmarks/bookmark_folder_tree_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698