Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / chrome / browser / ui / bookmarks / recently_used_folders_combo_model.h
blob9f32decd106c9baf738b0fa393fd6c62ceadd6ad
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_
6 #define CHROME_BROWSER_UI_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/observer_list.h"
13 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
14 #include "ui/base/models/combobox_model.h"
16 class BookmarkModel;
17 class BookmarkNode;
19 // Model for the combobox showing the list of folders to choose from. The
20 // list always contains the Bookmarks Bar, Other Bookmarks and the parent
21 // folder. The list also contains an extra item that shows the text
22 // "Choose Another Folder...".
23 class RecentlyUsedFoldersComboModel : public ui::ComboboxModel,
24 public BookmarkModelObserver {
25 public:
26 RecentlyUsedFoldersComboModel(BookmarkModel* model, const BookmarkNode* node);
27 virtual ~RecentlyUsedFoldersComboModel();
29 // Overridden from ui::ComboboxModel:
30 virtual int GetItemCount() const OVERRIDE;
31 virtual base::string16 GetItemAt(int index) OVERRIDE;
32 virtual bool IsItemSeparatorAt(int index) OVERRIDE;
33 virtual int GetDefaultIndex() const OVERRIDE;
34 virtual void AddObserver(ui::ComboboxModelObserver* observer) OVERRIDE;
35 virtual void RemoveObserver(ui::ComboboxModelObserver* observer) OVERRIDE;
37 // Overriden from BookmarkModelObserver:
38 virtual void BookmarkModelLoaded(BookmarkModel* model,
39 bool ids_reassigned) OVERRIDE;
40 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE;
41 virtual void BookmarkNodeMoved(BookmarkModel* model,
42 const BookmarkNode* old_parent,
43 int old_index,
44 const BookmarkNode* new_parent,
45 int new_index) OVERRIDE;
46 virtual void BookmarkNodeAdded(BookmarkModel* model,
47 const BookmarkNode* parent,
48 int index) OVERRIDE;
49 virtual void OnWillRemoveBookmarks(BookmarkModel* model,
50 const BookmarkNode* parent,
51 int old_index,
52 const BookmarkNode* node) OVERRIDE;
53 virtual void BookmarkNodeRemoved(BookmarkModel* model,
54 const BookmarkNode* parent,
55 int old_index,
56 const BookmarkNode* node) OVERRIDE;
57 virtual void BookmarkNodeChanged(BookmarkModel* model,
58 const BookmarkNode* node) OVERRIDE;
59 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
60 const BookmarkNode* node) OVERRIDE;
61 virtual void BookmarkNodeChildrenReordered(
62 BookmarkModel* model,
63 const BookmarkNode* node) OVERRIDE;
64 virtual void BookmarkAllNodesRemoved(BookmarkModel* model) OVERRIDE;
66 // If necessary this function moves |node| into the corresponding folder for
67 // the given |selected_index|.
68 void MaybeChangeParent(const BookmarkNode* node, int selected_index);
70 private:
71 // Returns the node at the specified |index|.
72 const BookmarkNode* GetNodeAt(int index);
74 // Removes |node| from |items_|. Does nothing if |node| is not in |items_|.
75 void RemoveNode(const BookmarkNode* node);
77 struct Item;
78 std::vector<Item> items_;
80 BookmarkModel* bookmark_model_;
82 // The index of the original parent folder.
83 int node_parent_index_;
85 ObserverList<ui::ComboboxModelObserver> observers_;
87 DISALLOW_COPY_AND_ASSIGN(RecentlyUsedFoldersComboModel);
90 #endif // CHROME_BROWSER_UI_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_