summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-28 19:32:15 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-28 19:32:15 +0000
commitef49de68beef6d5adf699518f8ef86f47b9f8b33 (patch)
treed325591020879e84a6bdea2433f1893a78ca75da /chrome/browser/bookmarks
parentb938c4cd5adac79efc4453ccf1a53f9e70c29293 (diff)
downloadchromium_src-ef49de68beef6d5adf699518f8ef86f47b9f8b33.zip
chromium_src-ef49de68beef6d5adf699518f8ef86f47b9f8b33.tar.gz
chromium_src-ef49de68beef6d5adf699518f8ef86f47b9f8b33.tar.bz2
Create a bookmark editor dialog interface and implement a GTK version.
The GTK version is currently limited to only editing the name/url of the bookmark; I'm submitting this since it's getting big and I want a design review. Review URL: http://codereview.chromium.org/99131 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14763 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks')
-rw-r--r--chrome/browser/bookmarks/bookmark_context_menu.cc36
-rw-r--r--chrome/browser/bookmarks/bookmark_editor.h44
2 files changed, 60 insertions, 20 deletions
diff --git a/chrome/browser/bookmarks/bookmark_context_menu.cc b/chrome/browser/bookmarks/bookmark_context_menu.cc
index 57f3631..039cd83 100644
--- a/chrome/browser/bookmarks/bookmark_context_menu.cc
+++ b/chrome/browser/bookmarks/bookmark_context_menu.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/bookmarks/bookmark_context_menu.h"
#include "base/compiler_specific.h"
+#include "chrome/browser/bookmarks/bookmark_editor.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/browser.h"
@@ -21,7 +22,6 @@
// TODO(port): Port these files.
#if defined(OS_WIN)
#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/views/bookmark_editor_view.h"
#include "chrome/browser/views/bookmark_manager_view.h"
#include "chrome/views/window/window.h"
#endif
@@ -189,7 +189,7 @@ class EditFolderController : public InputWindowDialog::Delegate,
// Used when adding a new bookmark. If a new bookmark is created it is selected
// in the bookmark manager.
-class SelectOnCreationHandler : public BookmarkEditorView::Handler {
+class SelectOnCreationHandler : public BookmarkEditor::Handler {
public:
explicit SelectOnCreationHandler(Profile* profile) : profile_(profile) {
}
@@ -336,17 +336,13 @@ void BookmarkContextMenu::ExecuteCommand(int id) {
}
if (selection_[0]->is_url()) {
-#if defined(OS_WIN)
- BookmarkEditorView::Configuration editor_config;
+ BookmarkEditor::Configuration editor_config;
if (configuration_ == BOOKMARK_BAR)
- editor_config = BookmarkEditorView::SHOW_TREE;
+ editor_config = BookmarkEditor::SHOW_TREE;
else
- editor_config = BookmarkEditorView::NO_TREE;
- BookmarkEditorView::Show(wnd_, profile_, NULL, selection_[0],
- editor_config, NULL);
-#else
- NOTIMPLEMENTED() << "BookmarkEditorView unimplemented";
-#endif
+ editor_config = BookmarkEditor::NO_TREE;
+ BookmarkEditor::Show(wnd_, profile_, NULL, selection_[0],
+ editor_config, NULL);
} else {
EditFolderController::Show(profile_, wnd_, selection_[0], false,
false);
@@ -368,21 +364,21 @@ void BookmarkContextMenu::ExecuteCommand(int id) {
case IDS_BOOMARK_BAR_ADD_NEW_BOOKMARK: {
UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_Add", profile_);
-#if defined(OS_WIN)
- BookmarkEditorView::Configuration editor_config;
- BookmarkEditorView::Handler* handler = NULL;
+ BookmarkEditor::Configuration editor_config;
+ BookmarkEditor::Handler* handler = NULL;
if (configuration_ == BOOKMARK_BAR) {
- editor_config = BookmarkEditorView::SHOW_TREE;
+ editor_config = BookmarkEditor::SHOW_TREE;
} else {
- editor_config = BookmarkEditorView::NO_TREE;
+ editor_config = BookmarkEditor::NO_TREE;
+#if defined(OS_WIN)
// This is owned by the BookmarkEditorView.
handler = new SelectOnCreationHandler(profile_);
- }
- BookmarkEditorView::Show(wnd_, profile_, GetParentForNewNodes(), NULL,
- editor_config, handler);
#else
- NOTIMPLEMENTED() << "Adding new bookmark not implemented";
+ NOTIMPLEMENTED() << "Custom SelectOnCreationHandler not implemented";
#endif
+ }
+ BookmarkEditor::Show(wnd_, profile_, GetParentForNewNodes(), NULL,
+ editor_config, handler);
break;
}
diff --git a/chrome/browser/bookmarks/bookmark_editor.h b/chrome/browser/bookmarks/bookmark_editor.h
new file mode 100644
index 0000000..5e356e1
--- /dev/null
+++ b/chrome/browser/bookmarks/bookmark_editor.h
@@ -0,0 +1,44 @@
+// Copyright (c) 2009 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_BOOKMARKS_BOOKMARK_EDITOR_H_
+#define CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_
+
+#include "base/gfx/native_widget_types.h"
+
+class BookmarkNode;
+class Profile;
+
+// Small, cross platform interface that shows the correct platform specific
+// bookmark editor dialog.
+class BookmarkEditor {
+ public:
+ // Handler is notified when the BookmarkEditor creates a new bookmark.
+ // Handler is owned by the BookmarkEditor and deleted when it is deleted.
+ class Handler {
+ public:
+ virtual ~Handler() {}
+ virtual void NodeCreated(BookmarkNode* new_node) = 0;
+ };
+
+ // An enumeration of the possible configurations offered.
+ enum Configuration {
+ SHOW_TREE,
+ NO_TREE
+ };
+
+ // Shows the platform specific BookmarkEditor subclass editing |node|. If
+ // |node| is NULL a new entry is created initially parented to |parent|. If
+ // |show_tree| is false the tree is not shown. BookmarkEditor takes
+ // ownership of |handler| and deletes it when done. |handler| may be
+ // null. See description of Handler for details.
+ static void Show(gfx::NativeWindow parent_window,
+ Profile* profile,
+ BookmarkNode* parent,
+ BookmarkNode* node,
+ Configuration configuration,
+ Handler* handler);
+};
+
+#endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_