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

Side by Side Diff: ui/app_list/views/apps_grid_view.cc

Issue 2143893002: Purge the App Launcher code from Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 4 years, 4 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
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 "ui/app_list/views/apps_grid_view.h" 5 #include "ui/app_list/views/apps_grid_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 11 matching lines...) Expand all
22 #include "ui/app_list/views/apps_grid_view_delegate.h" 22 #include "ui/app_list/views/apps_grid_view_delegate.h"
23 #include "ui/app_list/views/page_switcher.h" 23 #include "ui/app_list/views/page_switcher.h"
24 #include "ui/app_list/views/pulsing_block_view.h" 24 #include "ui/app_list/views/pulsing_block_view.h"
25 #include "ui/app_list/views/top_icon_animation_view.h" 25 #include "ui/app_list/views/top_icon_animation_view.h"
26 #include "ui/compositor/scoped_layer_animation_settings.h" 26 #include "ui/compositor/scoped_layer_animation_settings.h"
27 #include "ui/events/event.h" 27 #include "ui/events/event.h"
28 #include "ui/gfx/animation/animation.h" 28 #include "ui/gfx/animation/animation.h"
29 #include "ui/gfx/geometry/vector2d.h" 29 #include "ui/gfx/geometry/vector2d.h"
30 #include "ui/gfx/geometry/vector2d_conversions.h" 30 #include "ui/gfx/geometry/vector2d_conversions.h"
31 #include "ui/views/border.h" 31 #include "ui/views/border.h"
32 #include "ui/views/controls/label.h"
32 #include "ui/views/view_model_utils.h" 33 #include "ui/views/view_model_utils.h"
33 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
34 35
35 #if defined(USE_AURA) 36 #if defined(USE_AURA)
36 #include "ui/aura/window.h" 37 #include "ui/aura/window.h"
37 #include "ui/aura/window_event_dispatcher.h" 38 #include "ui/aura/window_event_dispatcher.h"
38 #if defined(OS_WIN)
39 #include "ui/views/win/hwnd_util.h"
40 #endif // defined(OS_WIN)
41 #endif // defined(USE_AURA) 39 #endif // defined(USE_AURA)
42 40
43 #if defined(OS_WIN)
44 #include "base/command_line.h"
45 #include "base/files/file_path.h"
46 #include "base/win/shortcut.h"
47 #include "ui/base/dragdrop/drag_utils.h"
48 #include "ui/base/dragdrop/drop_target_win.h"
49 #include "ui/base/dragdrop/os_exchange_data.h"
50 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
51 #include "ui/display/win/screen_win.h"
52 #endif
53
54 namespace app_list { 41 namespace app_list {
55 42
56 namespace { 43 namespace {
57 44
58 // Distance a drag needs to be from the app grid to be considered 'outside', at 45 // Distance a drag needs to be from the app grid to be considered 'outside', at
59 // which point we rearrange the apps to their pre-drag configuration, as a drop 46 // which point we rearrange the apps to their pre-drag configuration, as a drop
60 // then would be canceled. We have a buffer to make it easier to drag apps to 47 // then would be canceled. We have a buffer to make it easier to drag apps to
61 // other pages. 48 // other pages.
62 const int kDragBufferPx = 20; 49 const int kDragBufferPx = 20;
63 50
(...skipping 15 matching lines...) Expand all
79 const int kExperimentalTileLeftRightPadding = 10; 66 const int kExperimentalTileLeftRightPadding = 10;
80 const int kExperimentalTileBottomPadding = 6; 67 const int kExperimentalTileBottomPadding = 6;
81 const int kExperimentalTileTopPadding = 6; 68 const int kExperimentalTileTopPadding = 6;
82 69
83 // Width in pixels of the area on the sides that triggers a page flip. 70 // Width in pixels of the area on the sides that triggers a page flip.
84 const int kPageFlipZoneSize = 40; 71 const int kPageFlipZoneSize = 40;
85 72
86 // Delay in milliseconds to do the page flip. 73 // Delay in milliseconds to do the page flip.
87 const int kPageFlipDelayInMs = 1000; 74 const int kPageFlipDelayInMs = 1000;
88 75
89 // How many pages on either side of the selected one we prerender. Currently 0
90 // to test impact of prerendering on UI jank for http://crbug.com/440224. Was 1.
91 const int kPrerenderPages = 0;
92
93 // The drag and drop proxy should get scaled by this factor. 76 // The drag and drop proxy should get scaled by this factor.
94 const float kDragAndDropProxyScale = 1.5f; 77 const float kDragAndDropProxyScale = 1.5f;
95 78
96 // Delays in milliseconds to show folder dropping preview circle. 79 // Delays in milliseconds to show folder dropping preview circle.
97 const int kFolderDroppingDelay = 150; 80 const int kFolderDroppingDelay = 150;
98 81
99 // Delays in milliseconds to show re-order preview. 82 // Delays in milliseconds to show re-order preview.
100 const int kReorderDelay = 120; 83 const int kReorderDelay = 120;
101 84
102 // Delays in milliseconds to show folder item reparent UI. 85 // Delays in milliseconds to show folder item reparent UI.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 (static_cast<AppListFolderItem*>(item))->folder_type() == 209 (static_cast<AppListFolderItem*>(item))->folder_type() ==
227 AppListFolderItem::FOLDER_TYPE_OEM; 210 AppListFolderItem::FOLDER_TYPE_OEM;
228 } 211 }
229 212
230 int ClampToRange(int value, int min, int max) { 213 int ClampToRange(int value, int min, int max) {
231 return std::min(std::max(value, min), max); 214 return std::min(std::max(value, min), max);
232 } 215 }
233 216
234 } // namespace 217 } // namespace
235 218
236 #if defined(OS_WIN)
237 // Interprets drag events sent from Windows via the drag/drop API and forwards
238 // them to AppsGridView.
239 // On Windows, in order to have the OS perform the drag properly we need to
240 // provide it with a shortcut file which may or may not exist at the time the
241 // drag is started. Therefore while waiting for that shortcut to be located we
242 // just do a regular "internal" drag and transition into the synchronous drag
243 // when the shortcut is found/created. Hence a synchronous drag is an optional
244 // phase of a regular drag and non-Windows platforms drags are equivalent to a
245 // Windows drag that never enters the synchronous drag phase.
246 class SynchronousDrag : public ui::DragSourceWin {
247 public:
248 SynchronousDrag(AppsGridView* grid_view,
249 AppListItemView* drag_view,
250 const gfx::Point& drag_view_offset)
251 : grid_view_(grid_view),
252 drag_view_(drag_view),
253 drag_view_offset_(drag_view_offset),
254 has_shortcut_path_(false),
255 running_(false),
256 canceled_(false) {}
257
258 void set_shortcut_path(const base::FilePath& shortcut_path) {
259 has_shortcut_path_ = true;
260 shortcut_path_ = shortcut_path;
261 }
262
263 bool running() { return running_; }
264
265 bool CanRun() {
266 return has_shortcut_path_ && !running_;
267 }
268
269 void Run() {
270 DCHECK(CanRun());
271
272 // Prevent the synchronous dragger being destroyed while the drag is
273 // running.
274 Microsoft::WRL::ComPtr<SynchronousDrag> this_ref = this;
275 running_ = true;
276
277 ui::OSExchangeData data;
278 SetupExchangeData(&data);
279
280 // Hide the dragged view because the OS is going to create its own.
281 drag_view_->SetVisible(false);
282
283 // Blocks until the drag is finished. Calls into the ui::DragSourceWin
284 // methods.
285 DWORD effects;
286 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data),
287 this, DROPEFFECT_MOVE | DROPEFFECT_LINK, &effects);
288
289 // If |drag_view_| is NULL the drag was ended by some reentrant code.
290 if (drag_view_) {
291 // Make the drag view visible again.
292 drag_view_->SetVisible(true);
293 drag_view_->OnSyncDragEnd();
294
295 grid_view_->EndDrag(canceled_ || !IsCursorWithinGridView());
296 }
297 }
298
299 void EndDragExternally() {
300 CancelDrag();
301 DCHECK(drag_view_);
302 drag_view_->SetVisible(true);
303 drag_view_ = NULL;
304 }
305
306 private:
307 // Overridden from ui::DragSourceWin.
308 void OnDragSourceCancel() override { canceled_ = true; }
309
310 void OnDragSourceDrop() override {}
311
312 void OnDragSourceMove() override {
313 grid_view_->UpdateDrag(AppsGridView::MOUSE, GetCursorInGridViewCoords());
314 }
315
316 void SetupExchangeData(ui::OSExchangeData* data) {
317 data->SetFilename(shortcut_path_);
318 drag_utils::SetDragImageOnDataObject(
319 drag_view_->GetDragImage(),
320 drag_view_offset_ - drag_view_->GetDragImageOffset(), data);
321 }
322
323 HWND GetGridViewHWND() {
324 return views::HWNDForView(grid_view_);
325 }
326
327 bool IsCursorWithinGridView() {
328 POINT p;
329 GetCursorPos(&p);
330 return GetGridViewHWND() == WindowFromPoint(p);
331 }
332
333 gfx::Point GetCursorInGridViewCoords() {
334 POINT p;
335 GetCursorPos(&p);
336 ScreenToClient(GetGridViewHWND(), &p);
337 gfx::Point grid_view_pt(p.x, p.y);
338 grid_view_pt =
339 display::win::ScreenWin::ClientToDIPPoint(GetGridViewHWND(),
340 grid_view_pt);
341 views::View::ConvertPointFromWidget(grid_view_, &grid_view_pt);
342 return grid_view_pt;
343 }
344
345 AppsGridView* grid_view_;
346 AppListItemView* drag_view_;
347 gfx::Point drag_view_offset_;
348 bool has_shortcut_path_;
349 base::FilePath shortcut_path_;
350 bool running_;
351 bool canceled_;
352
353 DISALLOW_COPY_AND_ASSIGN(SynchronousDrag);
354 };
355 #endif // defined(OS_WIN)
356
357 AppsGridView::AppsGridView(AppsGridViewDelegate* delegate) 219 AppsGridView::AppsGridView(AppsGridViewDelegate* delegate)
358 : model_(NULL), 220 : model_(NULL),
359 item_list_(NULL), 221 item_list_(NULL),
360 delegate_(delegate), 222 delegate_(delegate),
361 folder_delegate_(NULL), 223 folder_delegate_(NULL),
362 page_switcher_view_(NULL), 224 page_switcher_view_(NULL),
363 cols_(0), 225 cols_(0),
364 rows_per_page_(0), 226 rows_per_page_(0),
365 selected_view_(NULL), 227 selected_view_(NULL),
366 drag_view_(NULL), 228 drag_view_(NULL),
367 drag_start_page_(-1), 229 drag_start_page_(-1),
368 #if defined(OS_WIN)
369 use_synchronous_drag_(true),
370 #endif
371 drag_pointer_(NONE), 230 drag_pointer_(NONE),
372 drop_attempt_(DROP_FOR_NONE), 231 drop_attempt_(DROP_FOR_NONE),
373 drag_and_drop_host_(NULL), 232 drag_and_drop_host_(NULL),
374 forward_events_to_drag_and_drop_host_(false), 233 forward_events_to_drag_and_drop_host_(false),
375 page_flip_target_(-1), 234 page_flip_target_(-1),
376 page_flip_delay_in_ms_(kPageFlipDelayInMs), 235 page_flip_delay_in_ms_(kPageFlipDelayInMs),
377 bounds_animator_(this), 236 bounds_animator_(this),
378 activated_folder_item_view_(NULL), 237 activated_folder_item_view_(NULL),
379 dragging_for_reparent_item_(false) { 238 dragging_for_reparent_item_(false) {
380 SetPaintToLayer(true); 239 SetPaintToLayer(true);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 362
504 drag_view_ = view; 363 drag_view_ = view;
505 drag_view_init_index_ = GetIndexOfView(drag_view_); 364 drag_view_init_index_ = GetIndexOfView(drag_view_);
506 drag_view_offset_ = event.location(); 365 drag_view_offset_ = event.location();
507 drag_start_page_ = pagination_model_.selected_page(); 366 drag_start_page_ = pagination_model_.selected_page();
508 reorder_placeholder_ = drag_view_init_index_; 367 reorder_placeholder_ = drag_view_init_index_;
509 ExtractDragLocation(event, &drag_start_grid_view_); 368 ExtractDragLocation(event, &drag_start_grid_view_);
510 drag_view_start_ = gfx::Point(drag_view_->x(), drag_view_->y()); 369 drag_view_start_ = gfx::Point(drag_view_->x(), drag_view_->y());
511 } 370 }
512 371
513 void AppsGridView::StartSettingUpSynchronousDrag() {
514 #if defined(OS_WIN)
515 if (!delegate_ || !use_synchronous_drag_)
516 return;
517
518 // Folders and downloading items can't be integrated with the OS.
519 if (IsFolderItem(drag_view_->item()) || drag_view_->item()->is_installing())
520 return;
521
522 // Favor the drag and drop host over native win32 drag. For the Win8/ash
523 // launcher we want to have ashes drag and drop over win32's.
524 if (drag_and_drop_host_)
525 return;
526
527 // Never create a second synchronous drag if the drag started in a folder.
528 if (IsDraggingForReparentInRootLevelGridView())
529 return;
530
531 synchronous_drag_ = Microsoft::WRL::Make<SynchronousDrag>(this, drag_view_,
532 drag_view_offset_);
533 delegate_->GetShortcutPathForApp(drag_view_->item()->id(),
534 base::Bind(&AppsGridView::OnGotShortcutPath,
535 base::Unretained(this),
536 synchronous_drag_));
537 #endif
538 }
539
540 bool AppsGridView::RunSynchronousDrag() {
541 #if defined(OS_WIN)
542 if (!synchronous_drag_.Get())
543 return false;
544
545 if (synchronous_drag_->CanRun()) {
546 if (IsDraggingForReparentInHiddenGridView())
547 folder_delegate_->SetRootLevelDragViewVisible(false);
548 synchronous_drag_->Run();
549 synchronous_drag_ = nullptr;
550 return true;
551 } else if (!synchronous_drag_->running()) {
552 // The OS drag is not ready yet. If the root grid has a drag view because
553 // a reparent has started, ensure it is visible.
554 if (IsDraggingForReparentInHiddenGridView())
555 folder_delegate_->SetRootLevelDragViewVisible(true);
556 }
557 #endif
558 return false;
559 }
560
561 void AppsGridView::CleanUpSynchronousDrag() {
562 #if defined(OS_WIN)
563 if (synchronous_drag_.Get())
564 synchronous_drag_->EndDragExternally();
565
566 synchronous_drag_ = nullptr;
567 #endif
568 }
569
570 #if defined(OS_WIN)
571 void AppsGridView::OnGotShortcutPath(
572 Microsoft::WRL::ComPtr<SynchronousDrag> synchronous_drag,
573 const base::FilePath& path) {
574 // Drag may have ended before we get the shortcut path or a new drag may have
575 // begun.
576 if (synchronous_drag_ != synchronous_drag)
577 return;
578 // Setting the shortcut path here means the next time we hit UpdateDrag()
579 // we'll enter the synchronous drag.
580 // NOTE we don't Run() the drag here because that causes animations not to
581 // update for some reason.
582 synchronous_drag_->set_shortcut_path(path);
583 DCHECK(synchronous_drag_->CanRun());
584 }
585 #endif
586
587 bool AppsGridView::UpdateDragFromItem(Pointer pointer, 372 bool AppsGridView::UpdateDragFromItem(Pointer pointer,
588 const ui::LocatedEvent& event) { 373 const ui::LocatedEvent& event) {
589 if (!drag_view_) 374 if (!drag_view_)
590 return false; // Drag canceled. 375 return false; // Drag canceled.
591 376
592 gfx::Point drag_point_in_grid_view; 377 gfx::Point drag_point_in_grid_view;
593 ExtractDragLocation(event, &drag_point_in_grid_view); 378 ExtractDragLocation(event, &drag_point_in_grid_view);
594 UpdateDrag(pointer, drag_point_in_grid_view); 379 UpdateDrag(pointer, drag_point_in_grid_view);
595 if (!dragging()) 380 if (!dragging())
596 return false; 381 return false;
597 382
598 // If a drag and drop host is provided, see if the drag operation needs to be 383 // If a drag and drop host is provided, see if the drag operation needs to be
599 // forwarded. 384 // forwarded.
600 gfx::Point location_in_screen = drag_point_in_grid_view; 385 gfx::Point location_in_screen = drag_point_in_grid_view;
601 views::View::ConvertPointToScreen(this, &location_in_screen); 386 views::View::ConvertPointToScreen(this, &location_in_screen);
602 DispatchDragEventToDragAndDropHost(location_in_screen); 387 DispatchDragEventToDragAndDropHost(location_in_screen);
603 if (drag_and_drop_host_) 388 if (drag_and_drop_host_)
604 drag_and_drop_host_->UpdateDragIconProxy(location_in_screen); 389 drag_and_drop_host_->UpdateDragIconProxy(location_in_screen);
605 return true; 390 return true;
606 } 391 }
607 392
608 void AppsGridView::UpdateDrag(Pointer pointer, const gfx::Point& point) { 393 void AppsGridView::UpdateDrag(Pointer pointer, const gfx::Point& point) {
609 if (folder_delegate_) 394 if (folder_delegate_)
610 UpdateDragStateInsideFolder(pointer, point); 395 UpdateDragStateInsideFolder(pointer, point);
611 396
612 if (!drag_view_) 397 if (!drag_view_)
613 return; // Drag canceled. 398 return; // Drag canceled.
614 399
615 if (RunSynchronousDrag())
616 return;
617
618 gfx::Vector2d drag_vector(point - drag_start_grid_view_); 400 gfx::Vector2d drag_vector(point - drag_start_grid_view_);
619 if (!dragging() && ExceededDragThreshold(drag_vector)) { 401 if (!dragging() && ExceededDragThreshold(drag_vector)) {
620 drag_pointer_ = pointer; 402 drag_pointer_ = pointer;
621 // Move the view to the front so that it appears on top of other views. 403 // Move the view to the front so that it appears on top of other views.
622 ReorderChildView(drag_view_, -1); 404 ReorderChildView(drag_view_, -1);
623 bounds_animator_.StopAnimatingView(drag_view_); 405 bounds_animator_.StopAnimatingView(drag_view_);
624 // Stopping the animation may have invalidated our drag view due to the 406 // Stopping the animation may have invalidated our drag view due to the
625 // view hierarchy changing. 407 // view hierarchy changing.
626 if (!drag_view_) 408 if (!drag_view_)
627 return; 409 return;
628 410
629 StartSettingUpSynchronousDrag();
630 if (!dragging_for_reparent_item_) 411 if (!dragging_for_reparent_item_)
631 StartDragAndDropHostDrag(point); 412 StartDragAndDropHostDrag(point);
632 } 413 }
633 414
634 if (drag_pointer_ != pointer) 415 if (drag_pointer_ != pointer)
635 return; 416 return;
636 417
637 drag_view_->SetPosition(drag_view_start_ + drag_vector); 418 drag_view_->SetPosition(drag_view_start_ + drag_vector);
638 419
639 last_drag_point_ = point; 420 last_drag_point_ = point;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 int i = reorder_drop_target_.slot; 508 int i = reorder_drop_target_.slot;
728 gfx::Rect bounds = view_model_.ideal_bounds(i); 509 gfx::Rect bounds = view_model_.ideal_bounds(i);
729 drag_view_->SetBoundsRect(bounds); 510 drag_view_->SetBoundsRect(bounds);
730 } 511 }
731 // Fade in slowly if it landed in the shelf. 512 // Fade in slowly if it landed in the shelf.
732 SetViewHidden(drag_view_, false /* show */, 513 SetViewHidden(drag_view_, false /* show */,
733 !landed_in_drag_and_drop_host /* animate */); 514 !landed_in_drag_and_drop_host /* animate */);
734 } 515 }
735 } 516 }
736 517
737 // The drag can be ended after the synchronous drag is created but before it
738 // is Run().
739 CleanUpSynchronousDrag();
740
741 SetAsFolderDroppingTarget(folder_drop_target_, false); 518 SetAsFolderDroppingTarget(folder_drop_target_, false);
742 ClearDragState(); 519 ClearDragState();
743 AnimateToIdealBounds(); 520 AnimateToIdealBounds();
744 521
745 StopPageFlipTimer(); 522 StopPageFlipTimer();
746 523
747 // If user releases mouse inside a folder's grid view, burst the folder 524 // If user releases mouse inside a folder's grid view, burst the folder
748 // container ink bubble. 525 // container ink bubble.
749 if (folder_delegate_ && !IsDraggingForReparentInHiddenGridView()) 526 if (folder_delegate_ && !IsDraggingForReparentInHiddenGridView())
750 folder_delegate_->UpdateFolderViewBackground(false); 527 folder_delegate_->UpdateFolderViewBackground(false);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 void AppsGridView::SetDragViewVisible(bool visible) { 640 void AppsGridView::SetDragViewVisible(bool visible) {
864 DCHECK(drag_view_); 641 DCHECK(drag_view_);
865 SetViewHidden(drag_view_, !visible, true); 642 SetViewHidden(drag_view_, !visible, true);
866 } 643 }
867 644
868 void AppsGridView::SetDragAndDropHostOfCurrentAppList( 645 void AppsGridView::SetDragAndDropHostOfCurrentAppList(
869 ApplicationDragAndDropHost* drag_and_drop_host) { 646 ApplicationDragAndDropHost* drag_and_drop_host) {
870 drag_and_drop_host_ = drag_and_drop_host; 647 drag_and_drop_host_ = drag_and_drop_host;
871 } 648 }
872 649
873 void AppsGridView::Prerender() {
874 Layout();
875 int selected_page = std::max(0, pagination_model_.selected_page());
876 int start = std::max(0, (selected_page - kPrerenderPages) * tiles_per_page());
877 int end = std::min(view_model_.view_size(),
878 (selected_page + 1 + kPrerenderPages) * tiles_per_page());
879 for (int i = start; i < end; i++)
880 GetItemViewAt(i)->Prerender();
881 }
882
883 bool AppsGridView::IsAnimatingView(AppListItemView* view) { 650 bool AppsGridView::IsAnimatingView(AppListItemView* view) {
884 return bounds_animator_.IsAnimating(view); 651 return bounds_animator_.IsAnimating(view);
885 } 652 }
886 653
887 gfx::Size AppsGridView::GetPreferredSize() const { 654 gfx::Size AppsGridView::GetPreferredSize() const {
888 const gfx::Insets insets(GetInsets()); 655 const gfx::Insets insets(GetInsets());
889 // If we are in a folder, ignore the page switcher for height calculations. 656 // If we are in a folder, ignore the page switcher for height calculations.
890 int page_switcher_height = 657 int page_switcher_height =
891 folder_delegate_ ? 0 : page_switcher_view_->GetPreferredSize().height(); 658 folder_delegate_ ? 0 : page_switcher_view_->GetPreferredSize().height();
892 gfx::Size size = GetTileGridSize(); 659 gfx::Size size = GetTileGridSize();
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 if (drop_attempt_ == DROP_FOR_REORDER) { 1235 if (drop_attempt_ == DROP_FOR_REORDER) {
1469 reorder_placeholder_ = reorder_drop_target_; 1236 reorder_placeholder_ = reorder_drop_target_;
1470 AnimateToIdealBounds(); 1237 AnimateToIdealBounds();
1471 } 1238 }
1472 } 1239 }
1473 1240
1474 void AppsGridView::OnFolderItemReparentTimer() { 1241 void AppsGridView::OnFolderItemReparentTimer() {
1475 DCHECK(folder_delegate_); 1242 DCHECK(folder_delegate_);
1476 if (drag_out_of_folder_container_ && drag_view_) { 1243 if (drag_out_of_folder_container_ && drag_view_) {
1477 bool has_native_drag = drag_and_drop_host_ != nullptr; 1244 bool has_native_drag = drag_and_drop_host_ != nullptr;
1478 #if defined(OS_WIN)
1479 has_native_drag = has_native_drag || synchronous_drag_.Get();
1480 #endif
1481 folder_delegate_->ReparentItem( 1245 folder_delegate_->ReparentItem(
1482 drag_view_, last_drag_point_, has_native_drag); 1246 drag_view_, last_drag_point_, has_native_drag);
1483 1247
1484 // Set the flag in the folder's grid view. 1248 // Set the flag in the folder's grid view.
1485 dragging_for_reparent_item_ = true; 1249 dragging_for_reparent_item_ = true;
1486 1250
1487 // Do not observe any data change since it is going to be hidden. 1251 // Do not observe any data change since it is going to be hidden.
1488 item_list_->RemoveObserver(this); 1252 item_list_->RemoveObserver(this);
1489 item_list_ = NULL; 1253 item_list_ = NULL;
1490 } 1254 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 } else if (drop_attempt_ == DROP_FOR_FOLDER && 1345 } else if (drop_attempt_ == DROP_FOR_FOLDER &&
1582 IsValidIndex(folder_drop_target_)) { 1346 IsValidIndex(folder_drop_target_)) {
1583 cancel_reparent = 1347 cancel_reparent =
1584 !ReparentItemToAnotherFolder(drag_view_, folder_drop_target_); 1348 !ReparentItemToAnotherFolder(drag_view_, folder_drop_target_);
1585 } else { 1349 } else {
1586 NOTREACHED(); 1350 NOTREACHED();
1587 } 1351 }
1588 SetViewHidden(drag_view_, false /* show */, true /* no animate */); 1352 SetViewHidden(drag_view_, false /* show */, true /* no animate */);
1589 } 1353 }
1590 1354
1591 // The drag can be ended after the synchronous drag is created but before it
1592 // is Run().
1593 CleanUpSynchronousDrag();
1594
1595 SetAsFolderDroppingTarget(folder_drop_target_, false); 1355 SetAsFolderDroppingTarget(folder_drop_target_, false);
1596 if (cancel_reparent) { 1356 if (cancel_reparent) {
1597 CancelFolderItemReparent(drag_view_); 1357 CancelFolderItemReparent(drag_view_);
1598 } else { 1358 } else {
1599 // By setting |drag_view_| to NULL here, we prevent ClearDragState() from 1359 // By setting |drag_view_| to NULL here, we prevent ClearDragState() from
1600 // cleaning up the newly created AppListItemView, effectively claiming 1360 // cleaning up the newly created AppListItemView, effectively claiming
1601 // ownership of the newly created drag view. 1361 // ownership of the newly created drag view.
1602 drag_view_->OnDragEnded(); 1362 drag_view_->OnDragEnded();
1603 drag_view_ = NULL; 1363 drag_view_ = NULL;
1604 } 1364 }
1605 ClearDragState(); 1365 ClearDragState();
1606 AnimateToIdealBounds(); 1366 AnimateToIdealBounds();
1607 1367
1608 StopPageFlipTimer(); 1368 StopPageFlipTimer();
1609 } 1369 }
1610 1370
1611 void AppsGridView::EndDragForReparentInHiddenFolderGridView() { 1371 void AppsGridView::EndDragForReparentInHiddenFolderGridView() {
1612 if (drag_and_drop_host_) { 1372 if (drag_and_drop_host_) {
1613 // If we had a drag and drop proxy icon, we delete it and make the real 1373 // If we had a drag and drop proxy icon, we delete it and make the real
1614 // item visible again. 1374 // item visible again.
1615 drag_and_drop_host_->DestroyDragIconProxy(); 1375 drag_and_drop_host_->DestroyDragIconProxy();
1616 } 1376 }
1617 1377
1618 // The drag can be ended after the synchronous drag is created but before it
1619 // is Run().
1620 CleanUpSynchronousDrag();
1621
1622 SetAsFolderDroppingTarget(folder_drop_target_, false); 1378 SetAsFolderDroppingTarget(folder_drop_target_, false);
1623 ClearDragState(); 1379 ClearDragState();
1624 } 1380 }
1625 1381
1626 void AppsGridView::OnFolderItemRemoved() { 1382 void AppsGridView::OnFolderItemRemoved() {
1627 DCHECK(folder_delegate_); 1383 DCHECK(folder_delegate_);
1628 if (item_list_) 1384 if (item_list_)
1629 item_list_->RemoveObserver(this); 1385 item_list_->RemoveObserver(this);
1630 item_list_ = nullptr; 1386 item_list_ = nullptr;
1631 } 1387 }
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 1935
2180 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, 1936 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index,
2181 bool is_target_folder) { 1937 bool is_target_folder) {
2182 AppListItemView* target_view = 1938 AppListItemView* target_view =
2183 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot); 1939 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot);
2184 if (target_view) 1940 if (target_view)
2185 target_view->SetAsAttemptedFolderTarget(is_target_folder); 1941 target_view->SetAsAttemptedFolderTarget(is_target_folder);
2186 } 1942 }
2187 1943
2188 } // namespace app_list 1944 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698