summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/frame
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views/frame')
-rw-r--r--chrome/browser/views/frame/browser_root_view.cc41
-rw-r--r--chrome/browser/views/frame/browser_root_view.h6
2 files changed, 20 insertions, 27 deletions
diff --git a/chrome/browser/views/frame/browser_root_view.cc b/chrome/browser/views/frame/browser_root_view.cc
index 753a3314..5e471c6 100644
--- a/chrome/browser/views/frame/browser_root_view.cc
+++ b/chrome/browser/views/frame/browser_root_view.cc
@@ -13,27 +13,18 @@
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) {
- return (tabstrip_ && tabstrip_->GetView()->IsVisible() &&
- !tabstrip_->IsAnimating());
+ can_drop_ = (tabstrip_ && tabstrip_->GetView()->IsVisible() &&
+ !tabstrip_->IsAnimating() && data.HasURL());
+ return can_drop_;
}
void BrowserRootView::OnDragEntered(const views::DropTargetEvent& event) {
- if (ShouldForwardToTabStrip(event)) {
+ if (can_drop_ && ShouldForwardToTabStrip(event)) {
forwarding_to_tab_strip_ = true;
scoped_ptr<views::DropTargetEvent> mapped_event(MapEventToTabStrip(event));
tabstrip_->GetView()->OnDragEntered(*mapped_event.get());
@@ -41,17 +32,19 @@ void BrowserRootView::OnDragEntered(const views::DropTargetEvent& event) {
}
int BrowserRootView::OnDragUpdated(const views::DropTargetEvent& event) {
- 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;
+ 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();
}
- 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 5ead7cc..370ef5f 100644
--- a/chrome/browser/views/frame/browser_root_view.h
+++ b/chrome/browser/views/frame/browser_root_view.h
@@ -25,9 +25,6 @@ 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);
@@ -46,6 +43,9 @@ 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.