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_CUSTOM_HOME_PAGES_TABLE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_CUSTOM_HOME_PAGES_TABLE_MODEL_H_ |
6 #define CHROME_BROWSER_CUSTOM_HOME_PAGES_TABLE_MODEL_H_ | 6 #define CHROME_BROWSER_CUSTOM_HOME_PAGES_TABLE_MODEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 namespace ui { | 24 namespace ui { |
25 class TableModelObserver; | 25 class TableModelObserver; |
26 } | 26 } |
27 | 27 |
28 // CustomHomePagesTableModel is the model for the TableView showing the list | 28 // CustomHomePagesTableModel is the model for the TableView showing the list |
29 // of pages the user wants opened on startup. | 29 // of pages the user wants opened on startup. |
30 | 30 |
31 class CustomHomePagesTableModel : public ui::TableModel { | 31 class CustomHomePagesTableModel : public ui::TableModel { |
32 public: | 32 public: |
33 explicit CustomHomePagesTableModel(Profile* profile); | 33 explicit CustomHomePagesTableModel(Profile* profile); |
34 virtual ~CustomHomePagesTableModel(); | 34 ~CustomHomePagesTableModel() override; |
35 | 35 |
36 // Sets the set of urls that this model contains. | 36 // Sets the set of urls that this model contains. |
37 void SetURLs(const std::vector<GURL>& urls); | 37 void SetURLs(const std::vector<GURL>& urls); |
38 | 38 |
39 // Collect all entries indexed by |index_list|, and moves them to be right | 39 // Collect all entries indexed by |index_list|, and moves them to be right |
40 // before the element addressed by |insert_before|. Used by Drag&Drop. | 40 // before the element addressed by |insert_before|. Used by Drag&Drop. |
41 // Expects |index_list| to be ordered ascending. | 41 // Expects |index_list| to be ordered ascending. |
42 void MoveURLs(int insert_before, const std::vector<int>& index_list); | 42 void MoveURLs(int insert_before, const std::vector<int>& index_list); |
43 | 43 |
44 // Adds an entry at the specified index. | 44 // Adds an entry at the specified index. |
45 void Add(int index, const GURL& url); | 45 void Add(int index, const GURL& url); |
46 | 46 |
47 // Removes the entry at the specified index. | 47 // Removes the entry at the specified index. |
48 void Remove(int index); | 48 void Remove(int index); |
49 | 49 |
50 // Clears any entries and fills the list with pages currently opened in the | 50 // Clears any entries and fills the list with pages currently opened in the |
51 // browser. | 51 // browser. |
52 void SetToCurrentlyOpenPages(); | 52 void SetToCurrentlyOpenPages(); |
53 | 53 |
54 // Returns the set of urls this model contains. | 54 // Returns the set of urls this model contains. |
55 std::vector<GURL> GetURLs(); | 55 std::vector<GURL> GetURLs(); |
56 | 56 |
57 // TableModel overrides: | 57 // TableModel overrides: |
58 virtual int RowCount() override; | 58 int RowCount() override; |
59 virtual base::string16 GetText(int row, int column_id) override; | 59 base::string16 GetText(int row, int column_id) override; |
60 virtual base::string16 GetTooltip(int row) override; | 60 base::string16 GetTooltip(int row) override; |
61 virtual void SetObserver(ui::TableModelObserver* observer) override; | 61 void SetObserver(ui::TableModelObserver* observer) override; |
62 | 62 |
63 private: | 63 private: |
64 // Each item in the model is represented as an Entry. Entry stores the URL | 64 // Each item in the model is represented as an Entry. Entry stores the URL |
65 // and title of the page. | 65 // and title of the page. |
66 struct Entry; | 66 struct Entry; |
67 | 67 |
68 // Loads the title for the specified entry. | 68 // Loads the title for the specified entry. |
69 void LoadTitle(Entry* entry); | 69 void LoadTitle(Entry* entry); |
70 | 70 |
71 // Callback from history service. Updates the title of the Entry whose | 71 // Callback from history service. Updates the title of the Entry whose |
(...skipping 14 matching lines...) Expand all Loading... |
86 | 86 |
87 ui::TableModelObserver* observer_; | 87 ui::TableModelObserver* observer_; |
88 | 88 |
89 // Used in loading titles. | 89 // Used in loading titles. |
90 base::CancelableTaskTracker task_tracker_; | 90 base::CancelableTaskTracker task_tracker_; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(CustomHomePagesTableModel); | 92 DISALLOW_COPY_AND_ASSIGN(CustomHomePagesTableModel); |
93 }; | 93 }; |
94 | 94 |
95 #endif // CHROME_BROWSER_CUSTOM_HOME_PAGES_TABLE_MODEL_H_ | 95 #endif // CHROME_BROWSER_CUSTOM_HOME_PAGES_TABLE_MODEL_H_ |
OLD | NEW |