| OLD | NEW |
| 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/shelf/shelf_view.h" | 5 #include "ash/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
| 11 #include "ash/drag_drop/drag_image_view.h" | 11 #include "ash/drag_drop/drag_image_view.h" |
| 12 #include "ash/public/cpp/shelf_item_delegate.h" | 12 #include "ash/public/cpp/shelf_item_delegate.h" |
| 13 #include "ash/scoped_root_window_for_new_windows.h" | 13 #include "ash/scoped_root_window_for_new_windows.h" |
| 14 #include "ash/shelf/app_list_button.h" | 14 #include "ash/shelf/app_list_button.h" |
| 15 #include "ash/shelf/overflow_bubble.h" | 15 #include "ash/shelf/overflow_bubble.h" |
| 16 #include "ash/shelf/overflow_bubble_view.h" | 16 #include "ash/shelf/overflow_bubble_view.h" |
| 17 #include "ash/shelf/overflow_button.h" | 17 #include "ash/shelf/overflow_button.h" |
| 18 #include "ash/shelf/shelf_application_menu_model.h" | 18 #include "ash/shelf/shelf_application_menu_model.h" |
| 19 #include "ash/shelf/shelf_button.h" | 19 #include "ash/shelf/shelf_button.h" |
| 20 #include "ash/shelf/shelf_constants.h" | 20 #include "ash/shelf/shelf_constants.h" |
| 21 #include "ash/shelf/shelf_delegate.h" | 21 #include "ash/shelf/shelf_delegate.h" |
| 22 #include "ash/shelf/shelf_model.h" | 22 #include "ash/shelf/shelf_model.h" |
| 23 #include "ash/shelf/shelf_widget.h" | 23 #include "ash/shelf/shelf_widget.h" |
| 24 #include "ash/shelf/wm_shelf.h" | 24 #include "ash/shelf/wm_shelf.h" |
| 25 #include "ash/shell.h" | 25 #include "ash/shell.h" |
| 26 #include "ash/shell_delegate.h" | 26 #include "ash/shell_delegate.h" |
| 27 #include "ash/shell_port.h" |
| 27 #include "ash/strings/grit/ash_strings.h" | 28 #include "ash/strings/grit/ash_strings.h" |
| 28 #include "ash/wm/root_window_finder.h" | 29 #include "ash/wm/root_window_finder.h" |
| 29 #include "ash/wm_shell.h" | |
| 30 #include "ash/wm_window.h" | 30 #include "ash/wm_window.h" |
| 31 #include "base/auto_reset.h" | 31 #include "base/auto_reset.h" |
| 32 #include "base/memory/ptr_util.h" | 32 #include "base/memory/ptr_util.h" |
| 33 #include "base/metrics/histogram_macros.h" | 33 #include "base/metrics/histogram_macros.h" |
| 34 #include "ui/accessibility/ax_node_data.h" | 34 #include "ui/accessibility/ax_node_data.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 36 #include "ui/base/models/simple_menu_model.h" | 36 #include "ui/base/models/simple_menu_model.h" |
| 37 #include "ui/compositor/layer.h" | 37 #include "ui/compositor/layer.h" |
| 38 #include "ui/compositor/layer_animator.h" | 38 #include "ui/compositor/layer_animator.h" |
| 39 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 39 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 if (event.IsShiftDown()) { | 459 if (event.IsShiftDown()) { |
| 460 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode( | 460 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode( |
| 461 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); | 461 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); |
| 462 } | 462 } |
| 463 | 463 |
| 464 // Collect usage statistics before we decide what to do with the click. | 464 // Collect usage statistics before we decide what to do with the click. |
| 465 switch (model_->items()[last_pressed_index_].type) { | 465 switch (model_->items()[last_pressed_index_].type) { |
| 466 case TYPE_PINNED_APP: | 466 case TYPE_PINNED_APP: |
| 467 case TYPE_BROWSER_SHORTCUT: | 467 case TYPE_BROWSER_SHORTCUT: |
| 468 case TYPE_APP: | 468 case TYPE_APP: |
| 469 WmShell::Get()->RecordUserMetricsAction(UMA_LAUNCHER_CLICK_ON_APP); | 469 ShellPort::Get()->RecordUserMetricsAction(UMA_LAUNCHER_CLICK_ON_APP); |
| 470 break; | 470 break; |
| 471 | 471 |
| 472 case TYPE_APP_LIST: | 472 case TYPE_APP_LIST: |
| 473 WmShell::Get()->RecordUserMetricsAction( | 473 ShellPort::Get()->RecordUserMetricsAction( |
| 474 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON); | 474 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON); |
| 475 break; | 475 break; |
| 476 | 476 |
| 477 case TYPE_APP_PANEL: | 477 case TYPE_APP_PANEL: |
| 478 case TYPE_DIALOG: | 478 case TYPE_DIALOG: |
| 479 break; | 479 break; |
| 480 | 480 |
| 481 case TYPE_UNDEFINED: | 481 case TYPE_UNDEFINED: |
| 482 NOTREACHED() << "ShelfItemType must be set."; | 482 NOTREACHED() << "ShelfItemType must be set."; |
| 483 break; | 483 break; |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 scoped_root_window_for_new_windows_.reset(); | 1623 scoped_root_window_for_new_windows_.reset(); |
| 1624 } | 1624 } |
| 1625 | 1625 |
| 1626 void ShelfView::ShowContextMenuForView(views::View* source, | 1626 void ShelfView::ShowContextMenuForView(views::View* source, |
| 1627 const gfx::Point& point, | 1627 const gfx::Point& point, |
| 1628 ui::MenuSourceType source_type) { | 1628 ui::MenuSourceType source_type) { |
| 1629 last_pressed_index_ = -1; | 1629 last_pressed_index_ = -1; |
| 1630 | 1630 |
| 1631 const ShelfItem* item = ShelfItemForView(source); | 1631 const ShelfItem* item = ShelfItemForView(source); |
| 1632 if (!item) { | 1632 if (!item) { |
| 1633 WmShell::Get()->ShowContextMenu(point, source_type); | 1633 ShellPort::Get()->ShowContextMenu(point, source_type); |
| 1634 return; | 1634 return; |
| 1635 } | 1635 } |
| 1636 | 1636 |
| 1637 std::unique_ptr<ui::MenuModel> context_menu_model( | 1637 std::unique_ptr<ui::MenuModel> context_menu_model( |
| 1638 Shell::Get()->shell_delegate()->CreateContextMenu(wm_shelf_, item)); | 1638 Shell::Get()->shell_delegate()->CreateContextMenu(wm_shelf_, item)); |
| 1639 if (!context_menu_model) | 1639 if (!context_menu_model) |
| 1640 return; | 1640 return; |
| 1641 | 1641 |
| 1642 context_menu_id_ = item ? item->id : 0; | 1642 context_menu_id_ = item ? item->id : 0; |
| 1643 ShowMenu(std::move(context_menu_model), source, point, true, source_type, | 1643 ShowMenu(std::move(context_menu_model), source, point, true, source_type, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 | 1764 |
| 1765 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1765 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
| 1766 const gfx::Rect bounds = GetBoundsInScreen(); | 1766 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1767 int distance = wm_shelf_->SelectValueForShelfAlignment( | 1767 int distance = wm_shelf_->SelectValueForShelfAlignment( |
| 1768 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1768 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
| 1769 bounds.x() - coordinate.x()); | 1769 bounds.x() - coordinate.x()); |
| 1770 return distance > 0 ? distance : 0; | 1770 return distance > 0 ? distance : 0; |
| 1771 } | 1771 } |
| 1772 | 1772 |
| 1773 } // namespace ash | 1773 } // namespace ash |
| OLD | NEW |