| 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_BOOKMARKS_BOOKMARK_TABLE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_TABLE_MODEL_H_ |
| 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_TABLE_MODEL_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_TABLE_MODEL_H_ |
| 7 | 7 |
| 8 #include "app/table_model.h" |
| 8 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 10 | 11 |
| 11 #if defined(TOOLKIT_VIEWS) | |
| 12 #include "views/controls/table/table_model.h" | |
| 13 #else | |
| 14 #include "chrome/common/temp_scaffolding_stubs.h" | |
| 15 #endif | |
| 16 | |
| 17 // BookmarkTableModel provides a view of the BookmarkModel as a TableModel. | 12 // BookmarkTableModel provides a view of the BookmarkModel as a TableModel. |
| 18 // Three variations are provided: | 13 // Three variations are provided: |
| 19 // . Recently created bookmarks. | 14 // . Recently created bookmarks. |
| 20 // . The children of a particular folder. | 15 // . The children of a particular folder. |
| 21 // . All bookmarks matching the specified text. | 16 // . All bookmarks matching the specified text. |
| 22 class BookmarkTableModel : public views::TableModel, | 17 class BookmarkTableModel : public TableModel, |
| 23 public BookmarkModelObserver { | 18 public BookmarkModelObserver { |
| 24 public: | 19 public: |
| 25 // Methods for creating the various BookmarkTableModels. Ownership passes | 20 // Methods for creating the various BookmarkTableModels. Ownership passes |
| 26 // to the caller. | 21 // to the caller. |
| 27 // |languages| is the kAcceptLanguages value of the user preference. It is | 22 // |languages| is the kAcceptLanguages value of the user preference. It is |
| 28 // used to decode IDN. | 23 // used to decode IDN. |
| 29 static BookmarkTableModel* CreateRecentlyBookmarkedModel( | 24 static BookmarkTableModel* CreateRecentlyBookmarkedModel( |
| 30 BookmarkModel* model); | 25 BookmarkModel* model); |
| 31 static BookmarkTableModel* CreateBookmarkTableModelForFolder( | 26 static BookmarkTableModel* CreateBookmarkTableModelForFolder( |
| 32 BookmarkModel* model, BookmarkNode* node); | 27 BookmarkModel* model, BookmarkNode* node); |
| 33 static BookmarkTableModel* CreateSearchTableModel( | 28 static BookmarkTableModel* CreateSearchTableModel( |
| 34 BookmarkModel* model, | 29 BookmarkModel* model, |
| 35 const std::wstring& text, | 30 const std::wstring& text, |
| 36 const std::wstring& languages); | 31 const std::wstring& languages); |
| 37 | 32 |
| 38 explicit BookmarkTableModel(BookmarkModel* model); | 33 explicit BookmarkTableModel(BookmarkModel* model); |
| 39 virtual ~BookmarkTableModel(); | 34 virtual ~BookmarkTableModel(); |
| 40 | 35 |
| 41 // TableModel methods. | 36 // TableModel methods. |
| 42 virtual std::wstring GetText(int row, int column_id); | 37 virtual std::wstring GetText(int row, int column_id); |
| 43 virtual SkBitmap GetIcon(int row); | 38 virtual SkBitmap GetIcon(int row); |
| 44 virtual void SetObserver(views::TableModelObserver* observer) { | 39 virtual void SetObserver(TableModelObserver* observer) { |
| 45 observer_ = observer; | 40 observer_ = observer; |
| 46 } | 41 } |
| 47 | 42 |
| 48 // BookmarkModelObserver methods. | 43 // BookmarkModelObserver methods. |
| 49 virtual void Loaded(BookmarkModel* model) {} | 44 virtual void Loaded(BookmarkModel* model) {} |
| 50 virtual void BookmarkModelBeingDeleted(BookmarkModel* model); | 45 virtual void BookmarkModelBeingDeleted(BookmarkModel* model); |
| 51 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, | 46 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, |
| 52 BookmarkNode* node) {} | 47 BookmarkNode* node) {} |
| 53 | 48 |
| 54 | 49 |
| 55 // Returns the index of the specified node, or -1 if the node isn't in the | 50 // Returns the index of the specified node, or -1 if the node isn't in the |
| 56 // model. | 51 // model. |
| 57 virtual int IndexOfNode(BookmarkNode* node); | 52 virtual int IndexOfNode(BookmarkNode* node); |
| 58 | 53 |
| 59 // Returns the BookmarkNode at the specified index. | 54 // Returns the BookmarkNode at the specified index. |
| 60 virtual BookmarkNode* GetNodeForRow(int row) = 0; | 55 virtual BookmarkNode* GetNodeForRow(int row) = 0; |
| 61 | 56 |
| 62 // Returns the underlying BookmarkModel. | 57 // Returns the underlying BookmarkModel. |
| 63 BookmarkModel* model() const { return model_; } | 58 BookmarkModel* model() const { return model_; } |
| 64 | 59 |
| 65 protected: | 60 protected: |
| 66 views::TableModelObserver* observer() const { return observer_; } | 61 TableModelObserver* observer() const { return observer_; } |
| 67 | 62 |
| 68 private: | 63 private: |
| 69 // Builds the path shown in the path column for the specified node. | 64 // Builds the path shown in the path column for the specified node. |
| 70 void BuildPath(BookmarkNode* node, std::wstring* path); | 65 void BuildPath(BookmarkNode* node, std::wstring* path); |
| 71 | 66 |
| 72 BookmarkModel* model_; | 67 BookmarkModel* model_; |
| 73 views::TableModelObserver* observer_; | 68 TableModelObserver* observer_; |
| 74 | 69 |
| 75 DISALLOW_COPY_AND_ASSIGN(BookmarkTableModel); | 70 DISALLOW_COPY_AND_ASSIGN(BookmarkTableModel); |
| 76 }; | 71 }; |
| 77 | 72 |
| 78 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_TABLE_MODEL_H_ | 73 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_TABLE_MODEL_H_ |
| OLD | NEW |