Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Side by Side Diff: content/browser/tab_contents/web_contents_drag_win.h

Issue 10024066: TabContents -> WebContentsImpl, part 4. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_WEB_CONTENTS_DRAG_WIN_H_
6 #define CONTENT_BROWSER_TAB_CONTENTS_WEB_CONTENTS_DRAG_WIN_H_
7 #pragma once
8
9 #include "base/callback.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/threading/platform_thread.h"
14 #include "content/common/content_export.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
16 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
18 #include "ui/gfx/native_widget_types.h"
19 #include "ui/gfx/point.h"
20
21 class DragDropThread;
22 class WebDragDest;
23 class WebDragSource;
24 struct WebDropData;
25
26 namespace content {
27 class WebContents;
28 }
29
30 // Windows-specific drag-and-drop handling in WebContentsView.
31 // If we are dragging a virtual file out of the browser, we use a background
32 // thread to do the drag-and-drop because we do not want to run nested
33 // message loop in the UI thread. For all other cases, the drag-and-drop happens
34 // in the UI thread.
35 class CONTENT_EXPORT WebContentsDragWin
36 : NON_EXPORTED_BASE(public ui::DataObjectImpl::Observer),
37 public base::RefCountedThreadSafe<WebContentsDragWin> {
38 public:
39 WebContentsDragWin(gfx::NativeWindow source_window,
40 content::WebContents* web_contents,
41 WebDragDest* drag_dest,
42 const base::Callback<void()>& drag_end_callback);
43 virtual ~WebContentsDragWin();
44
45 // Called on UI thread.
46 void StartDragging(const WebDropData& drop_data,
47 WebKit::WebDragOperationsMask ops,
48 const SkBitmap& image,
49 const gfx::Point& image_offset);
50 void CancelDrag();
51
52 // DataObjectImpl::Observer implementation.
53 // Called on drag-and-drop thread.
54 virtual void OnWaitForData();
55 virtual void OnDataObjectDisposed();
56
57 private:
58 // Called on either UI thread or drag-and-drop thread.
59 void PrepareDragForDownload(const WebDropData& drop_data,
60 ui::OSExchangeData* data,
61 const GURL& page_url,
62 const std::string& page_encoding);
63 void PrepareDragForFileContents(const WebDropData& drop_data,
64 ui::OSExchangeData* data);
65 void PrepareDragForUrl(const WebDropData& drop_data,
66 ui::OSExchangeData* data);
67 void DoDragging(const WebDropData& drop_data,
68 WebKit::WebDragOperationsMask ops,
69 const GURL& page_url,
70 const std::string& page_encoding,
71 const SkBitmap& image,
72 const gfx::Point& image_offset);
73
74 // Called on drag-and-drop thread.
75 void StartBackgroundDragging(const WebDropData& drop_data,
76 WebKit::WebDragOperationsMask ops,
77 const GURL& page_url,
78 const std::string& page_encoding,
79 const SkBitmap& image,
80 const gfx::Point& image_offset);
81 // Called on UI thread.
82 void EndDragging(bool restore_suspended_state);
83 void CloseThread();
84
85 // For debug check only. Access only on drag-and-drop thread.
86 base::PlatformThreadId drag_drop_thread_id_;
87
88 // All the member variables below are accessed on UI thread.
89
90 gfx::NativeWindow source_window_;
91 content::WebContents* web_contents_;
92 WebDragDest* drag_dest_;
93
94 // |drag_source_| is our callback interface passed to the system when we
95 // want to initiate a drag and drop operation. We use it to tell if a
96 // drag operation is happening.
97 scoped_refptr<WebDragSource> drag_source_;
98
99 // The thread used by the drag-out download. This is because we want to avoid
100 // running nested message loop in main UI thread.
101 scoped_ptr<DragDropThread> drag_drop_thread_;
102
103 // The flag to guard that EndDragging is not called twice.
104 bool drag_ended_;
105
106 // Keep track of the old suspended state of the drop target.
107 bool old_drop_target_suspended_state_;
108
109 base::Callback<void()> drag_end_callback_;
110
111 DISALLOW_COPY_AND_ASSIGN(WebContentsDragWin);
112 };
113
114 #endif // CONTENT_BROWSER_TAB_CONTENTS_WEB_CONTENTS_DRAG_WIN_H_
OLDNEW
« no previous file with comments | « content/browser/tab_contents/test_web_contents.cc ('k') | content/browser/tab_contents/web_contents_drag_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698