| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "chrome/browser/search_engines/template_url_service_observer.h" | 14 #include "chrome/browser/search_engines/template_url_service_observer.h" |
| 15 #include "ui/base/models/table_model.h" | 15 #include "ui/base/models/table_model.h" |
| 16 | 16 |
| 17 class ModelEntry; | 17 class ModelEntry; |
| 18 class SkBitmap; | 18 class SkBitmap; |
| 19 class TemplateURL; | 19 class TemplateURL; |
| 20 class TemplateURLService; | 20 class TemplateURLService; |
| 21 | 21 |
| 22 namespace gfx { |
| 23 class ImageSkia; |
| 24 } |
| 25 |
| 22 // TemplateURLTableModel is the TableModel implementation used by | 26 // TemplateURLTableModel is the TableModel implementation used by |
| 23 // KeywordEditorView to show the keywords in a TableView. | 27 // KeywordEditorView to show the keywords in a TableView. |
| 24 // | 28 // |
| 25 // TemplateURLTableModel has two columns, the first showing the description, | 29 // TemplateURLTableModel has two columns, the first showing the description, |
| 26 // the second the keyword. | 30 // the second the keyword. |
| 27 // | 31 // |
| 28 // TemplateURLTableModel maintains a vector of ModelEntrys that correspond to | 32 // TemplateURLTableModel maintains a vector of ModelEntrys that correspond to |
| 29 // each row in the tableview. Each ModelEntry wraps a TemplateURL, providing | 33 // each row in the tableview. Each ModelEntry wraps a TemplateURL, providing |
| 30 // the favicon. The entries in the model are sorted such that non-generated | 34 // the favicon. The entries in the model are sorted such that non-generated |
| 31 // appear first (grouped together) and are followed by generated keywords. | 35 // appear first (grouped together) and are followed by generated keywords. |
| 32 | 36 |
| 33 class TemplateURLTableModel : public ui::TableModel, | 37 class TemplateURLTableModel : public ui::TableModel, |
| 34 TemplateURLServiceObserver { | 38 TemplateURLServiceObserver { |
| 35 public: | 39 public: |
| 36 explicit TemplateURLTableModel(TemplateURLService* template_url_service); | 40 explicit TemplateURLTableModel(TemplateURLService* template_url_service); |
| 37 | 41 |
| 38 virtual ~TemplateURLTableModel(); | 42 virtual ~TemplateURLTableModel(); |
| 39 | 43 |
| 40 // Reloads the entries from the TemplateURLService. This should ONLY be | 44 // Reloads the entries from the TemplateURLService. This should ONLY be |
| 41 // invoked if the TemplateURLService wasn't initially loaded and has been | 45 // invoked if the TemplateURLService wasn't initially loaded and has been |
| 42 // loaded. | 46 // loaded. |
| 43 void Reload(); | 47 void Reload(); |
| 44 | 48 |
| 45 // ui::TableModel overrides. | 49 // ui::TableModel overrides. |
| 46 virtual int RowCount() OVERRIDE; | 50 virtual int RowCount() OVERRIDE; |
| 47 virtual string16 GetText(int row, int column) OVERRIDE; | 51 virtual string16 GetText(int row, int column) OVERRIDE; |
| 48 virtual SkBitmap GetIcon(int row) OVERRIDE; | 52 virtual gfx::ImageSkia GetIcon(int row) OVERRIDE; |
| 49 virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; | 53 virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; |
| 50 virtual bool HasGroups() OVERRIDE; | 54 virtual bool HasGroups() OVERRIDE; |
| 51 virtual Groups GetGroups() OVERRIDE; | 55 virtual Groups GetGroups() OVERRIDE; |
| 52 virtual int GetGroupID(int row) OVERRIDE; | 56 virtual int GetGroupID(int row) OVERRIDE; |
| 53 | 57 |
| 54 // Removes the entry at the specified index. | 58 // Removes the entry at the specified index. |
| 55 void Remove(int index); | 59 void Remove(int index); |
| 56 | 60 |
| 57 // Adds a new entry at the specified index. | 61 // Adds a new entry at the specified index. |
| 58 void Add(int index, | 62 void Add(int index, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 118 |
| 115 // Index of the last search engine in entries_. This is used to determine the | 119 // Index of the last search engine in entries_. This is used to determine the |
| 116 // group boundaries. | 120 // group boundaries. |
| 117 int last_search_engine_index_; | 121 int last_search_engine_index_; |
| 118 | 122 |
| 119 DISALLOW_COPY_AND_ASSIGN(TemplateURLTableModel); | 123 DISALLOW_COPY_AND_ASSIGN(TemplateURLTableModel); |
| 120 }; | 124 }; |
| 121 | 125 |
| 122 | 126 |
| 123 #endif // CHROME_BROWSER_UI_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_ | 127 #endif // CHROME_BROWSER_UI_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_ |
| OLD | NEW |