summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/bookmark_manager_view.h
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-29 23:38:06 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-29 23:38:06 +0000
commit7f856bee73ffdccdbbbbbab4cb79185290d38359 (patch)
treea837328e08a113abdc70b2fc0ae2f2a4a3f804eb /chrome/browser/views/bookmark_manager_view.h
parent281fe14063dd8fb81cea102f5abb7b82f407c3d1 (diff)
downloadchromium_src-7f856bee73ffdccdbbbbbab4cb79185290d38359.zip
chromium_src-7f856bee73ffdccdbbbbbab4cb79185290d38359.tar.gz
chromium_src-7f856bee73ffdccdbbbbbab4cb79185290d38359.tar.bz2
First cut at the bookmark manager. There are still a fair number of
rough edges, but I'm at a good point where I want to land what I have. Here's what is left: . Flicker on show, likely the result of restoring window placement. . tree flickers when dragging splitter. . table/tree need to autoscroll when drop cursor held at bottom of view. . prompts for deleting. . When you move an item the table snaps to the top, this is because I'm sending out model changed. need a better notification. . Operations in menu to add need to change selection. . Remember split location. I would have preferred to split this up into a couple of reviews, but everything is intertwined now. Sorry. BUG=674 TEST=don't test the bookmark manager yet, but make sure bookmark bar still works. Review URL: http://codereview.chromium.org/8197 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4191 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/bookmark_manager_view.h')
-rw-r--r--chrome/browser/views/bookmark_manager_view.h160
1 files changed, 160 insertions, 0 deletions
diff --git a/chrome/browser/views/bookmark_manager_view.h b/chrome/browser/views/bookmark_manager_view.h
new file mode 100644
index 0000000..c397b33
--- /dev/null
+++ b/chrome/browser/views/bookmark_manager_view.h
@@ -0,0 +1,160 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_VIEWS_BOOKMARK_MANAGER_VIEW_H_
+#define CHROME_BROWSER_VIEWS_BOOKMARK_MANAGER_VIEW_H_
+
+#include "base/task.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/views/table_view.h"
+#include "chrome/views/text_field.h"
+#include "chrome/views/tree_view.h"
+#include "chrome/views/view.h"
+#include "chrome/views/window_delegate.h"
+#include "webkit/glue/window_open_disposition.h"
+
+class BookmarkFolderTreeModel;
+class BookmarkFolderTreeView;
+class BookmarkTableModel;
+class BookmarkTableView;
+class PrefService;
+class Profile;
+
+// A view that lets the user manage their bookmarks. The bookmark manager
+// shows a tree on the left with a table on the right. The tree shows the
+// folder nodes and the table the contents of the selected tree node. The
+// tree is a BookmarkFolderTreeView and the table a BookmarkTableView. A
+// text field is also provided that allows the user to search the contents
+// of the bookmarks.
+class BookmarkManagerView : public views::View,
+ public views::WindowDelegate,
+ public views::TreeViewController,
+ public views::TableViewObserver,
+ public views::TextField::Controller,
+ public BookmarkModelObserver,
+ public views::ContextMenuController {
+ public:
+ explicit BookmarkManagerView(Profile* profile);
+ virtual ~BookmarkManagerView();
+
+ static void RegisterPrefs(PrefService* prefs);
+
+ // Shows the bookmark manager. Only one bookmark manager exists.
+ static void Show(Profile* profile);
+
+ // Returns the current manager, or NULL if the manager is not showing.
+ static BookmarkManagerView* current();
+
+ // Selects the specified node in the tree. If node is a URL it's parent is
+ // selected and node is selected in the table.
+ void SelectInTree(BookmarkNode* node);
+
+ // Returns the selection of the table.
+ std::vector<BookmarkNode*> GetSelectedTableNodes();
+
+ virtual void PaintBackground(ChromeCanvas* canvas);
+
+ virtual gfx::Size GetPreferredSize();
+
+ // WindowDelegate.
+ virtual bool CanResize() const { return true; }
+ virtual bool CanMaximize() const { return true; }
+ virtual std::wstring GetWindowTitle() const;
+ virtual void SaveWindowPosition(const CRect& bounds,
+ bool maximized,
+ bool always_on_top);
+ virtual bool RestoreWindowPosition(CRect* bounds,
+ bool* maximized,
+ bool* always_on_top);
+ virtual View* GetContentsView() { return this; }
+ // TODO(sky): implement these when we have an icon.
+ //virtual SkBitmap GetWindowIcon();
+ //virtual bool ShouldShowWindowIcon() const { return true; }
+
+ private:
+ // TableViewObserver methods.
+ virtual void OnSelectionChanged() {}
+ // Overriden to open the selected table nodes in the current browser.
+ virtual void OnDoubleClick();
+ virtual void OnTableViewDelete(views::TableView* table);
+
+ // TreeViewController method.
+ virtual void OnTreeViewSelectionChanged(views::TreeView* tree_view);
+
+ // BookmarkModelObserver. We're only installed as an observer until the
+ // bookmarks are loaded.
+ virtual void Loaded(BookmarkModel* model);
+ virtual void BookmarkModelBeingDeleted(BookmarkModel* model) {}
+ virtual void BookmarkNodeMoved(BookmarkModel* model,
+ BookmarkNode* old_parent,
+ int old_index,
+ BookmarkNode* new_parent,
+ int new_index) {}
+ virtual void BookmarkNodeAdded(BookmarkModel* model,
+ BookmarkNode* parent,
+ int index) {}
+ virtual void BookmarkNodeRemoved(BookmarkModel* model,
+ BookmarkNode* parent,
+ int index) {}
+ virtual void BookmarkNodeRemoved(BookmarkModel* model,
+ BookmarkNode* parent,
+ int old_index,
+ BookmarkNode* node) {}
+ virtual void BookmarkNodeChanged(BookmarkModel* model,
+ BookmarkNode* node) {}
+ virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
+ BookmarkNode* node) {}
+
+ // TextField::Controller methods.
+ // Starts a timer to search for the search text.
+ virtual void ContentsChanged(views::TextField* sender,
+ const std::wstring& new_contents);
+ // If return has been pressed this performs an immediate search.
+ virtual void HandleKeystroke(views::TextField* sender,
+ UINT message, TCHAR key, UINT repeat_count,
+ UINT flags);
+
+ // ContextMenuController.
+ virtual void ShowContextMenu(views::View* source,
+ int x,
+ int y,
+ bool is_mouse_gesture);
+
+ // Creates the table model to use when searching. This returns NULL if there
+ // is no search text.
+ BookmarkTableModel* CreateSearchTableModel();
+
+ // Sets the model of the table and its parent node.
+ void SetTableModel(BookmarkTableModel* new_table_model,
+ BookmarkNode* parent_node);
+
+ // Sets the table's model to the results of CreateSearchTableModel and selects
+ // the search node in the tree.
+ void PerformSearch();
+
+ // Invoked prior to showing. If the BookmarkModel is loaded this invokes
+ // LoadedImpl.
+ void PrepareForShow();
+
+ // Invoked when we're parented and the BookmarkModel is loaded. Sets the
+ // models of the tree/table appropriately and expands the necessary nodes.
+ void LoadedImpl();
+
+ // Returns the BookmarkModel.
+ BookmarkModel* GetBookmarkModel() const;
+
+ Profile* profile_;
+ BookmarkTableView* table_view_;
+ BookmarkFolderTreeView* tree_view_;
+ scoped_ptr<BookmarkTableModel> table_model_;
+ scoped_ptr<BookmarkFolderTreeModel> tree_model_;
+ views::TextField* search_tf_;
+
+ // Factory used for delaying search.
+ ScopedRunnableMethodFactory<BookmarkManagerView> search_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(BookmarkManagerView);
+};
+
+#endif // CHROME_BROWSER_VIEWS_BOOKMARK_MANAGER_VIEW_H_