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_UI_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_ |
6 #define CHROME_BROWSER_UI_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_ | 6 #define CHROME_BROWSER_UI_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 // each row in the tableview. Each ModelEntry wraps a TemplateURL, providing | 32 // each row in the tableview. Each ModelEntry wraps a TemplateURL, providing |
33 // the favicon. The entries in the model are sorted such that non-generated | 33 // the favicon. The entries in the model are sorted such that non-generated |
34 // appear first (grouped together) and are followed by generated keywords. | 34 // appear first (grouped together) and are followed by generated keywords. |
35 | 35 |
36 class TemplateURLTableModel : public ui::TableModel, | 36 class TemplateURLTableModel : public ui::TableModel, |
37 TemplateURLServiceObserver { | 37 TemplateURLServiceObserver { |
38 public: | 38 public: |
39 TemplateURLTableModel(TemplateURLService* template_url_service, | 39 TemplateURLTableModel(TemplateURLService* template_url_service, |
40 FaviconService* favicon_service); | 40 FaviconService* favicon_service); |
41 | 41 |
42 virtual ~TemplateURLTableModel(); | 42 ~TemplateURLTableModel() override; |
43 | 43 |
44 // Reloads the entries from the TemplateURLService. This should ONLY be | 44 // Reloads the entries from the TemplateURLService. This should ONLY be |
45 // invoked if the TemplateURLService wasn't initially loaded and has been | 45 // invoked if the TemplateURLService wasn't initially loaded and has been |
46 // loaded. | 46 // loaded. |
47 void Reload(); | 47 void Reload(); |
48 | 48 |
49 // ui::TableModel overrides. | 49 // ui::TableModel overrides. |
50 virtual int RowCount() override; | 50 int RowCount() override; |
51 virtual base::string16 GetText(int row, int column) override; | 51 base::string16 GetText(int row, int column) override; |
52 virtual gfx::ImageSkia GetIcon(int row) override; | 52 gfx::ImageSkia GetIcon(int row) override; |
53 virtual void SetObserver(ui::TableModelObserver* observer) override; | 53 void SetObserver(ui::TableModelObserver* observer) override; |
54 virtual bool HasGroups() override; | 54 bool HasGroups() override; |
55 virtual Groups GetGroups() override; | 55 Groups GetGroups() override; |
56 virtual int GetGroupID(int row) override; | 56 int GetGroupID(int row) override; |
57 | 57 |
58 // Removes the entry at the specified index. | 58 // Removes the entry at the specified index. |
59 void Remove(int index); | 59 void Remove(int index); |
60 | 60 |
61 // Adds a new entry at the specified index. | 61 // Adds a new entry at the specified index. |
62 void Add(int index, | 62 void Add(int index, |
63 const base::string16& short_name, | 63 const base::string16& short_name, |
64 const base::string16& keyword, | 64 const base::string16& keyword, |
65 const std::string& url); | 65 const std::string& url); |
66 | 66 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // group. | 99 // group. |
100 int last_other_engine_index() const { return last_other_engine_index_; } | 100 int last_other_engine_index() const { return last_other_engine_index_; } |
101 | 101 |
102 private: | 102 private: |
103 class ModelEntry; | 103 class ModelEntry; |
104 | 104 |
105 // Notification that a model entry has fetched its icon. | 105 // Notification that a model entry has fetched its icon. |
106 void FaviconAvailable(ModelEntry* entry); | 106 void FaviconAvailable(ModelEntry* entry); |
107 | 107 |
108 // TemplateURLServiceObserver notification. | 108 // TemplateURLServiceObserver notification. |
109 virtual void OnTemplateURLServiceChanged() override; | 109 void OnTemplateURLServiceChanged() override; |
110 | 110 |
111 // Removes the entry at |index| from |entries_| and returns the removed item. | 111 // Removes the entry at |index| from |entries_| and returns the removed item. |
112 scoped_ptr<ModelEntry> RemoveEntry(int index); | 112 scoped_ptr<ModelEntry> RemoveEntry(int index); |
113 | 113 |
114 // Adds |entry| to |entries_| at |index| and takes ownership. | 114 // Adds |entry| to |entries_| at |index| and takes ownership. |
115 void AddEntry(int index, scoped_ptr<ModelEntry> entry); | 115 void AddEntry(int index, scoped_ptr<ModelEntry> entry); |
116 | 116 |
117 ui::TableModelObserver* observer_; | 117 ui::TableModelObserver* observer_; |
118 | 118 |
119 // The entries. | 119 // The entries. |
(...skipping 10 matching lines...) Expand all Loading... |
130 | 130 |
131 // Index of the last other engine in entries_. This is used to determine the | 131 // Index of the last other engine in entries_. This is used to determine the |
132 // group boundaries. | 132 // group boundaries. |
133 int last_other_engine_index_; | 133 int last_other_engine_index_; |
134 | 134 |
135 DISALLOW_COPY_AND_ASSIGN(TemplateURLTableModel); | 135 DISALLOW_COPY_AND_ASSIGN(TemplateURLTableModel); |
136 }; | 136 }; |
137 | 137 |
138 | 138 |
139 #endif // CHROME_BROWSER_UI_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_ | 139 #endif // CHROME_BROWSER_UI_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_ |
OLD | NEW |