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

Side by Side Diff: chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc

Issue 8771015: Rename Desktop->RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/views/tab_contents/native_tab_contents_view_aura.h" 5 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.h"
6 6
7 #include "base/event_types.h" 7 #include "base/event_types.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate .h" 9 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate .h"
10 #include "content/browser/renderer_host/render_view_host.h" 10 #include "content/browser/renderer_host/render_view_host.h"
11 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 11 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
12 #include "content/browser/tab_contents/tab_contents.h" 12 #include "content/browser/tab_contents/tab_contents.h"
13 #include "content/browser/tab_contents/tab_contents_view.h" 13 #include "content/browser/tab_contents/tab_contents_view.h"
14 #include "ui/aura/client/aura_constants.h" 14 #include "ui/aura/client/aura_constants.h"
15 #include "ui/aura/client/drag_drop_client.h" 15 #include "ui/aura/client/drag_drop_client.h"
16 #include "ui/aura/desktop.h" 16 #include "ui/aura/root_window.h"
17 #include "ui/aura/event.h" 17 #include "ui/aura/event.h"
18 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
19 #include "ui/base/dragdrop/drag_drop_types.h" 19 #include "ui/base/dragdrop/drag_drop_types.h"
20 #include "ui/base/dragdrop/os_exchange_data.h" 20 #include "ui/base/dragdrop/os_exchange_data.h"
21 #include "ui/base/dragdrop/os_exchange_data_provider_aura.h" 21 #include "ui/base/dragdrop/os_exchange_data_provider_aura.h"
22 #include "ui/views/views_delegate.h" 22 #include "ui/views/views_delegate.h"
23 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
24 #include "webkit/glue/webdropdata.h" 24 #include "webkit/glue/webdropdata.h"
25 25
26 namespace { 26 namespace {
(...skipping 19 matching lines...) Expand all
46 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { 46 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE {
47 ui::EventType type = ui::EventTypeFromNative(event); 47 ui::EventType type = ui::EventTypeFromNative(event);
48 RenderViewHost* rvh = NULL; 48 RenderViewHost* rvh = NULL;
49 switch (type) { 49 switch (type) {
50 case ui::ET_MOUSE_DRAGGED: 50 case ui::ET_MOUSE_DRAGGED:
51 rvh = view_->GetTabContents()->render_view_host(); 51 rvh = view_->GetTabContents()->render_view_host();
52 if (rvh) { 52 if (rvh) {
53 gfx::Point screen_loc = ui::EventLocationFromNative(event); 53 gfx::Point screen_loc = ui::EventLocationFromNative(event);
54 gfx::Point client_loc = screen_loc; 54 gfx::Point client_loc = screen_loc;
55 aura::Window* window = rvh->view()->GetNativeView(); 55 aura::Window* window = rvh->view()->GetNativeView();
56 aura::Window::ConvertPointToWindow(aura::Desktop::GetInstance(), 56 aura::Window::ConvertPointToWindow(aura::RootWindow::GetInstance(),
57 window, &client_loc); 57 window, &client_loc);
58 rvh->DragSourceMovedTo(client_loc.x(), client_loc.y(), 58 rvh->DragSourceMovedTo(client_loc.x(), client_loc.y(),
59 screen_loc.x(), screen_loc.y()); 59 screen_loc.x(), screen_loc.y());
60 } 60 }
61 break; 61 break;
62 default: 62 default:
63 break; 63 break;
64 } 64 }
65 } 65 }
66 66
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 void NativeTabContentsViewAura::InitNativeTabContentsView() { 145 void NativeTabContentsViewAura::InitNativeTabContentsView() {
146 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); 146 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
147 params.native_widget = this; 147 params.native_widget = this;
148 // We don't draw anything so we don't need a texture. 148 // We don't draw anything so we don't need a texture.
149 params.create_texture_for_layer = false; 149 params.create_texture_for_layer = false;
150 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 150 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
151 params.parent = NULL; 151 params.parent = NULL;
152 GetWidget()->Init(params); 152 GetWidget()->Init(params);
153 153
154 // Hide the widget to prevent it from showing up on the desktop. This is 154 // Hide the widget to prevent it from showing up on the root window. This is
155 // needed for TabContentses that aren't immediately added to the tabstrip, 155 // needed for TabContentses that aren't immediately added to the tabstrip,
156 // e.g. the Instant preview contents. 156 // e.g. the Instant preview contents.
157 // TODO(beng): investigate if control-type windows shouldn't be hidden by 157 // TODO(beng): investigate if control-type windows shouldn't be hidden by
158 // default if they are created with no parent. Pending oshima's 158 // default if they are created with no parent. Pending oshima's
159 // change to reflect Widget types onto a ViewProp. 159 // change to reflect Widget types onto a ViewProp.
160 GetWidget()->Hide(); 160 GetWidget()->Hide();
161 } 161 }
162 162
163 void NativeTabContentsViewAura::Unparent() { 163 void NativeTabContentsViewAura::Unparent() {
164 // Nothing to do. 164 // Nothing to do.
(...skipping 23 matching lines...) Expand all
188 188
189 void NativeTabContentsViewAura::SetPageTitle(const string16& title) { 189 void NativeTabContentsViewAura::SetPageTitle(const string16& title) {
190 GetNativeView()->set_title(title); 190 GetNativeView()->set_title(title);
191 } 191 }
192 192
193 void NativeTabContentsViewAura::StartDragging(const WebDropData& drop_data, 193 void NativeTabContentsViewAura::StartDragging(const WebDropData& drop_data,
194 WebKit::WebDragOperationsMask ops, 194 WebKit::WebDragOperationsMask ops,
195 const SkBitmap& image, 195 const SkBitmap& image,
196 const gfx::Point& image_offset) { 196 const gfx::Point& image_offset) {
197 aura::DragDropClient* client = static_cast<aura::DragDropClient*>( 197 aura::DragDropClient* client = static_cast<aura::DragDropClient*>(
198 aura::Desktop::GetInstance()->GetProperty( 198 aura::RootWindow::GetInstance()->GetProperty(
199 aura::kDesktopDragDropClientKey)); 199 aura::kRootWindowDragDropClientKey));
200 if (!client) 200 if (!client)
201 return; 201 return;
202 202
203 ui::OSExchangeDataProviderAura* provider = new ui::OSExchangeDataProviderAura; 203 ui::OSExchangeDataProviderAura* provider = new ui::OSExchangeDataProviderAura;
204 PrepareDragData(drop_data, provider); 204 PrepareDragData(drop_data, provider);
205 if (!image.isNull()) 205 if (!image.isNull())
206 provider->set_drag_image(image); 206 provider->set_drag_image(image);
207 ui::OSExchangeData data(provider); // takes ownership of |provider|. 207 ui::OSExchangeData data(provider); // takes ownership of |provider|.
208 208
209 scoped_ptr<WebDragSourceAura> drag_source(new WebDragSourceAura(this)); 209 scoped_ptr<WebDragSourceAura> drag_source(new WebDragSourceAura(this));
210 210
211 // We need to enable recursive tasks on the message loop so we can get 211 // We need to enable recursive tasks on the message loop so we can get
212 // updates while in the system DoDragDrop loop. 212 // updates while in the system DoDragDrop loop.
213 bool old_state = MessageLoop::current()->NestableTasksAllowed(); 213 bool old_state = MessageLoop::current()->NestableTasksAllowed();
214 MessageLoop::current()->SetNestableTasksAllowed(true); 214 MessageLoop::current()->SetNestableTasksAllowed(true);
215 int result_op = client->StartDragAndDrop(data, ConvertFromWeb(ops)); 215 int result_op = client->StartDragAndDrop(data, ConvertFromWeb(ops));
216 MessageLoop::current()->SetNestableTasksAllowed(old_state); 216 MessageLoop::current()->SetNestableTasksAllowed(old_state);
217 217
218 EndDrag(ConvertToWeb(result_op)); 218 EndDrag(ConvertToWeb(result_op));
219 GetTabContents()->render_view_host()->DragSourceSystemDragEnded(); 219 GetTabContents()->render_view_host()->DragSourceSystemDragEnded();
220 } 220 }
221 221
222 void NativeTabContentsViewAura::CancelDrag() { 222 void NativeTabContentsViewAura::CancelDrag() {
223 aura::DragDropClient* client = static_cast<aura::DragDropClient*>( 223 aura::DragDropClient* client = static_cast<aura::DragDropClient*>(
224 aura::Desktop::GetInstance()->GetProperty( 224 aura::RootWindow::GetInstance()->GetProperty(
225 aura::kDesktopDragDropClientKey)); 225 aura::kRootWindowDragDropClientKey));
226 if (client) 226 if (client)
227 client->DragCancel(); 227 client->DragCancel();
228 } 228 }
229 229
230 bool NativeTabContentsViewAura::IsDoingDrag() const { 230 bool NativeTabContentsViewAura::IsDoingDrag() const {
231 aura::DragDropClient* client = static_cast<aura::DragDropClient*>( 231 aura::DragDropClient* client = static_cast<aura::DragDropClient*>(
232 aura::Desktop::GetInstance()->GetProperty( 232 aura::RootWindow::GetInstance()->GetProperty(
233 aura::kDesktopDragDropClientKey)); 233 aura::kRootWindowDragDropClientKey));
234 if (client) 234 if (client)
235 return client->IsDragDropInProgress(); 235 return client->IsDragDropInProgress();
236 return false; 236 return false;
237 } 237 }
238 238
239 void NativeTabContentsViewAura::SetDragCursor( 239 void NativeTabContentsViewAura::SetDragCursor(
240 WebKit::WebDragOperation operation) { 240 WebKit::WebDragOperation operation) {
241 current_drag_op_ = operation; 241 current_drag_op_ = operation;
242 } 242 }
243 243
(...skipping 27 matching lines...) Expand all
271 // Pass all mouse event to renderer. 271 // Pass all mouse event to renderer.
272 return views::NativeWidgetAura::OnMouseEvent(event); 272 return views::NativeWidgetAura::OnMouseEvent(event);
273 } 273 }
274 274
275 void NativeTabContentsViewAura::OnDragEntered( 275 void NativeTabContentsViewAura::OnDragEntered(
276 const aura::DropTargetEvent& event) { 276 const aura::DropTargetEvent& event) {
277 WebDropData drop_data; 277 WebDropData drop_data;
278 PrepareWebDropData(&drop_data, event.data()); 278 PrepareWebDropData(&drop_data, event.data());
279 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 279 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
280 280
281 gfx::Point screen_pt = aura::Desktop::GetInstance()->last_mouse_location(); 281 gfx::Point screen_pt = aura::RootWindow::GetInstance()->last_mouse_location();
282 GetTabContents()->render_view_host()->DragTargetDragEnter( 282 GetTabContents()->render_view_host()->DragTargetDragEnter(
283 drop_data, event.location(), screen_pt, op); 283 drop_data, event.location(), screen_pt, op);
284 } 284 }
285 285
286 int NativeTabContentsViewAura::OnDragUpdated( 286 int NativeTabContentsViewAura::OnDragUpdated(
287 const aura::DropTargetEvent& event) { 287 const aura::DropTargetEvent& event) {
288 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 288 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
289 gfx::Point screen_pt = aura::Desktop::GetInstance()->last_mouse_location(); 289 gfx::Point screen_pt = aura::RootWindow::GetInstance()->last_mouse_location();
290 GetTabContents()->render_view_host()->DragTargetDragOver( 290 GetTabContents()->render_view_host()->DragTargetDragOver(
291 event.location(), screen_pt, op); 291 event.location(), screen_pt, op);
292 return ConvertFromWeb(current_drag_op_); 292 return ConvertFromWeb(current_drag_op_);
293 } 293 }
294 294
295 void NativeTabContentsViewAura::OnDragExited() { 295 void NativeTabContentsViewAura::OnDragExited() {
296 GetTabContents()->render_view_host()->DragTargetDragLeave(); 296 GetTabContents()->render_view_host()->DragTargetDragLeave();
297 } 297 }
298 298
299 int NativeTabContentsViewAura::OnPerformDrop( 299 int NativeTabContentsViewAura::OnPerformDrop(
300 const aura::DropTargetEvent& event) { 300 const aura::DropTargetEvent& event) {
301 GetTabContents()->render_view_host()->DragTargetDrop( 301 GetTabContents()->render_view_host()->DragTargetDrop(
302 event.location(), aura::Desktop::GetInstance()->last_mouse_location()); 302 event.location(), aura::RootWindow::GetInstance()->last_mouse_location());
303 return current_drag_op_; 303 return current_drag_op_;
304 } 304 }
305 305
306 //////////////////////////////////////////////////////////////////////////////// 306 ////////////////////////////////////////////////////////////////////////////////
307 // NativeTabContentsViewAura, private: 307 // NativeTabContentsViewAura, private:
308 308
309 void NativeTabContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { 309 void NativeTabContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) {
310 gfx::Point screen_loc = aura::Desktop::GetInstance()->last_mouse_location(); 310 gfx::Point screen_loc =
311 aura::RootWindow::GetInstance()->last_mouse_location();
311 gfx::Point client_loc = screen_loc; 312 gfx::Point client_loc = screen_loc;
312 RenderViewHost* rvh = GetTabContents()->render_view_host(); 313 RenderViewHost* rvh = GetTabContents()->render_view_host();
313 aura::Window* window = rvh->view()->GetNativeView(); 314 aura::Window* window = rvh->view()->GetNativeView();
314 aura::Window::ConvertPointToWindow(aura::Desktop::GetInstance(), 315 aura::Window::ConvertPointToWindow(aura::RootWindow::GetInstance(),
315 window, &client_loc); 316 window, &client_loc);
316 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(), 317 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(),
317 screen_loc.y(), ops); 318 screen_loc.y(), ops);
318 } 319 }
319 320
320 //////////////////////////////////////////////////////////////////////////////// 321 ////////////////////////////////////////////////////////////////////////////////
321 // NativeTabContentsView, public: 322 // NativeTabContentsView, public:
322 323
323 // static 324 // static
324 NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView( 325 NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView(
325 internal::NativeTabContentsViewDelegate* delegate) { 326 internal::NativeTabContentsViewDelegate* delegate) {
326 return new NativeTabContentsViewAura(delegate); 327 return new NativeTabContentsViewAura(delegate);
327 } 328 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698