summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-01 22:50:55 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-01 22:50:55 +0000
commite446aa03b366a12be68c07bdf9fba16524227b80 (patch)
tree31bf322d4896e358c2b277ea95d244236bbd12ae
parent10b95a0a02da9ab61cc112f2a8a4493728445de7 (diff)
downloadchromium_src-e446aa03b366a12be68c07bdf9fba16524227b80.zip
chromium_src-e446aa03b366a12be68c07bdf9fba16524227b80.tar.gz
chromium_src-e446aa03b366a12be68c07bdf9fba16524227b80.tar.bz2
Move the RenderViewHostDelegate::BookmarkDrag interface to Chrome as the feature which uses it is
specific to Chrome. This interface is now part of the BookmarkTabHelper class. Fixes bug http://code.google.com/p/chromium/issues/detail?id=87682 BUG=87682 TEST=no change in functionality. Existing tests should continue to work. Review URL: http://codereview.chromium.org/7291018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91384 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_bookmark_manager_api.cc11
-rw-r--r--chrome/browser/extensions/extension_bookmark_manager_api.h10
-rw-r--r--chrome/browser/extensions/extension_web_ui.cc5
-rw-r--r--chrome/browser/tab_contents/web_drag_dest_gtk.cc30
-rw-r--r--chrome/browser/tab_contents/web_drag_dest_gtk.h4
-rw-r--r--chrome/browser/tab_contents/web_drop_target_win.cc30
-rw-r--r--chrome/browser/tab_contents/web_drop_target_win.h5
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_tab_helper.cc14
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_tab_helper.h26
-rw-r--r--chrome/browser/ui/cocoa/tab_contents/web_drop_target.h4
-rw-r--r--chrome/browser/ui/cocoa/tab_contents/web_drop_target.mm20
-rw-r--r--content/browser/renderer_host/render_view_host_delegate.cc5
-rw-r--r--content/browser/renderer_host/render_view_host_delegate.h16
-rw-r--r--content/browser/tab_contents/tab_contents.cc10
-rw-r--r--content/browser/tab_contents/tab_contents.h13
15 files changed, 123 insertions, 80 deletions
diff --git a/chrome/browser/extensions/extension_bookmark_manager_api.cc b/chrome/browser/extensions/extension_bookmark_manager_api.cc
index 3f1388c..7e1f87b 100644
--- a/chrome/browser/extensions/extension_bookmark_manager_api.cc
+++ b/chrome/browser/extensions/extension_bookmark_manager_api.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/common/pref_names.h"
#include "content/browser/renderer_host/render_view_host.h"
@@ -145,15 +146,15 @@ void BookmarkNodeDataToJSON(Profile* profile, const BookmarkNodeData& data,
} // namespace
ExtensionBookmarkManagerEventRouter::ExtensionBookmarkManagerEventRouter(
- Profile* profile, TabContents* tab_contents)
+ Profile* profile, TabContentsWrapper* tab)
: profile_(profile),
- tab_contents_(tab_contents) {
- tab_contents_->SetBookmarkDragDelegate(this);
+ tab_(tab) {
+ tab_->bookmark_tab_helper()->SetBookmarkDragDelegate(this);
}
ExtensionBookmarkManagerEventRouter::~ExtensionBookmarkManagerEventRouter() {
- if (tab_contents_->GetBookmarkDragDelegate() == this)
- tab_contents_->SetBookmarkDragDelegate(NULL);
+ if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate() == this)
+ tab_->bookmark_tab_helper()->SetBookmarkDragDelegate(NULL);
}
void ExtensionBookmarkManagerEventRouter::DispatchEvent(const char* event_name,
diff --git a/chrome/browser/extensions/extension_bookmark_manager_api.h b/chrome/browser/extensions/extension_bookmark_manager_api.h
index 69812a3..f2bff9b 100644
--- a/chrome/browser/extensions/extension_bookmark_manager_api.h
+++ b/chrome/browser/extensions/extension_bookmark_manager_api.h
@@ -9,19 +9,19 @@
#include "chrome/browser/bookmarks/bookmark_node_data.h"
#include "chrome/browser/extensions/extension_bookmarks_module.h"
#include "chrome/browser/extensions/extension_function.h"
-#include "content/browser/renderer_host/render_view_host_delegate.h"
+#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
struct BookmarkNodeData;
class ListValue;
class Profile;
-class TabContents;
+class TabContentsWrapper;
// Class that handles the chrome.experimental.bookmarkManager events.
class ExtensionBookmarkManagerEventRouter
- : public RenderViewHostDelegate::BookmarkDrag {
+ : public BookmarkTabHelper::BookmarkDrag {
public:
ExtensionBookmarkManagerEventRouter(Profile* profile,
- TabContents* tab_contents);
+ TabContentsWrapper* tab);
virtual ~ExtensionBookmarkManagerEventRouter();
// RenderViewHostDelegate::BookmarkDrag interface
@@ -44,7 +44,7 @@ class ExtensionBookmarkManagerEventRouter
void DispatchDragEvent(const BookmarkNodeData& data, const char* event_name);
Profile* profile_;
- TabContents* tab_contents_;
+ TabContentsWrapper* tab_;
BookmarkNodeData bookmark_drag_data_;
DISALLOW_COPY_AND_ASSIGN(ExtensionBookmarkManagerEventRouter);
diff --git a/chrome/browser/extensions/extension_web_ui.cc b/chrome/browser/extensions/extension_web_ui.cc
index 4644127..0c91bde 100644
--- a/chrome/browser/extensions/extension_web_ui.cc
+++ b/chrome/browser/extensions/extension_web_ui.cc
@@ -159,8 +159,11 @@ ExtensionWebUI::ExtensionWebUI(TabContents* tab_contents, const GURL& url)
// Hack: A few things we specialize just for the bookmark manager.
if (extension->id() == extension_misc::kBookmarkManagerId) {
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_);
+ DCHECK(tab);
extension_bookmark_manager_event_router_.reset(
- new ExtensionBookmarkManagerEventRouter(GetProfile(), tab_contents));
+ new ExtensionBookmarkManagerEventRouter(GetProfile(), tab));
link_transition_type_ = PageTransition::AUTO_BOOKMARK;
}
diff --git a/chrome/browser/tab_contents/web_drag_dest_gtk.cc b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
index a2560ad..ffddbdd 100644
--- a/chrome/browser/tab_contents/web_drag_dest_gtk.cc
+++ b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
@@ -9,8 +9,10 @@
#include "base/file_path.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_node_data.h"
+#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/url_constants.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -42,6 +44,7 @@ GdkAtom GetBookmarkTargetAtom() {
WebDragDestGtk::WebDragDestGtk(TabContents* tab_contents, GtkWidget* widget)
: tab_contents_(tab_contents),
+ tab_(NULL),
widget_(widget),
context_(NULL),
method_factory_(this) {
@@ -83,8 +86,10 @@ void WebDragDestGtk::UpdateDragStatus(WebDragOperation operation) {
void WebDragDestGtk::DragLeave() {
tab_contents_->render_view_host()->DragTargetDragLeave();
- if (tab_contents_->GetBookmarkDragDelegate()) {
- tab_contents_->GetBookmarkDragDelegate()->OnDragLeave(bookmark_drag_data_);
+ DCHECK(tab_);
+ if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
+ tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragLeave(
+ bookmark_drag_data_);
}
}
@@ -127,8 +132,10 @@ gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender,
gtk_util::ClientPoint(widget_),
gtk_util::ScreenPoint(widget_),
gtk_util::GdkDragActionToWebDragOp(context->actions));
- if (tab_contents_->GetBookmarkDragDelegate())
- tab_contents_->GetBookmarkDragDelegate()->OnDragOver(bookmark_drag_data_);
+ DCHECK(tab_);
+ if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate())
+ tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragOver(
+ bookmark_drag_data_);
drag_over_time_ = time;
}
@@ -232,13 +239,16 @@ void WebDragDestGtk::OnDragDataReceived(
gtk_util::ScreenPoint(widget_),
gtk_util::GdkDragActionToWebDragOp(context->actions));
+ if (!tab_) {
+ tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_);
+ DCHECK(tab_);
+ }
// This is non-null if tab_contents_ is showing an ExtensionWebUI with
// support for (at the moment experimental) drag and drop extensions.
- if (tab_contents_->GetBookmarkDragDelegate()) {
- tab_contents_->GetBookmarkDragDelegate()->OnDragEnter(
+ if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
+ tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragEnter(
bookmark_drag_data_);
}
-
drag_over_time_ = time;
}
}
@@ -268,10 +278,12 @@ gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context,
DragTargetDrop(gtk_util::ClientPoint(widget_),
gtk_util::ScreenPoint(widget_));
+ DCHECK(tab_);
// This is non-null if tab_contents_ is showing an ExtensionWebUI with
// support for (at the moment experimental) drag and drop extensions.
- if (tab_contents_->GetBookmarkDragDelegate())
- tab_contents_->GetBookmarkDragDelegate()->OnDrop(bookmark_drag_data_);
+ if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate())
+ tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDrop(
+ bookmark_drag_data_);
// The second parameter is just an educated guess as to whether or not the
// drag succeeded, but at least we will get the drag-end animation right
diff --git a/chrome/browser/tab_contents/web_drag_dest_gtk.h b/chrome/browser/tab_contents/web_drag_dest_gtk.h
index 856fb76..1946d0c 100644
--- a/chrome/browser/tab_contents/web_drag_dest_gtk.h
+++ b/chrome/browser/tab_contents/web_drag_dest_gtk.h
@@ -16,6 +16,7 @@
#include "webkit/glue/webdropdata.h"
class TabContents;
+class TabContentsWrapper;
// A helper class that handles DnD for drops in the renderer. In GTK parlance,
// this handles destination-side DnD, but not source-side DnD.
@@ -57,6 +58,9 @@ class WebDragDestGtk {
gint, gint, guint);
TabContents* tab_contents_;
+ // The TabContentsWrapper for the TabContents member defined above.
+ // Weak reference.
+ TabContentsWrapper* tab_;
// The render view.
GtkWidget* widget_;
// The current drag context for system drags over our render view, or NULL if
diff --git a/chrome/browser/tab_contents/web_drop_target_win.cc b/chrome/browser/tab_contents/web_drop_target_win.cc
index c2ec3dd..113b6a5 100644
--- a/chrome/browser/tab_contents/web_drop_target_win.cc
+++ b/chrome/browser/tab_contents/web_drop_target_win.cc
@@ -9,6 +9,8 @@
#include "chrome/browser/bookmarks/bookmark_node_data.h"
#include "chrome/browser/tab_contents/web_drag_utils_win.h"
+#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "googleurl/src/gurl.h"
@@ -84,6 +86,7 @@ class InterstitialDropTarget {
WebDropTarget::WebDropTarget(HWND source_hwnd, TabContents* tab_contents)
: ui::DropTarget(source_hwnd),
tab_contents_(tab_contents),
+ tab_(NULL),
current_rvh_(NULL),
drag_cursor_(WebDragOperationNone),
interstitial_drop_target_(new InterstitialDropTarget(tab_contents)) {
@@ -121,14 +124,19 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
gfx::Point(cursor_position.x, cursor_position.y),
web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects));
+ if (!tab_) {
+ tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_);
+ DCHECK(tab_);
+ }
// This is non-null if tab_contents_ is showing an ExtensionWebUI with
// support for (at the moment experimental) drag and drop extensions.
- if (tab_contents_->GetBookmarkDragDelegate()) {
+ if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
ui::OSExchangeData os_exchange_data(
new ui::OSExchangeDataProviderWin(data_object));
BookmarkNodeData bookmark_drag_data;
if (bookmark_drag_data.Read(os_exchange_data))
- tab_contents_->GetBookmarkDragDelegate()->OnDragEnter(bookmark_drag_data);
+ tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragEnter(
+ bookmark_drag_data);
}
// We lie here and always return a DROPEFFECT because we don't want to
@@ -154,12 +162,14 @@ DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
gfx::Point(cursor_position.x, cursor_position.y),
web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects));
- if (tab_contents_->GetBookmarkDragDelegate()) {
+ DCHECK(tab_);
+ if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
ui::OSExchangeData os_exchange_data(
new ui::OSExchangeDataProviderWin(data_object));
BookmarkNodeData bookmark_drag_data;
if (bookmark_drag_data.Read(os_exchange_data))
- tab_contents_->GetBookmarkDragDelegate()->OnDragOver(bookmark_drag_data);
+ tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragOver(
+ bookmark_drag_data);
}
return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_);
@@ -176,12 +186,14 @@ void WebDropTarget::OnDragLeave(IDataObject* data_object) {
tab_contents_->render_view_host()->DragTargetDragLeave();
}
- if (tab_contents_->GetBookmarkDragDelegate()) {
+ DCHECK(tab_);
+ if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
ui::OSExchangeData os_exchange_data(
new ui::OSExchangeDataProviderWin(data_object));
BookmarkNodeData bookmark_drag_data;
if (bookmark_drag_data.Read(os_exchange_data))
- tab_contents_->GetBookmarkDragDelegate()->OnDragLeave(bookmark_drag_data);
+ tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragLeave(
+ bookmark_drag_data);
}
}
@@ -205,12 +217,14 @@ DWORD WebDropTarget::OnDrop(IDataObject* data_object,
gfx::Point(client_pt.x, client_pt.y),
gfx::Point(cursor_position.x, cursor_position.y));
- if (tab_contents_->GetBookmarkDragDelegate()) {
+ DCHECK(tab_);
+ if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
ui::OSExchangeData os_exchange_data(
new ui::OSExchangeDataProviderWin(data_object));
BookmarkNodeData bookmark_drag_data;
if (bookmark_drag_data.Read(os_exchange_data))
- tab_contents_->GetBookmarkDragDelegate()->OnDrop(bookmark_drag_data);
+ tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDrop(
+ bookmark_drag_data);
}
current_rvh_ = NULL;
diff --git a/chrome/browser/tab_contents/web_drop_target_win.h b/chrome/browser/tab_contents/web_drop_target_win.h
index d51eaa3..377ca39 100644
--- a/chrome/browser/tab_contents/web_drop_target_win.h
+++ b/chrome/browser/tab_contents/web_drop_target_win.h
@@ -13,7 +13,7 @@
class InterstitialDropTarget;
class RenderViewHost;
class TabContents;
-
+class TabContentsWrapper;
// A helper object that provides drop capabilities to a TabContents. The
// DropTarget handles drags that enter the region of the TabContents by
// passing on the events to the renderer.
@@ -49,6 +49,9 @@ class WebDropTarget : public ui::DropTarget {
private:
// Our associated TabContents.
TabContents* tab_contents_;
+ // The TabContentsWrapper for the TabContents member defined above.
+ // Weak reference.
+ TabContentsWrapper* tab_;
// We keep track of the render view host we're dragging over. If it changes
// during a drag, we need to re-send the DragEnter message. WARNING:
diff --git a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
index fa00c71..2e25d03 100644
--- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/bookmarks/bookmark_node_data.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper_delegate.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -21,7 +22,8 @@ BookmarkTabHelper::BookmarkTabHelper(TabContentsWrapper* tab_contents)
: TabContentsObserver(tab_contents->tab_contents()),
is_starred_(false),
tab_contents_wrapper_(tab_contents),
- delegate_(NULL) {
+ delegate_(NULL),
+ bookmark_drag_(NULL) {
// Register for notifications about URL starredness changing on any profile.
registrar_.Add(this, NotificationType::URLS_STARRED,
NotificationService::AllSources());
@@ -82,6 +84,16 @@ void BookmarkTabHelper::Observe(NotificationType type,
}
}
+void BookmarkTabHelper::SetBookmarkDragDelegate(
+ BookmarkTabHelper::BookmarkDrag* bookmark_drag) {
+ bookmark_drag_ = bookmark_drag;
+}
+
+BookmarkTabHelper::BookmarkDrag*
+ BookmarkTabHelper::GetBookmarkDragDelegate() {
+ return bookmark_drag_;
+}
+
void BookmarkTabHelper::UpdateStarredStateForCurrentURL() {
BookmarkModel* model = tab_contents()->profile()->GetBookmarkModel();
const bool old_state = is_starred_;
diff --git a/chrome/browser/ui/bookmarks/bookmark_tab_helper.h b/chrome/browser/ui/bookmarks/bookmark_tab_helper.h
index 7be376b..0814236 100644
--- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.h
+++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.h
@@ -12,11 +12,25 @@
class BookmarkTabHelperDelegate;
class TabContentsWrapper;
+struct BookmarkNodeData;
// Per-tab class to manage bookmarks.
class BookmarkTabHelper : public NotificationObserver,
public TabContentsObserver {
public:
+ // BookmarkDrag --------------------------------------------------------------
+ // Interface for forwarding bookmark drag and drop to extenstions.
+ class BookmarkDrag {
+ public:
+ virtual void OnDragEnter(const BookmarkNodeData& data) = 0;
+ virtual void OnDragOver(const BookmarkNodeData& data) = 0;
+ virtual void OnDragLeave(const BookmarkNodeData& data) = 0;
+ virtual void OnDrop(const BookmarkNodeData& data) = 0;
+
+ protected:
+ virtual ~BookmarkDrag() {}
+ };
+
explicit BookmarkTabHelper(TabContentsWrapper* tab_contents);
virtual ~BookmarkTabHelper();
@@ -38,6 +52,15 @@ class BookmarkTabHelper : public NotificationObserver,
const NotificationSource& source,
const NotificationDetails& details) OVERRIDE;
+ // It is up to callers to call SetBookmarkDragDelegate(NULL) when
+ // |bookmark_drag| is deleted since this class does not take ownership of
+ // |bookmark_drag|.
+ void SetBookmarkDragDelegate(
+ BookmarkTabHelper::BookmarkDrag* bookmark_drag);
+ // The BookmarkDragDelegate is used to forward bookmark drag and drop events
+ // to extensions.
+ BookmarkTabHelper::BookmarkDrag* GetBookmarkDragDelegate();
+
private:
// Updates the starred state from the bookmark bar model. If the state has
// changed, the delegate is notified.
@@ -56,6 +79,9 @@ class BookmarkTabHelper : public NotificationObserver,
// by us.
BookmarkTabHelperDelegate* delegate_;
+ // Handles drag and drop event forwarding to extensions.
+ BookmarkDrag* bookmark_drag_;
+
DISALLOW_COPY_AND_ASSIGN(BookmarkTabHelper);
};
diff --git a/chrome/browser/ui/cocoa/tab_contents/web_drop_target.h b/chrome/browser/ui/cocoa/tab_contents/web_drop_target.h
index 35074a4..52e7981 100644
--- a/chrome/browser/ui/cocoa/tab_contents/web_drop_target.h
+++ b/chrome/browser/ui/cocoa/tab_contents/web_drop_target.h
@@ -9,6 +9,7 @@
class GURL;
class RenderViewHost;
class TabContents;
+class TabContentsWrapper;
struct WebDropData;
// A typedef for a RenderViewHost used for comparison purposes only.
@@ -23,6 +24,9 @@ typedef RenderViewHost* RenderViewHostIdentifier;
// Our associated TabContents. Weak reference.
TabContents* tabContents_;
+ // The TabContentsWrapper for the TabContents member above. Weak reference.
+ TabContentsWrapper* tab_;
+
// Updated asynchronously during a drag to tell us whether or not we should
// allow the drop.
NSDragOperation current_operation_;
diff --git a/chrome/browser/ui/cocoa/tab_contents/web_drop_target.mm b/chrome/browser/ui/cocoa/tab_contents/web_drop_target.mm
index 6397d49..700c071 100644
--- a/chrome/browser/ui/cocoa/tab_contents/web_drop_target.mm
+++ b/chrome/browser/ui/cocoa/tab_contents/web_drop_target.mm
@@ -7,7 +7,9 @@
#include "base/sys_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_node_data.h"
#include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h"
+#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/ui/cocoa/drag_util.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
#import "third_party/mozilla/NSPasteboard+Utils.h"
@@ -81,9 +83,13 @@ using WebKit::WebDragOperationsMask;
return NSDragOperationNone;
}
+ if (!tab_) {
+ tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tabContents_);
+ DCHECK(tab_);
+ }
// If the tab is showing the bookmark manager, send BookmarkDrag events
- RenderViewHostDelegate::BookmarkDrag* dragDelegate =
- tabContents_->GetBookmarkDragDelegate();
+ BookmarkTabHelper::BookmarkDrag* dragDelegate =
+ tab_->bookmark_tab_helper()->GetBookmarkDragDelegate();
BookmarkNodeData dragData;
if(dragDelegate && dragData.ReadFromDragClipboard())
dragDelegate->OnDragEnter(dragData);
@@ -142,9 +148,10 @@ using WebKit::WebDragOperationsMask;
gfx::Point(screenPoint.x, screenPoint.y),
static_cast<WebDragOperationsMask>(mask));
+ DCHECK(tab_);
// If the tab is showing the bookmark manager, send BookmarkDrag events
- RenderViewHostDelegate::BookmarkDrag* dragDelegate =
- tabContents_->GetBookmarkDragDelegate();
+ BookmarkTabHelper::BookmarkDrag* dragDelegate =
+ tab_->bookmark_tab_helper()->GetBookmarkDragDelegate();
BookmarkNodeData dragData;
if(dragDelegate && dragData.ReadFromDragClipboard())
dragDelegate->OnDragOver(dragData);
@@ -169,9 +176,10 @@ using WebKit::WebDragOperationsMask;
return NO;
}
+ DCHECK(tab_);
// If the tab is showing the bookmark manager, send BookmarkDrag events
- RenderViewHostDelegate::BookmarkDrag* dragDelegate =
- tabContents_->GetBookmarkDragDelegate();
+ BookmarkTabHelper::BookmarkDrag* dragDelegate =
+ tab_->bookmark_tab_helper()->GetBookmarkDragDelegate();
BookmarkNodeData dragData;
if(dragDelegate && dragData.ReadFromDragClipboard())
dragDelegate->OnDrop(dragData);
diff --git a/content/browser/renderer_host/render_view_host_delegate.cc b/content/browser/renderer_host/render_view_host_delegate.cc
index 94a17ae..12bbc36 100644
--- a/content/browser/renderer_host/render_view_host_delegate.cc
+++ b/content/browser/renderer_host/render_view_host_delegate.cc
@@ -19,11 +19,6 @@ RenderViewHostDelegate::GetRendererManagementDelegate() {
return NULL;
}
-RenderViewHostDelegate::BookmarkDrag*
-RenderViewHostDelegate::GetBookmarkDragDelegate() {
- return NULL;
-}
-
bool RenderViewHostDelegate::OnMessageReceived(const IPC::Message& message) {
return false;
}
diff --git a/content/browser/renderer_host/render_view_host_delegate.h b/content/browser/renderer_host/render_view_host_delegate.h
index 6024b19..ee9cd26 100644
--- a/content/browser/renderer_host/render_view_host_delegate.h
+++ b/content/browser/renderer_host/render_view_host_delegate.h
@@ -235,20 +235,6 @@ class RenderViewHostDelegate : public IPC::Channel::Listener {
virtual ~RendererManagement() {}
};
- // BookmarkDrag --------------------------------------------------------------
- // Interface for forwarding bookmark drag and drop to extenstions.
-
- class BookmarkDrag {
- public:
- virtual void OnDragEnter(const BookmarkNodeData& data) = 0;
- virtual void OnDragOver(const BookmarkNodeData& data) = 0;
- virtual void OnDragLeave(const BookmarkNodeData& data) = 0;
- virtual void OnDrop(const BookmarkNodeData& data) = 0;
-
- protected:
- virtual ~BookmarkDrag() {}
- };
-
// ---------------------------------------------------------------------------
// Returns the current delegate associated with a feature. May return NULL if
@@ -256,8 +242,6 @@ class RenderViewHostDelegate : public IPC::Channel::Listener {
virtual View* GetViewDelegate();
virtual RendererManagement* GetRendererManagementDelegate();
- virtual BookmarkDrag* GetBookmarkDragDelegate();
-
// IPC::Channel::Listener implementation.
// This is used to give the delegate a chance to filter IPC messages.
virtual bool OnMessageReceived(const IPC::Message& message);
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index b043686..c2ca82d 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -167,7 +167,6 @@ TabContents::TabContents(Profile* profile,
ALLOW_THIS_IN_INITIALIZER_LIST(view_(
TabContentsView::Create(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this)),
- bookmark_drag_(NULL),
is_loading_(false),
crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING),
crashed_error_code_(0),
@@ -1242,15 +1241,6 @@ TabContents::GetRendererManagementDelegate() {
return &render_manager_;
}
-RenderViewHostDelegate::BookmarkDrag* TabContents::GetBookmarkDragDelegate() {
- return bookmark_drag_;
-}
-
-void TabContents::SetBookmarkDragDelegate(
- RenderViewHostDelegate::BookmarkDrag* bookmark_drag) {
- bookmark_drag_ = bookmark_drag;
-}
-
RendererPreferences TabContents::GetRendererPrefs(Profile* profile) const {
return renderer_preferences_;
}
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index bc2bdd3..458d341 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -446,16 +446,6 @@ class TabContents : public PageNavigator,
virtual gfx::NativeWindow GetDialogRootWindow() OVERRIDE;
virtual void OnDialogShown() OVERRIDE;
- // The BookmarkDragDelegate is used to forward bookmark drag and drop events
- // to extensions.
- virtual RenderViewHostDelegate::BookmarkDrag* GetBookmarkDragDelegate();
-
- // It is up to callers to call SetBookmarkDragDelegate(NULL) when
- // |bookmark_drag| is deleted since this class does not take ownership of
- // |bookmark_drag|.
- virtual void SetBookmarkDragDelegate(
- RenderViewHostDelegate::BookmarkDrag* bookmark_drag);
-
// Gets the zoom level for this tab.
double GetZoomLevel() const;
@@ -744,9 +734,6 @@ class TabContents : public PageNavigator,
// Registers and unregisters us for notifications.
NotificationRegistrar registrar_;
- // Handles drag and drop event forwarding to extensions.
- BookmarkDrag* bookmark_drag_;
-
// Data for loading state ----------------------------------------------------
// Indicates whether we're currently loading a resource.