diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 21:24:34 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 21:24:34 +0000 |
commit | 493ba6474eb990b53cb34f57370d4660b2b6aa55 (patch) | |
tree | c53f8ea803354c4d4006024dda3e39abe6fc9cc0 /chrome/browser/views/frame | |
parent | bbe8521434be58c20cb2a41167bb947e95fc6b4e (diff) | |
download | chromium_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/views/frame')
-rw-r--r-- | chrome/browser/views/frame/browser_root_view.cc | 41 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_root_view.h | 6 |
2 files changed, 27 insertions, 20 deletions
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. |