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

Side by Side Diff: ash/drag_drop/drag_drop_controller.cc

Issue 382673002: Fixes for re-enabling more MSVC level 4 warnings: misc edition #2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 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
« no previous file with comments | « no previous file | cloud_print/virtual_driver/win/install/setup.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 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 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 "ash/drag_drop/drag_drop_controller.h" 5 #include "ash/drag_drop/drag_drop_controller.h"
6 6
7 #include "ash/drag_drop/drag_drop_tracker.h" 7 #include "ash/drag_drop/drag_drop_tracker.h"
8 #include "ash/drag_drop/drag_image_view.h" 8 #include "ash/drag_drop/drag_image_view.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/coordinate_conversion.h" 10 #include "ash/wm/coordinate_conversion.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 if (drag_source_window_) 237 if (drag_source_window_)
238 drag_source_window_->RemoveObserver(this); 238 drag_source_window_->RemoveObserver(this);
239 drag_source_window_ = NULL; 239 drag_source_window_ = NULL;
240 } 240 }
241 241
242 return drag_operation_; 242 return drag_operation_;
243 } 243 }
244 244
245 void DragDropController::DragUpdate(aura::Window* target, 245 void DragDropController::DragUpdate(aura::Window* target,
246 const ui::LocatedEvent& event) { 246 const ui::LocatedEvent& event) {
247 aura::client::DragDropDelegate* delegate = NULL;
248 int op = ui::DragDropTypes::DRAG_NONE; 247 int op = ui::DragDropTypes::DRAG_NONE;
249 if (target != drag_window_) { 248 if (target != drag_window_) {
250 if (drag_window_) { 249 if (drag_window_) {
251 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) 250 aura::client::DragDropDelegate* delegate =
251 aura::client::GetDragDropDelegate(drag_window_);
252 if (delegate)
252 delegate->OnDragExited(); 253 delegate->OnDragExited();
253 if (drag_window_ != drag_source_window_) 254 if (drag_window_ != drag_source_window_)
254 drag_window_->RemoveObserver(this); 255 drag_window_->RemoveObserver(this);
255 } 256 }
256 drag_window_ = target; 257 drag_window_ = target;
257 // We are already an observer of |drag_source_window_| so no need to add. 258 // We are already an observer of |drag_source_window_| so no need to add.
258 if (drag_window_ != drag_source_window_) 259 if (drag_window_ != drag_source_window_)
259 drag_window_->AddObserver(this); 260 drag_window_->AddObserver(this);
260 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) { 261 aura::client::DragDropDelegate* delegate =
262 aura::client::GetDragDropDelegate(drag_window_);
263 if (delegate) {
261 ui::DropTargetEvent e(*drag_data_, 264 ui::DropTargetEvent e(*drag_data_,
262 event.location(), 265 event.location(),
263 event.root_location(), 266 event.root_location(),
264 drag_operation_); 267 drag_operation_);
265 e.set_flags(event.flags()); 268 e.set_flags(event.flags());
266 delegate->OnDragEntered(e); 269 delegate->OnDragEntered(e);
267 } 270 }
268 } else { 271 } else {
269 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) { 272 aura::client::DragDropDelegate* delegate =
273 aura::client::GetDragDropDelegate(drag_window_);
274 if (delegate) {
270 ui::DropTargetEvent e(*drag_data_, 275 ui::DropTargetEvent e(*drag_data_,
271 event.location(), 276 event.location(),
272 event.root_location(), 277 event.root_location(),
273 drag_operation_); 278 drag_operation_);
274 e.set_flags(event.flags()); 279 e.set_flags(event.flags());
275 op = delegate->OnDragUpdated(e); 280 op = delegate->OnDragUpdated(e);
276 gfx::NativeCursor cursor = ui::kCursorNoDrop; 281 gfx::NativeCursor cursor = ui::kCursorNoDrop;
277 if (op & ui::DragDropTypes::DRAG_COPY) 282 if (op & ui::DragDropTypes::DRAG_COPY)
278 cursor = ui::kCursorCopy; 283 cursor = ui::kCursorCopy;
279 else if (op & ui::DragDropTypes::DRAG_LINK) 284 else if (op & ui::DragDropTypes::DRAG_LINK)
(...skipping 11 matching lines...) Expand all
291 &root_location_in_screen); 296 &root_location_in_screen);
292 drag_image_->SetScreenPosition( 297 drag_image_->SetScreenPosition(
293 root_location_in_screen - drag_image_offset_); 298 root_location_in_screen - drag_image_offset_);
294 drag_image_->SetTouchDragOperation(op); 299 drag_image_->SetTouchDragOperation(op);
295 } 300 }
296 } 301 }
297 302
298 void DragDropController::Drop(aura::Window* target, 303 void DragDropController::Drop(aura::Window* target,
299 const ui::LocatedEvent& event) { 304 const ui::LocatedEvent& event) {
300 ash::Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorPointer); 305 ash::Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorPointer);
301 aura::client::DragDropDelegate* delegate = NULL;
302 306
303 // We must guarantee that a target gets a OnDragEntered before Drop. WebKit 307 // We must guarantee that a target gets a OnDragEntered before Drop. WebKit
304 // depends on not getting a Drop without DragEnter. This behavior is 308 // depends on not getting a Drop without DragEnter. This behavior is
305 // consistent with drag/drop on other platforms. 309 // consistent with drag/drop on other platforms.
306 if (target != drag_window_) 310 if (target != drag_window_)
307 DragUpdate(target, event); 311 DragUpdate(target, event);
308 DCHECK(target == drag_window_); 312 DCHECK(target == drag_window_);
309 313
310 if ((delegate = aura::client::GetDragDropDelegate(target))) { 314 aura::client::DragDropDelegate* delegate =
315 aura::client::GetDragDropDelegate(target);
316 if (delegate) {
311 ui::DropTargetEvent e( 317 ui::DropTargetEvent e(
312 *drag_data_, event.location(), event.root_location(), drag_operation_); 318 *drag_data_, event.location(), event.root_location(), drag_operation_);
313 e.set_flags(event.flags()); 319 e.set_flags(event.flags());
314 drag_operation_ = delegate->OnPerformDrop(e); 320 drag_operation_ = delegate->OnPerformDrop(e);
315 if (drag_operation_ == 0) 321 if (drag_operation_ == 0)
316 StartCanceledAnimation(kCancelAnimationDuration); 322 StartCanceledAnimation(kCancelAnimationDuration);
317 else 323 else
318 drag_image_.reset(); 324 drag_image_.reset();
319 } else { 325 } else {
320 drag_image_.reset(); 326 drag_image_.reset();
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 if (drag_window_) 557 if (drag_window_)
552 drag_window_->RemoveObserver(this); 558 drag_window_->RemoveObserver(this);
553 drag_window_ = NULL; 559 drag_window_ = NULL;
554 drag_data_ = NULL; 560 drag_data_ = NULL;
555 // Cleanup can be called again while deleting DragDropTracker, so use Pass 561 // Cleanup can be called again while deleting DragDropTracker, so use Pass
556 // instead of reset to avoid double free. 562 // instead of reset to avoid double free.
557 drag_drop_tracker_.Pass(); 563 drag_drop_tracker_.Pass();
558 } 564 }
559 565
560 } // namespace ash 566 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | cloud_print/virtual_driver/win/install/setup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698