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