| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/tab_contents/web_drop_target_win.h" |
| 6 |
| 5 #include <windows.h> | 7 #include <windows.h> |
| 6 #include <shlobj.h> | 8 #include <shlobj.h> |
| 7 | 9 |
| 8 #include "chrome/browser/tab_contents/web_drop_target_win.h" | |
| 9 | |
| 10 #include "app/clipboard/clipboard_util_win.h" | 10 #include "app/clipboard/clipboard_util_win.h" |
| 11 #include "app/os_exchange_data.h" | 11 #include "app/os_exchange_data.h" |
| 12 #include "app/os_exchange_data_provider_win.h" | 12 #include "app/os_exchange_data_provider_win.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_drag_data.h" | 13 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
| 14 #include "chrome/browser/renderer_host/render_view_host.h" | 14 #include "chrome/browser/renderer_host/render_view_host.h" |
| 15 #include "chrome/browser/tab_contents/tab_contents.h" | 15 #include "chrome/browser/tab_contents/tab_contents.h" |
| 16 #include "chrome/browser/tab_contents/web_drag_utils_win.h" | 16 #include "chrome/browser/tab_contents/web_drag_utils_win.h" |
| 17 #include "gfx/point.h" | 17 #include "gfx/point.h" |
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 32 DWORD GetPreferredDropEffect(DWORD effect) { | 32 DWORD GetPreferredDropEffect(DWORD effect) { |
| 33 if (effect & DROPEFFECT_COPY) | 33 if (effect & DROPEFFECT_COPY) |
| 34 return DROPEFFECT_COPY; | 34 return DROPEFFECT_COPY; |
| 35 if (effect & DROPEFFECT_LINK) | 35 if (effect & DROPEFFECT_LINK) |
| 36 return DROPEFFECT_LINK; | 36 return DROPEFFECT_LINK; |
| 37 if (effect & DROPEFFECT_MOVE) | 37 if (effect & DROPEFFECT_MOVE) |
| 38 return DROPEFFECT_MOVE; | 38 return DROPEFFECT_MOVE; |
| 39 return DROPEFFECT_NONE; | 39 return DROPEFFECT_NONE; |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // anonymous namespace | 42 } // namespace |
| 43 | 43 |
| 44 // InterstitialDropTarget is like a BaseDropTarget implementation that | 44 // InterstitialDropTarget is like a app::win::DropTarget implementation that |
| 45 // WebDropTarget passes through to if an interstitial is showing. Rather than | 45 // WebDropTarget passes through to if an interstitial is showing. Rather than |
| 46 // passing messages on to the renderer, we just check to see if there's a link | 46 // passing messages on to the renderer, we just check to see if there's a link |
| 47 // in the drop data and handle links as navigations. | 47 // in the drop data and handle links as navigations. |
| 48 class InterstitialDropTarget { | 48 class InterstitialDropTarget { |
| 49 public: | 49 public: |
| 50 explicit InterstitialDropTarget(TabContents* tab_contents) | 50 explicit InterstitialDropTarget(TabContents* tab_contents) |
| 51 : tab_contents_(tab_contents) {} | 51 : tab_contents_(tab_contents) {} |
| 52 | 52 |
| 53 DWORD OnDragEnter(IDataObject* data_object, DWORD effect) { | 53 DWORD OnDragEnter(IDataObject* data_object, DWORD effect) { |
| 54 return ClipboardUtil::HasUrl(data_object) ? GetPreferredDropEffect(effect) | 54 return ClipboardUtil::HasUrl(data_object) ? GetPreferredDropEffect(effect) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 74 } | 74 } |
| 75 return DROPEFFECT_NONE; | 75 return DROPEFFECT_NONE; |
| 76 } | 76 } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 TabContents* tab_contents_; | 79 TabContents* tab_contents_; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(InterstitialDropTarget); | 81 DISALLOW_COPY_AND_ASSIGN(InterstitialDropTarget); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 /////////////////////////////////////////////////////////////////////////////// | |
| 85 // WebDropTarget, public: | |
| 86 | |
| 87 WebDropTarget::WebDropTarget(HWND source_hwnd, TabContents* tab_contents) | 84 WebDropTarget::WebDropTarget(HWND source_hwnd, TabContents* tab_contents) |
| 88 : BaseDropTarget(source_hwnd), | 85 : app::win::DropTarget(source_hwnd), |
| 89 tab_contents_(tab_contents), | 86 tab_contents_(tab_contents), |
| 90 current_rvh_(NULL), | 87 current_rvh_(NULL), |
| 91 drag_cursor_(WebDragOperationNone), | 88 drag_cursor_(WebDragOperationNone), |
| 92 interstitial_drop_target_(new InterstitialDropTarget(tab_contents)) { | 89 interstitial_drop_target_(new InterstitialDropTarget(tab_contents)) { |
| 93 } | 90 } |
| 94 | 91 |
| 95 WebDropTarget::~WebDropTarget() { | 92 WebDropTarget::~WebDropTarget() { |
| 96 } | 93 } |
| 97 | 94 |
| 98 DWORD WebDropTarget::OnDragEnter(IDataObject* data_object, | 95 DWORD WebDropTarget::OnDragEnter(IDataObject* data_object, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 tab_contents_->GetBookmarkDragDelegate()->OnDrop(bookmark_drag_data); | 209 tab_contents_->GetBookmarkDragDelegate()->OnDrop(bookmark_drag_data); |
| 213 } | 210 } |
| 214 | 211 |
| 215 current_rvh_ = NULL; | 212 current_rvh_ = NULL; |
| 216 | 213 |
| 217 // This isn't always correct, but at least it's a close approximation. | 214 // This isn't always correct, but at least it's a close approximation. |
| 218 // For now, we always map a move to a copy to prevent potential data loss. | 215 // For now, we always map a move to a copy to prevent potential data loss. |
| 219 DWORD drop_effect = web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); | 216 DWORD drop_effect = web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); |
| 220 return drop_effect != DROPEFFECT_MOVE ? drop_effect : DROPEFFECT_COPY; | 217 return drop_effect != DROPEFFECT_MOVE ? drop_effect : DROPEFFECT_COPY; |
| 221 } | 218 } |
| OLD | NEW |