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 #ifndef CHROME_BROWSER_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ |
6 #define CHROME_BROWSER_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "ui/base/models/combobox_model.h" | 12 #include "ui/base/models/combobox_model.h" |
13 | 13 |
14 class BookmarkModel; | 14 class BookmarkModel; |
15 class BookmarkNode; | 15 class BookmarkNode; |
16 | 16 |
17 // Model for the combobox showing the list of folders to choose from. The | 17 // Model for the combobox showing the list of folders to choose from. The |
18 // list always contains the bookmark bar, other node and parent. The list | 18 // list always contains the bookmark bar, other node and parent. The list |
19 // also contains an extra item that shows the text 'Choose another folder...'. | 19 // also contains an extra item that shows the text 'Choose another folder...'. |
20 class RecentlyUsedFoldersComboModel : public ui::ComboboxModel { | 20 class RecentlyUsedFoldersComboModel : public ui::ComboboxModel { |
21 public: | 21 public: |
22 RecentlyUsedFoldersComboModel(BookmarkModel* model, const BookmarkNode* node); | 22 RecentlyUsedFoldersComboModel(BookmarkModel* model, const BookmarkNode* node); |
23 virtual ~RecentlyUsedFoldersComboModel(); | 23 virtual ~RecentlyUsedFoldersComboModel(); |
24 | 24 |
25 // Overridden from ui::ComboboxModel: | 25 // Overridden from ui::ComboboxModel: |
26 virtual int GetItemCount() const OVERRIDE; | 26 virtual int GetItemCount() const OVERRIDE; |
27 virtual string16 GetItemAt(int index) OVERRIDE; | 27 virtual string16 GetItemAt(int index) OVERRIDE; |
| 28 virtual int GetDefaultIndex() const OVERRIDE; |
28 | 29 |
29 // Returns the node at the specified |index|. | 30 // Returns the node at the specified |index|. |
30 const BookmarkNode* GetNodeAt(int index); | 31 const BookmarkNode* GetNodeAt(int index); |
31 | 32 |
32 // Returns the index of the original parent folder. | |
33 int node_parent_index() const { return node_parent_index_; } | |
34 | |
35 private: | 33 private: |
36 // Removes |node| from |nodes_|. Does nothing if |node| is not in |nodes_|. | 34 // Removes |node| from |nodes_|. Does nothing if |node| is not in |nodes_|. |
37 void RemoveNode(const BookmarkNode* node); | 35 void RemoveNode(const BookmarkNode* node); |
38 | 36 |
39 std::vector<const BookmarkNode*> nodes_; | 37 std::vector<const BookmarkNode*> nodes_; |
| 38 |
| 39 // The index of the original parent folder. |
40 int node_parent_index_; | 40 int node_parent_index_; |
41 | 41 |
42 DISALLOW_COPY_AND_ASSIGN(RecentlyUsedFoldersComboModel); | 42 DISALLOW_COPY_AND_ASSIGN(RecentlyUsedFoldersComboModel); |
43 }; | 43 }; |
44 | 44 |
45 #endif // CHROME_BROWSER_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ | 45 #endif // CHROME_BROWSER_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ |
OLD | NEW |