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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 // Clears any entries and fills the list with pages currently opened in the | 44 // Clears any entries and fills the list with pages currently opened in the |
45 // browser. | 45 // browser. |
46 void SetToCurrentlyOpenPages(); | 46 void SetToCurrentlyOpenPages(); |
47 | 47 |
48 // Returns the set of urls this model contains. | 48 // Returns the set of urls this model contains. |
49 std::vector<GURL> GetURLs(); | 49 std::vector<GURL> GetURLs(); |
50 | 50 |
51 // TableModel overrides: | 51 // TableModel overrides: |
52 virtual int RowCount() OVERRIDE; | 52 virtual int RowCount() OVERRIDE; |
53 virtual string16 GetText(int row, int column_id) OVERRIDE; | 53 virtual base::string16 GetText(int row, int column_id) OVERRIDE; |
54 virtual string16 GetTooltip(int row) OVERRIDE; | 54 virtual base::string16 GetTooltip(int row) OVERRIDE; |
55 virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; | 55 virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; |
56 | 56 |
57 private: | 57 private: |
58 // Each item in the model is represented as an Entry. Entry stores the URL | 58 // Each item in the model is represented as an Entry. Entry stores the URL |
59 // and title of the page. | 59 // and title of the page. |
60 struct Entry; | 60 struct Entry; |
61 | 61 |
62 // Loads the title for the specified entry. | 62 // Loads the title for the specified entry. |
63 void LoadTitle(Entry* entry); | 63 void LoadTitle(Entry* entry); |
64 | 64 |
65 // Callback from history service. Updates the title of the Entry whose | 65 // Callback from history service. Updates the title of the Entry whose |
66 // |title_handle| matches |handle| and notifies the observer of the change. | 66 // |title_handle| matches |handle| and notifies the observer of the change. |
67 void OnGotTitle(HistoryService::Handle handle, | 67 void OnGotTitle(HistoryService::Handle handle, |
68 bool found_url, | 68 bool found_url, |
69 const history::URLRow* row, | 69 const history::URLRow* row, |
70 history::VisitVector* visits); | 70 history::VisitVector* visits); |
71 | 71 |
72 // Returns the entry whose |member| matches |handle| and sets |entry_index| to | 72 // Returns the entry whose |member| matches |handle| and sets |entry_index| to |
73 // the index of the entry. | 73 // the index of the entry. |
74 Entry* GetEntryByLoadHandle(CancelableRequestProvider::Handle Entry::* member, | 74 Entry* GetEntryByLoadHandle(CancelableRequestProvider::Handle Entry::* member, |
75 CancelableRequestProvider::Handle handle, | 75 CancelableRequestProvider::Handle handle, |
76 int* entry_index); | 76 int* entry_index); |
77 | 77 |
78 // Returns the URL for a particular row, formatted for display to the user. | 78 // Returns the URL for a particular row, formatted for display to the user. |
79 string16 FormattedURL(int row) const; | 79 base::string16 FormattedURL(int row) const; |
80 | 80 |
81 // Set of entries we're showing. | 81 // Set of entries we're showing. |
82 std::vector<Entry> entries_; | 82 std::vector<Entry> entries_; |
83 | 83 |
84 // Profile used to load titles. | 84 // Profile used to load titles. |
85 Profile* profile_; | 85 Profile* profile_; |
86 | 86 |
87 ui::TableModelObserver* observer_; | 87 ui::TableModelObserver* observer_; |
88 | 88 |
89 // Used in loading titles. | 89 // Used in loading titles. |
90 CancelableRequestConsumer history_query_consumer_; | 90 CancelableRequestConsumer history_query_consumer_; |
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 |