OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_POSSIBLE_URL_MODEL_H_ | 5 #ifndef CHROME_BROWSER_POSSIBLE_URL_MODEL_H_ |
6 #define CHROME_BROWSER_POSSIBLE_URL_MODEL_H_ | 6 #define CHROME_BROWSER_POSSIBLE_URL_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "app/table_model.h" | 13 #include "app/table_model.h" |
| 14 #include "base/compiler_specific.h" |
14 #include "chrome/browser/history/history.h" | 15 #include "chrome/browser/history/history.h" |
15 | 16 |
16 class SkBitmap; | 17 class SkBitmap; |
17 | 18 |
18 //////////////////////////////////////////////////////////////////////////////// | 19 //////////////////////////////////////////////////////////////////////////////// |
19 // | 20 // |
20 // A table model to represent the list of URLs that the user might want to | 21 // A table model to represent the list of URLs that the user might want to |
21 // bookmark. | 22 // bookmark. |
22 // | 23 // |
23 //////////////////////////////////////////////////////////////////////////////// | 24 //////////////////////////////////////////////////////////////////////////////// |
24 | 25 |
25 class PossibleURLModel : public TableModel { | 26 class PossibleURLModel : public TableModel { |
26 public: | 27 public: |
27 PossibleURLModel(); | 28 PossibleURLModel(); |
28 virtual ~PossibleURLModel(); | 29 virtual ~PossibleURLModel(); |
29 | 30 |
30 void Reload(Profile *profile); | 31 void Reload(Profile *profile); |
31 | 32 |
32 void OnHistoryQueryComplete(HistoryService::Handle h, | 33 void OnHistoryQueryComplete(HistoryService::Handle h, |
33 history::QueryResults* result); | 34 history::QueryResults* result); |
34 | 35 |
35 virtual int RowCount(); | |
36 | |
37 const GURL& GetURL(int row); | 36 const GURL& GetURL(int row); |
38 | |
39 const std::wstring& GetTitle(int row); | 37 const std::wstring& GetTitle(int row); |
40 | 38 |
41 virtual std::wstring GetText(int row, int col_id); | |
42 | |
43 virtual SkBitmap GetIcon(int row); | |
44 | |
45 virtual int CompareValues(int row1, int row2, int column_id); | |
46 | |
47 virtual void OnFavIconAvailable(FaviconService::Handle h, | 39 virtual void OnFavIconAvailable(FaviconService::Handle h, |
48 bool fav_icon_available, | 40 bool fav_icon_available, |
49 scoped_refptr<RefCountedMemory> data, | 41 scoped_refptr<RefCountedMemory> data, |
50 bool expired, | 42 bool expired, |
51 GURL icon_url); | 43 GURL icon_url); |
52 | 44 |
53 virtual void SetObserver(TableModelObserver* observer); | 45 // TableModel overrides |
| 46 virtual int RowCount() OVERRIDE; |
| 47 virtual string16 GetText(int row, int col_id) OVERRIDE; |
| 48 virtual SkBitmap GetIcon(int row) OVERRIDE; |
| 49 virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE; |
| 50 virtual void SetObserver(TableModelObserver* observer) OVERRIDE; |
54 | 51 |
55 private: | 52 private: |
56 // The current profile. | 53 // The current profile. |
57 Profile* profile_; | 54 Profile* profile_; |
58 | 55 |
59 // Our observer. | 56 // Our observer. |
60 TableModelObserver* observer_; | 57 TableModelObserver* observer_; |
61 | 58 |
62 // Our consumer for favicon requests. | 59 // Our consumer for favicon requests. |
63 CancelableRequestConsumerT<size_t, NULL> consumer_; | 60 CancelableRequestConsumerT<size_t, NULL> consumer_; |
64 | 61 |
65 // The results we're showing. | 62 // The results we're showing. |
66 struct Result; | 63 struct Result; |
67 std::vector<Result> results_; | 64 std::vector<Result> results_; |
68 | 65 |
69 // Map Result::index -> Favicon. | 66 // Map Result::index -> Favicon. |
70 typedef std::map<size_t, SkBitmap> FavIconMap; | 67 typedef std::map<size_t, SkBitmap> FavIconMap; |
71 FavIconMap fav_icon_map_; | 68 FavIconMap fav_icon_map_; |
72 | 69 |
73 DISALLOW_COPY_AND_ASSIGN(PossibleURLModel); | 70 DISALLOW_COPY_AND_ASSIGN(PossibleURLModel); |
74 }; | 71 }; |
75 | 72 |
76 #endif // CHROME_BROWSER_POSSIBLE_URL_MODEL_H_ | 73 #endif // CHROME_BROWSER_POSSIBLE_URL_MODEL_H_ |
OLD | NEW |