1// Copyright (c) 2009 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_LANGUAGE_ORDER_TABLE_MODEL_H_
6#define CHROME_BROWSER_LANGUAGE_ORDER_TABLE_MODEL_H_
7#pragma once
8
9#include <string>
10#include <vector>
11
12#include "base/basictypes.h"
13#include "base/compiler_specific.h"
14#include "ui/base/models/table_model.h"
15
16namespace ui {
17class TableModelObserver;
18}
19
20class LanguageOrderTableModel : public ui::TableModel {
21 public:
22  LanguageOrderTableModel();
23
24  virtual ~LanguageOrderTableModel();
25
26  // Set Language List.
27  void SetAcceptLanguagesString(const std::string& language_list);
28
29  // Add at the end.  Return true if the language was added.
30  bool Add(const std::string& language);
31
32  // Removes the entry at the specified index.
33  void Remove(int index);
34
35  // Returns index corresponding to a given language. Returns -1 if the
36  // language is not found.
37  int GetIndex(const std::string& language);
38
39  // Move down the entry at the specified index.
40  void MoveDown(int index);
41
42  // Move up the entry at the specified index.
43  void MoveUp(int index);
44
45  // Returns the set of languagess this model contains.
46  std::string GetLanguageList();
47
48  // TableModel overrides:
49  virtual int RowCount() OVERRIDE;
50  virtual string16 GetText(int row, int column_id) OVERRIDE;
51  virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE;
52
53 private:
54  // Set of entries we're showing.
55  std::vector<std::string> languages_;
56  std::string comma_separated_language_list_;
57
58  ui::TableModelObserver* observer_;
59
60  DISALLOW_COPY_AND_ASSIGN(LanguageOrderTableModel);
61};
62
63#endif  // CHROME_BROWSER_LANGUAGE_ORDER_TABLE_MODEL_H_
64