summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-18 21:24:34 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-18 21:24:34 +0000
commit493ba6474eb990b53cb34f57370d4660b2b6aa55 (patch)
treec53f8ea803354c4d4006024dda3e39abe6fc9cc0 /chrome/browser
parentbbe8521434be58c20cb2a41167bb947e95fc6b4e (diff)
downloadchromium_src-493ba6474eb990b53cb34f57370d4660b2b6aa55.zip
chromium_src-493ba6474eb990b53cb34f57370d4660b2b6aa55.tar.gz
chromium_src-493ba6474eb990b53cb34f57370d4660b2b6aa55.tar.bz2
Adds drop support for views on gtk. As X lazily provides drop data I
needed to tweak the views API a bit. BUG=none TEST=none Review URL: http://codereview.chromium.org/165407 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23653 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_focus_uitest.cc11
-rw-r--r--chrome/browser/browser_init_browsertest.cc1
-rw-r--r--chrome/browser/renderer_host/render_widget_host.cc5
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc14
-rw-r--r--chrome/browser/views/bookmark_bar_view.h4
-rw-r--r--chrome/browser/views/bookmark_menu_button.cc16
-rw-r--r--chrome/browser/views/bookmark_menu_button.h4
-rw-r--r--chrome/browser/views/frame/browser_root_view.cc41
-rw-r--r--chrome/browser/views/frame/browser_root_view.h6
9 files changed, 77 insertions, 25 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 1c1c012..4007ebd 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -7,12 +7,11 @@
#include "base/ref_counted.h"
#include "chrome/browser/automation/ui_controls.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/browser/tab_contents/interstitial_page.h"
#include "chrome/browser/view_ids.h"
-#include "chrome/browser/views/frame/browser_view.h"
-#include "chrome/browser/views/location_bar_view.h"
-#include "chrome/browser/views/tab_contents/tab_contents_container.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"
@@ -20,6 +19,12 @@
#include "views/view.h"
#include "views/window/window.h"
+#if defined(TOOLKIT_VIEWS)
+#include "chrome/browser/views/frame/browser_view.h"
+#include "chrome/browser/views/location_bar_view.h"
+#include "chrome/browser/views/tab_contents/tab_contents_container.h"
+#endif
+
#if defined(OS_LINUX)
#include "chrome/browser/gtk/view_id_util.h"
#endif
diff --git a/chrome/browser/browser_init_browsertest.cc b/chrome/browser/browser_init_browsertest.cc
index a343caf..f5337f4 100644
--- a/chrome/browser/browser_init_browsertest.cc
+++ b/chrome/browser/browser_init_browsertest.cc
@@ -6,7 +6,6 @@
#include "chrome/browser/browser_init.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_window.h"
-#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/test/in_process_browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index 996f63f..c7d7e19 100644
--- a/chrome/browser/renderer_host/render_widget_host.cc
+++ b/chrome/browser/renderer_host/render_widget_host.cc
@@ -15,9 +15,12 @@
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/render_messages.h"
-#include "views/view.h"
#include "webkit/glue/webcursor.h"
+#if defined(TOOLKIT_VIEWS)
+#include "views/view.h"
+#endif
+
#if defined(OS_WIN)
#include "base/gfx/gdi_util.h"
#include "chrome/app/chrome_dll_resource.h"
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 28bdec8..4afe926 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -870,6 +870,20 @@ void BookmarkBarView::PaintChildren(gfx::Canvas* canvas) {
}
}
+bool BookmarkBarView::GetDropFormats(
+ int* formats,
+ std::set<OSExchangeData::CustomFormat>* custom_formats) {
+ if (!model_ || !model_->IsLoaded())
+ return false;
+ *formats = OSExchangeData::URL;
+ custom_formats->insert(BookmarkDragData::GetBookmarkCustomFormat());
+ return true;
+}
+
+bool BookmarkBarView::AreDropTypesRequired() {
+ return true;
+}
+
bool BookmarkBarView::CanDrop(const OSExchangeData& data) {
if (!model_ || !model_->IsLoaded())
return false;
diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h
index b82b669..caca1aa 100644
--- a/chrome/browser/views/bookmark_bar_view.h
+++ b/chrome/browser/views/bookmark_bar_view.h
@@ -97,6 +97,10 @@ class BookmarkBarView : public views::View,
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
virtual void Paint(gfx::Canvas* canvas);
virtual void PaintChildren(gfx::Canvas* canvas);
+ virtual bool GetDropFormats(
+ int* formats,
+ std::set<OSExchangeData::CustomFormat>* custom_formats);
+ virtual bool AreDropTypesRequired();
virtual bool CanDrop(const OSExchangeData& data);
virtual void OnDragEntered(const views::DropTargetEvent& event);
virtual int OnDragUpdated(const views::DropTargetEvent& event);
diff --git a/chrome/browser/views/bookmark_menu_button.cc b/chrome/browser/views/bookmark_menu_button.cc
index 4a4889b..577189e 100644
--- a/chrome/browser/views/bookmark_menu_button.cc
+++ b/chrome/browser/views/bookmark_menu_button.cc
@@ -40,6 +40,22 @@ BookmarkMenuButton::~BookmarkMenuButton() {
bookmark_drop_menu_->set_observer(NULL);
}
+bool BookmarkMenuButton::GetDropFormats(
+ int* formats,
+ std::set<OSExchangeData::CustomFormat>* custom_formats) {
+ BookmarkModel* bookmark_model = GetBookmarkModel();
+ if (!bookmark_model || !bookmark_model->IsLoaded())
+ return false;
+
+ *formats = OSExchangeData::URL;
+ custom_formats->insert(BookmarkDragData::GetBookmarkCustomFormat());
+ return true;
+}
+
+bool BookmarkMenuButton::AreDropTypesRequired() {
+ return true;
+}
+
bool BookmarkMenuButton::CanDrop(const OSExchangeData& data) {
BookmarkModel* bookmark_model = GetBookmarkModel();
if (!bookmark_model || !bookmark_model->IsLoaded())
diff --git a/chrome/browser/views/bookmark_menu_button.h b/chrome/browser/views/bookmark_menu_button.h
index aeed549..7a7fd7e 100644
--- a/chrome/browser/views/bookmark_menu_button.h
+++ b/chrome/browser/views/bookmark_menu_button.h
@@ -26,6 +26,10 @@ class BookmarkMenuButton : public views::MenuButton,
virtual ~BookmarkMenuButton();
// View drop methods.
+ virtual bool GetDropFormats(
+ int* formats,
+ std::set<OSExchangeData::CustomFormat>* custom_formats);
+ virtual bool AreDropTypesRequired();
virtual bool CanDrop(const OSExchangeData& data);
virtual int OnDragUpdated(const views::DropTargetEvent& event);
virtual void OnDragExited();
diff --git a/chrome/browser/views/frame/browser_root_view.cc b/chrome/browser/views/frame/browser_root_view.cc
index 5e471c6..753a3314 100644
--- a/chrome/browser/views/frame/browser_root_view.cc
+++ b/chrome/browser/views/frame/browser_root_view.cc
@@ -13,18 +13,27 @@
BrowserRootView::BrowserRootView(views::Widget* widget)
: views::RootView(widget),
tabstrip_(NULL),
- can_drop_(false),
forwarding_to_tab_strip_(false) {
}
+bool BrowserRootView::GetDropFormats(
+ int* formats,
+ std::set<OSExchangeData::CustomFormat>* custom_formats) {
+ if (tabstrip_ && tabstrip_->GetView()->IsVisible() &&
+ !tabstrip_->IsAnimating()) {
+ *formats = OSExchangeData::URL;
+ return true;
+ }
+ return false;
+}
+
bool BrowserRootView::CanDrop(const OSExchangeData& data) {
- can_drop_ = (tabstrip_ && tabstrip_->GetView()->IsVisible() &&
- !tabstrip_->IsAnimating() && data.HasURL());
- return can_drop_;
+ return (tabstrip_ && tabstrip_->GetView()->IsVisible() &&
+ !tabstrip_->IsAnimating());
}
void BrowserRootView::OnDragEntered(const views::DropTargetEvent& event) {
- if (can_drop_ && ShouldForwardToTabStrip(event)) {
+ if (ShouldForwardToTabStrip(event)) {
forwarding_to_tab_strip_ = true;
scoped_ptr<views::DropTargetEvent> mapped_event(MapEventToTabStrip(event));
tabstrip_->GetView()->OnDragEntered(*mapped_event.get());
@@ -32,19 +41,17 @@ void BrowserRootView::OnDragEntered(const views::DropTargetEvent& event) {
}
int BrowserRootView::OnDragUpdated(const views::DropTargetEvent& event) {
- if (can_drop_) {
- if (ShouldForwardToTabStrip(event)) {
- scoped_ptr<views::DropTargetEvent> mapped_event(
- MapEventToTabStrip(event));
- if (!forwarding_to_tab_strip_) {
- tabstrip_->GetView()->OnDragEntered(*mapped_event.get());
- forwarding_to_tab_strip_ = true;
- }
- return tabstrip_->GetView()->OnDragUpdated(*mapped_event.get());
- } else if (forwarding_to_tab_strip_) {
- forwarding_to_tab_strip_ = false;
- tabstrip_->GetView()->OnDragExited();
+ if (ShouldForwardToTabStrip(event)) {
+ scoped_ptr<views::DropTargetEvent> mapped_event(
+ MapEventToTabStrip(event));
+ if (!forwarding_to_tab_strip_) {
+ tabstrip_->GetView()->OnDragEntered(*mapped_event.get());
+ forwarding_to_tab_strip_ = true;
}
+ return tabstrip_->GetView()->OnDragUpdated(*mapped_event.get());
+ } else if (forwarding_to_tab_strip_) {
+ forwarding_to_tab_strip_ = false;
+ tabstrip_->GetView()->OnDragExited();
}
return DragDropTypes::DRAG_NONE;
}
diff --git a/chrome/browser/views/frame/browser_root_view.h b/chrome/browser/views/frame/browser_root_view.h
index 370ef5f..5ead7cc 100644
--- a/chrome/browser/views/frame/browser_root_view.h
+++ b/chrome/browser/views/frame/browser_root_view.h
@@ -25,6 +25,9 @@ class BrowserRootView : public views::RootView {
// tabstrip set.
void set_tabstrip(TabStripWrapper* tabstrip) { tabstrip_ = tabstrip; }
+ virtual bool GetDropFormats(
+ int* formats,
+ std::set<OSExchangeData::CustomFormat>* custom_formats);
virtual bool CanDrop(const OSExchangeData& data);
virtual void OnDragEntered(const views::DropTargetEvent& event);
virtual int OnDragUpdated(const views::DropTargetEvent& event);
@@ -43,9 +46,6 @@ class BrowserRootView : public views::RootView {
// The TabStrip.
TabStripWrapper* tabstrip_;
- // Is a drop allowed? This is set by CanDrop.
- bool can_drop_;
-
// If true, drag and drop events are being forwarded to the tab strip.
// This is used to determine when to send OnDragEntered and OnDragExited
// to the tab strip.