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

Side by Side Diff: chrome/browser/tab_contents/web_drag_source_win.cc

Issue 3660002: Rename ChromeThread to BrowserThread Part13: (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: Created 10 years, 2 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
« no previous file with comments | « chrome/browser/tab_contents/web_contents_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_drag_source_win.h" 5 #include "chrome/browser/tab_contents/web_drag_source_win.h"
6 6
7 #include "base/task.h" 7 #include "base/task.h"
8 #include "chrome/browser/chrome_thread.h" 8 #include "chrome/browser/chrome_thread.h"
9 #include "chrome/browser/renderer_host/render_view_host.h" 9 #include "chrome/browser/renderer_host/render_view_host.h"
10 #include "chrome/browser/tab_contents/tab_contents.h" 10 #include "chrome/browser/tab_contents/tab_contents.h"
(...skipping 26 matching lines...) Expand all
37 render_view_host_(tab_contents->render_view_host()), 37 render_view_host_(tab_contents->render_view_host()),
38 effect_(DROPEFFECT_NONE) { 38 effect_(DROPEFFECT_NONE) {
39 registrar_.Add(this, NotificationType::TAB_CONTENTS_SWAPPED, 39 registrar_.Add(this, NotificationType::TAB_CONTENTS_SWAPPED,
40 Source<TabContents>(tab_contents)); 40 Source<TabContents>(tab_contents));
41 registrar_.Add(this, NotificationType::TAB_CONTENTS_DISCONNECTED, 41 registrar_.Add(this, NotificationType::TAB_CONTENTS_DISCONNECTED,
42 Source<TabContents>(tab_contents)); 42 Source<TabContents>(tab_contents));
43 } 43 }
44 44
45 void WebDragSource::OnDragSourceCancel() { 45 void WebDragSource::OnDragSourceCancel() {
46 // Delegate to the UI thread if we do drag-and-drop in the background thread. 46 // Delegate to the UI thread if we do drag-and-drop in the background thread.
47 if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) { 47 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
48 ChromeThread::PostTask( 48 BrowserThread::PostTask(
49 ChromeThread::UI, FROM_HERE, 49 BrowserThread::UI, FROM_HERE,
50 NewRunnableMethod(this, &WebDragSource::OnDragSourceCancel)); 50 NewRunnableMethod(this, &WebDragSource::OnDragSourceCancel));
51 return; 51 return;
52 } 52 }
53 53
54 if (!render_view_host_) 54 if (!render_view_host_)
55 return; 55 return;
56 56
57 gfx::Point client; 57 gfx::Point client;
58 gfx::Point screen; 58 gfx::Point screen;
59 GetCursorPositions(source_wnd_, &client, &screen); 59 GetCursorPositions(source_wnd_, &client, &screen);
60 render_view_host_->DragSourceEndedAt(client.x(), client.y(), 60 render_view_host_->DragSourceEndedAt(client.x(), client.y(),
61 screen.x(), screen.y(), 61 screen.x(), screen.y(),
62 WebDragOperationNone); 62 WebDragOperationNone);
63 } 63 }
64 64
65 void WebDragSource::OnDragSourceDrop() { 65 void WebDragSource::OnDragSourceDrop() {
66 // On Windows, we check for drag end in IDropSource::QueryContinueDrag which 66 // On Windows, we check for drag end in IDropSource::QueryContinueDrag which
67 // happens before IDropTarget::Drop is called. HTML5 requires the "dragend" 67 // happens before IDropTarget::Drop is called. HTML5 requires the "dragend"
68 // event to happen after the "drop" event. Since Windows calls these two 68 // event to happen after the "drop" event. Since Windows calls these two
69 // directly after each other we can just post a task to handle the 69 // directly after each other we can just post a task to handle the
70 // OnDragSourceDrop after the current task. 70 // OnDragSourceDrop after the current task.
71 ChromeThread::PostTask( 71 BrowserThread::PostTask(
72 ChromeThread::UI, FROM_HERE, 72 BrowserThread::UI, FROM_HERE,
73 NewRunnableMethod(this, &WebDragSource::DelayedOnDragSourceDrop)); 73 NewRunnableMethod(this, &WebDragSource::DelayedOnDragSourceDrop));
74 } 74 }
75 75
76 void WebDragSource::DelayedOnDragSourceDrop() { 76 void WebDragSource::DelayedOnDragSourceDrop() {
77 if (!render_view_host_) 77 if (!render_view_host_)
78 return; 78 return;
79 79
80 gfx::Point client; 80 gfx::Point client;
81 gfx::Point screen; 81 gfx::Point screen;
82 GetCursorPositions(source_wnd_, &client, &screen); 82 GetCursorPositions(source_wnd_, &client, &screen);
83 render_view_host_->DragSourceEndedAt( 83 render_view_host_->DragSourceEndedAt(
84 client.x(), client.y(), screen.x(), screen.y(), 84 client.x(), client.y(), screen.x(), screen.y(),
85 web_drag_utils_win::WinDragOpToWebDragOp(effect_)); 85 web_drag_utils_win::WinDragOpToWebDragOp(effect_));
86 } 86 }
87 87
88 void WebDragSource::OnDragSourceMove() { 88 void WebDragSource::OnDragSourceMove() {
89 // Delegate to the UI thread if we do drag-and-drop in the background thread. 89 // Delegate to the UI thread if we do drag-and-drop in the background thread.
90 if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) { 90 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
91 ChromeThread::PostTask( 91 BrowserThread::PostTask(
92 ChromeThread::UI, FROM_HERE, 92 BrowserThread::UI, FROM_HERE,
93 NewRunnableMethod(this, &WebDragSource::OnDragSourceMove)); 93 NewRunnableMethod(this, &WebDragSource::OnDragSourceMove));
94 return; 94 return;
95 } 95 }
96 96
97 if (!render_view_host_) 97 if (!render_view_host_)
98 return; 98 return;
99 99
100 gfx::Point client; 100 gfx::Point client;
101 gfx::Point screen; 101 gfx::Point screen;
102 GetCursorPositions(source_wnd_, &client, &screen); 102 GetCursorPositions(source_wnd_, &client, &screen);
103 render_view_host_->DragSourceMovedTo(client.x(), client.y(), 103 render_view_host_->DragSourceMovedTo(client.x(), client.y(),
104 screen.x(), screen.y()); 104 screen.x(), screen.y());
105 } 105 }
106 106
107 void WebDragSource::Observe(NotificationType type, 107 void WebDragSource::Observe(NotificationType type,
108 const NotificationSource& source, const NotificationDetails& details) { 108 const NotificationSource& source, const NotificationDetails& details) {
109 if (NotificationType::TAB_CONTENTS_SWAPPED == type) { 109 if (NotificationType::TAB_CONTENTS_SWAPPED == type) {
110 // When the tab contents get swapped, our render view host goes away. 110 // When the tab contents get swapped, our render view host goes away.
111 // That's OK, we can continue the drag, we just can't send messages back to 111 // That's OK, we can continue the drag, we just can't send messages back to
112 // our drag source. 112 // our drag source.
113 render_view_host_ = NULL; 113 render_view_host_ = NULL;
114 } else if (NotificationType::TAB_CONTENTS_DISCONNECTED == type) { 114 } else if (NotificationType::TAB_CONTENTS_DISCONNECTED == type) {
115 // This could be possible when we close the tab and the source is still 115 // This could be possible when we close the tab and the source is still
116 // being used in DoDragDrop at the time that the virtual file is being 116 // being used in DoDragDrop at the time that the virtual file is being
117 // downloaded. 117 // downloaded.
118 render_view_host_ = NULL; 118 render_view_host_ = NULL;
119 } 119 }
120 } 120 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/web_contents_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698