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