diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-19 03:33:44 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-19 03:33:44 +0000 |
commit | 134c47b9e74ab7aa6dce7e1beeaf5e406a925b76 (patch) | |
tree | f4db8cfc40f3eb8a66421ee415f575cf6a76d638 /chrome | |
parent | cf5811e922d5aa215a4094bd88e70c38c6ddc57c (diff) | |
download | chromium_src-134c47b9e74ab7aa6dce7e1beeaf5e406a925b76.zip chromium_src-134c47b9e74ab7aa6dce7e1beeaf5e406a925b76.tar.gz chromium_src-134c47b9e74ab7aa6dce7e1beeaf5e406a925b76.tar.bz2 |
Relands drop support:
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/173025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23690 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_focus_uitest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/browser_init_browsertest.cc | 1 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host.cc | 5 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.cc | 14 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.h | 4 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_menu_button.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_menu_button.h | 4 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_root_view.cc | 41 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_root_view.h | 6 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.h | 9 | ||||
-rw-r--r-- | chrome/test/automated_ui_tests/automated_ui_test_base.cc | 3 | ||||
-rw-r--r-- | chrome/test/automated_ui_tests/automated_ui_tests.cc | 3 |
12 files changed, 83 insertions, 34 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. diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h index d0b5621..53e4fd1 100644 --- a/chrome/common/temp_scaffolding_stubs.h +++ b/chrome/common/temp_scaffolding_stubs.h @@ -24,7 +24,6 @@ #include "googleurl/src/gurl.h" #include "third_party/skia/include/core/SkBitmap.h" - class BookmarkContextMenu; class BookmarkNode; class Browser; @@ -363,14 +362,6 @@ class FontsLanguagesWindowView { void SelectLanguagesTab() { NOTIMPLEMENTED(); } }; -#if !defined(TOOLKIT_VIEWS) -class OSExchangeData { - public: - void SetString(const std::wstring& data) { NOTIMPLEMENTED(); } - void SetURL(const GURL& url, const std::wstring& title) { NOTIMPLEMENTED(); } -}; -#endif - class BaseDragSource { }; diff --git a/chrome/test/automated_ui_tests/automated_ui_test_base.cc b/chrome/test/automated_ui_tests/automated_ui_test_base.cc index 4e842a2..981965d 100644 --- a/chrome/test/automated_ui_tests/automated_ui_test_base.cc +++ b/chrome/test/automated_ui_tests/automated_ui_test_base.cc @@ -9,7 +9,10 @@ #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/automation/window_proxy.h" #include "chrome/test/ui/ui_test.h" + +#if defined(TOOLKIT_VIEWS) #include "views/view.h" +#endif AutomatedUITestBase::AutomatedUITestBase() {} diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc index c29e2aa..a2b6611 100644 --- a/chrome/test/automated_ui_tests/automated_ui_tests.cc +++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc @@ -26,7 +26,10 @@ #include "chrome/test/automation/window_proxy.h" #include "chrome/test/ui/ui_test.h" #include "googleurl/src/gurl.h" + +#if defined(TOOLKIT_VIEWS) #include "views/view.h" +#endif namespace { |