| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_VIEWS_KEYWORD_EDITOR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_KEYWORD_EDITOR_VIEW_H_ |
| 6 #define CHROME_BROWSER_VIEWS_KEYWORD_EDITOR_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_KEYWORD_EDITOR_VIEW_H_ |
| 7 | 7 |
| 8 #include <Windows.h> | 8 #include <Windows.h> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "app/table_model.h" |
| 11 #include "chrome/browser/search_engines/template_url_model.h" | 12 #include "chrome/browser/search_engines/template_url_model.h" |
| 12 #include "views/controls/button/button.h" | 13 #include "views/controls/button/button.h" |
| 13 #include "views/controls/table/table_model.h" | |
| 14 #include "views/controls/table/table_view_observer.h" | 14 #include "views/controls/table/table_view_observer.h" |
| 15 #include "views/view.h" | 15 #include "views/view.h" |
| 16 #include "views/window/dialog_delegate.h" | 16 #include "views/window/dialog_delegate.h" |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 class Label; | 19 class Label; |
| 20 class NativeButton; | 20 class NativeButton; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 class BorderView; | 24 class BorderView; |
| 25 } | 25 } |
| 26 | 26 |
| 27 class ModelEntry; | 27 class ModelEntry; |
| 28 class SkBitmap; | 28 class SkBitmap; |
| 29 class TemplateURLModel; | 29 class TemplateURLModel; |
| 30 class TemplateURLTableModel; | 30 class TemplateURLTableModel; |
| 31 | 31 |
| 32 // TemplateURLTableModel is the TableModel implementation used by | 32 // TemplateURLTableModel is the TableModel implementation used by |
| 33 // KeywordEditorView to show the keywords in a TableView. | 33 // KeywordEditorView to show the keywords in a TableView. |
| 34 // | 34 // |
| 35 // TemplateURLTableModel has two columns, the first showing the description, | 35 // TemplateURLTableModel has two columns, the first showing the description, |
| 36 // the second the keyword. | 36 // the second the keyword. |
| 37 // | 37 // |
| 38 // TemplateURLTableModel maintains a vector of ModelEntrys that correspond to | 38 // TemplateURLTableModel maintains a vector of ModelEntrys that correspond to |
| 39 // each row in the tableview. Each ModelEntry wraps a TemplateURL, providing | 39 // each row in the tableview. Each ModelEntry wraps a TemplateURL, providing |
| 40 // the favicon. The entries in the model are sorted such that non-generated | 40 // the favicon. The entries in the model are sorted such that non-generated |
| 41 // appear first (grouped together) and are followed by generated keywords. | 41 // appear first (grouped together) and are followed by generated keywords. |
| 42 | 42 |
| 43 class TemplateURLTableModel : public views::TableModel { | 43 class TemplateURLTableModel : public TableModel { |
| 44 public: | 44 public: |
| 45 explicit TemplateURLTableModel(TemplateURLModel* template_url_model); | 45 explicit TemplateURLTableModel(TemplateURLModel* template_url_model); |
| 46 | 46 |
| 47 virtual ~TemplateURLTableModel(); | 47 virtual ~TemplateURLTableModel(); |
| 48 | 48 |
| 49 // Reloads the entries from the TemplateURLModel. This should ONLY be invoked | 49 // Reloads the entries from the TemplateURLModel. This should ONLY be invoked |
| 50 // if the TemplateURLModel wasn't initially loaded and has been loaded. | 50 // if the TemplateURLModel wasn't initially loaded and has been loaded. |
| 51 void Reload(); | 51 void Reload(); |
| 52 | 52 |
| 53 // TableModel overrides. | 53 // TableModel overrides. |
| 54 virtual int RowCount(); | 54 virtual int RowCount(); |
| 55 virtual std::wstring GetText(int row, int column); | 55 virtual std::wstring GetText(int row, int column); |
| 56 virtual SkBitmap GetIcon(int row); | 56 virtual SkBitmap GetIcon(int row); |
| 57 virtual void SetObserver(views::TableModelObserver* observer); | 57 virtual void SetObserver(TableModelObserver* observer); |
| 58 virtual bool HasGroups(); | 58 virtual bool HasGroups(); |
| 59 virtual Groups GetGroups(); | 59 virtual Groups GetGroups(); |
| 60 virtual int GetGroupID(int row); | 60 virtual int GetGroupID(int row); |
| 61 | 61 |
| 62 // Removes the entry at the specified index. This does NOT propagate the | 62 // Removes the entry at the specified index. This does NOT propagate the |
| 63 // change to the backend. | 63 // change to the backend. |
| 64 void Remove(int index); | 64 void Remove(int index); |
| 65 | 65 |
| 66 // Adds a new entry at the specified index. This does not propagate the | 66 // Adds a new entry at the specified index. This does not propagate the |
| 67 // change to the backend. | 67 // change to the backend. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 89 | 89 |
| 90 // Returns the index of the last entry shown in the search engines group. | 90 // Returns the index of the last entry shown in the search engines group. |
| 91 int last_search_engine_index() const { return last_search_engine_index_; } | 91 int last_search_engine_index() const { return last_search_engine_index_; } |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 friend class ModelEntry; | 94 friend class ModelEntry; |
| 95 | 95 |
| 96 // Notification that a model entry has fetched its icon. | 96 // Notification that a model entry has fetched its icon. |
| 97 void FavIconAvailable(ModelEntry* entry); | 97 void FavIconAvailable(ModelEntry* entry); |
| 98 | 98 |
| 99 views::TableModelObserver* observer_; | 99 TableModelObserver* observer_; |
| 100 | 100 |
| 101 // The entries. | 101 // The entries. |
| 102 std::vector<ModelEntry*> entries_; | 102 std::vector<ModelEntry*> entries_; |
| 103 | 103 |
| 104 // The model we're displaying entries from. | 104 // The model we're displaying entries from. |
| 105 TemplateURLModel* template_url_model_; | 105 TemplateURLModel* template_url_model_; |
| 106 | 106 |
| 107 // Index of the last search engine in entries_. This is used to determine the | 107 // Index of the last search engine in entries_. This is used to determine the |
| 108 // group boundaries. | 108 // group boundaries. |
| 109 int last_search_engine_index_; | 109 int last_search_engine_index_; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 views::TableView* table_view_; | 196 views::TableView* table_view_; |
| 197 views::NativeButton* add_button_; | 197 views::NativeButton* add_button_; |
| 198 views::NativeButton* edit_button_; | 198 views::NativeButton* edit_button_; |
| 199 views::NativeButton* remove_button_; | 199 views::NativeButton* remove_button_; |
| 200 views::NativeButton* make_default_button_; | 200 views::NativeButton* make_default_button_; |
| 201 | 201 |
| 202 DISALLOW_COPY_AND_ASSIGN(KeywordEditorView); | 202 DISALLOW_COPY_AND_ASSIGN(KeywordEditorView); |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 #endif // CHROME_BROWSER_VIEWS_KEYWORD_EDITOR_VIEW_H_ | 205 #endif // CHROME_BROWSER_VIEWS_KEYWORD_EDITOR_VIEW_H_ |
| OLD | NEW |