summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks/recently_used_folders_combo_model.h
blob: b405899afec4000e756fa73b0fcd43d20fe6f99a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_
#define CHROME_BROWSER_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_
#pragma once

#include <vector>

#include "base/string16.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "ui/base/models/combobox_model.h"

// Model for the combobox showing the list of folders to choose from. The
// list always contains the bookmark bar, other node and parent. The list
// also contains an extra item that shows the text 'Choose another folder...'.
class RecentlyUsedFoldersComboModel : public ui::ComboboxModel {
 public:
  RecentlyUsedFoldersComboModel(BookmarkModel* model, const BookmarkNode* node);
  virtual ~RecentlyUsedFoldersComboModel();

  // Overridden from ui::ComboboxModel:
  virtual int GetItemCount();
  virtual string16 GetItemAt(int index);

  // Returns the node at the specified |index|.
  const BookmarkNode* GetNodeAt(int index);

  // Returns the index of the original parent folder.
  int node_parent_index() const { return node_parent_index_; }

 private:
  // Removes |node| from |nodes_|. Does nothing if |node| is not in |nodes_|.
  void RemoveNode(const BookmarkNode* node);

  std::vector<const BookmarkNode*> nodes_;
  int node_parent_index_;

  DISALLOW_COPY_AND_ASSIGN(RecentlyUsedFoldersComboModel);
};

#endif  // CHROME_BROWSER_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_