From 7130cc4f2628a63c5c11080258dd017605660278 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 18 Oct 2011 00:23:32 +0000 Subject: [PATCH] Add a new NAVTYPE_LINKDROPPED value to the cef_handler_navtype_t enum passed to OnBeforeResourceLoad() that will be passed when navigation is resulting from a drop (issue #363). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@320 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- include/internal/cef_types.h | 1 + libcef/browser_impl.cc | 18 ++++++++++++++---- libcef/browser_impl.h | 6 ++++++ libcef/browser_webview_delegate.cc | 8 +++++++- libcef/web_drop_target_mac.mm | 3 +++ libcef/web_drop_target_win.cc | 3 +++ 6 files changed, 34 insertions(+), 5 deletions(-) diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 1ff94b279..b84733a06 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -525,6 +525,7 @@ enum cef_handler_navtype_t NAVTYPE_RELOAD, NAVTYPE_FORMRESUBMITTED, NAVTYPE_OTHER, + NAVTYPE_LINKDROPPED, }; /// diff --git a/libcef/browser_impl.cc b/libcef/browser_impl.cc index 3ce9e0d66..04b7fbb81 100644 --- a/libcef/browser_impl.cc +++ b/libcef/browser_impl.cc @@ -163,10 +163,20 @@ CefBrowserImpl::CefBrowserImpl(const CefWindowInfo& windowInfo, const CefBrowserSettings& settings, gfx::NativeView opener, CefRefPtr client) - : window_info_(windowInfo), settings_(settings), opener_(opener), - is_modal_(false), client_(client), webviewhost_(NULL), popuphost_(NULL), - zoom_level_(0.0), can_go_back_(false), can_go_forward_(false), - has_document_(false), main_frame_(NULL), unique_id_(0) + : window_info_(windowInfo), + settings_(settings), + opener_(opener), + is_modal_(false), + client_(client), + webviewhost_(NULL), + popuphost_(NULL), + zoom_level_(0.0), + can_go_back_(false), + can_go_forward_(false), + has_document_(false), + is_dropping_(false), + main_frame_(NULL), + unique_id_(0) #if defined(OS_WIN) , opener_was_disabled_by_modal_loop_(false), internal_modal_message_loop_is_active_(false) diff --git a/libcef/browser_impl.h b/libcef/browser_impl.h index 2292e7c8f..12a567c69 100644 --- a/libcef/browser_impl.h +++ b/libcef/browser_impl.h @@ -327,6 +327,9 @@ public: void set_has_document(bool has_document); bool has_document(); + void set_is_dropping(bool is_dropping) { is_dropping_ = is_dropping; } + bool is_dropping() { return is_dropping_; } + #if defined(OS_WIN) void set_opener_was_disabled_by_modal_loop(bool disabled) { @@ -374,6 +377,9 @@ protected: bool can_go_forward_; bool has_document_; + // True if a drop action is occuring. + bool is_dropping_; + #if defined(OS_WIN) // Context object used to manage printing. printing::PrintingContext print_context_; diff --git a/libcef/browser_webview_delegate.cc b/libcef/browser_webview_delegate.cc index 843f74993..3d54d23e0 100644 --- a/libcef/browser_webview_delegate.cc +++ b/libcef/browser_webview_delegate.cc @@ -738,9 +738,15 @@ WebNavigationPolicy BrowserWebViewDelegate::decidePolicyForNavigation( if(map.size() > 0) static_cast(req.get())->SetHeaderMap(map); + cef_handler_navtype_t navType; + if (browser_->is_dropping()) + navType = NAVTYPE_LINKDROPPED; + else + navType = (cef_handler_navtype_t)type; + // Notify the handler of a browse request bool handled = handler->OnBeforeBrowse(browser_, - browser_->UIT_GetCefFrame(frame), req, (cef_handler_navtype_t)type, + browser_->UIT_GetCefFrame(frame), req, navType, is_redirect); if(handled) return WebKit::WebNavigationPolicyIgnore; diff --git a/libcef/web_drop_target_mac.mm b/libcef/web_drop_target_mac.mm index e648f9c6c..0ef5b4ad4 100644 --- a/libcef/web_drop_target_mac.mm +++ b/libcef/web_drop_target_mac.mm @@ -195,8 +195,11 @@ using WebKit::WebView; NSPoint windowPoint = [info draggingLocation]; NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; + + view_.browser->set_is_dropping(true); webview->dragTargetDrop(gfx::Point(viewPoint.x, viewPoint.y), gfx::Point(screenPoint.x, screenPoint.y)); + view_.browser->set_is_dropping(false); return YES; } diff --git a/libcef/web_drop_target_win.cc b/libcef/web_drop_target_win.cc index 776f19fce..244564a96 100644 --- a/libcef/web_drop_target_win.cc +++ b/libcef/web_drop_target_win.cc @@ -146,9 +146,12 @@ DWORD WebDropTarget::OnDrop(IDataObject* data_object, POINT client_pt = cursor_position; ScreenToClient(GetHWND(), &client_pt); + + browser_->set_is_dropping(true); browser_->UIT_GetWebView()->dragTargetDrop( WebPoint(client_pt.x, client_pt.y), WebPoint(cursor_position.x, cursor_position.y)); + browser_->set_is_dropping(false); current_wvh_ = NULL;