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/aura/wm_window_aura.h" | 10 #include "ash/aura/wm_window_aura.h" |
11 #include "ash/common/ash_constants.h" | 11 #include "ash/common/ash_constants.h" |
12 #include "ash/common/ash_switches.h" | 12 #include "ash/common/ash_switches.h" |
13 #include "ash/common/shelf/shelf_constants.h" | 13 #include "ash/common/shelf/shelf_constants.h" |
14 #include "ash/common/shelf/shelf_item_delegate_manager.h" | 14 #include "ash/common/shelf/shelf_item_delegate_manager.h" |
15 #include "ash/common/shelf/shelf_menu_model.h" | 15 #include "ash/common/shelf/shelf_menu_model.h" |
16 #include "ash/common/shelf/shelf_model.h" | 16 #include "ash/common/shelf/shelf_model.h" |
| 17 #include "ash/common/shell_delegate.h" |
17 #include "ash/common/wm/root_window_finder.h" | 18 #include "ash/common/wm/root_window_finder.h" |
18 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
19 #include "ash/drag_drop/drag_image_view.h" | 20 #include "ash/drag_drop/drag_image_view.h" |
20 #include "ash/scoped_target_root_window.h" | 21 #include "ash/scoped_target_root_window.h" |
21 #include "ash/shelf/app_list_button.h" | 22 #include "ash/shelf/app_list_button.h" |
22 #include "ash/shelf/overflow_bubble.h" | 23 #include "ash/shelf/overflow_bubble.h" |
23 #include "ash/shelf/overflow_bubble_view.h" | 24 #include "ash/shelf/overflow_bubble_view.h" |
24 #include "ash/shelf/overflow_button.h" | 25 #include "ash/shelf/overflow_button.h" |
25 #include "ash/shelf/shelf.h" | 26 #include "ash/shelf/shelf.h" |
26 #include "ash/shelf/shelf_button.h" | 27 #include "ash/shelf/shelf_button.h" |
27 #include "ash/shelf/shelf_delegate.h" | 28 #include "ash/shelf/shelf_delegate.h" |
28 #include "ash/shelf/shelf_icon_observer.h" | 29 #include "ash/shelf/shelf_icon_observer.h" |
29 #include "ash/shelf/shelf_widget.h" | 30 #include "ash/shelf/shelf_widget.h" |
30 #include "ash/shell.h" | 31 #include "ash/shell.h" |
31 #include "ash/shell_delegate.h" | |
32 #include "base/auto_reset.h" | 32 #include "base/auto_reset.h" |
33 #include "base/metrics/histogram.h" | 33 #include "base/metrics/histogram.h" |
34 #include "grit/ash_strings.h" | 34 #include "grit/ash_strings.h" |
35 #include "ui/accessibility/ax_view_state.h" | 35 #include "ui/accessibility/ax_view_state.h" |
36 #include "ui/aura/client/screen_position_client.h" | 36 #include "ui/aura/client/screen_position_client.h" |
37 #include "ui/aura/window.h" | 37 #include "ui/aura/window.h" |
38 #include "ui/aura/window_event_dispatcher.h" | 38 #include "ui/aura/window_event_dispatcher.h" |
39 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
40 #include "ui/base/models/simple_menu_model.h" | 40 #include "ui/base/models/simple_menu_model.h" |
41 #include "ui/base/resource/resource_bundle.h" | 41 #include "ui/base/resource/resource_bundle.h" |
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1787 ui::MenuSourceType source_type) { | 1787 ui::MenuSourceType source_type) { |
1788 last_pressed_index_ = -1; | 1788 last_pressed_index_ = -1; |
1789 | 1789 |
1790 const ShelfItem* item = ShelfItemForView(source); | 1790 const ShelfItem* item = ShelfItemForView(source); |
1791 if (!item) { | 1791 if (!item) { |
1792 Shell::GetInstance()->ShowContextMenu(point, source_type); | 1792 Shell::GetInstance()->ShowContextMenu(point, source_type); |
1793 return; | 1793 return; |
1794 } | 1794 } |
1795 | 1795 |
1796 std::unique_ptr<ui::MenuModel> context_menu_model( | 1796 std::unique_ptr<ui::MenuModel> context_menu_model( |
1797 Shell::GetInstance()->delegate()->CreateContextMenu(wm_shelf_, item)); | 1797 WmShell::Get()->delegate()->CreateContextMenu(wm_shelf_, item)); |
1798 if (!context_menu_model) | 1798 if (!context_menu_model) |
1799 return; | 1799 return; |
1800 | 1800 |
1801 context_menu_id_ = item ? item->id : 0; | 1801 context_menu_id_ = item ? item->id : 0; |
1802 ShowMenu(context_menu_model.get(), source, point, true, source_type); | 1802 ShowMenu(context_menu_model.get(), source, point, true, source_type); |
1803 } | 1803 } |
1804 | 1804 |
1805 void ShelfView::ShowMenu(ui::MenuModel* menu_model, | 1805 void ShelfView::ShowMenu(ui::MenuModel* menu_model, |
1806 views::View* source, | 1806 views::View* source, |
1807 const gfx::Point& click_point, | 1807 const gfx::Point& click_point, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 | 1907 |
1908 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1908 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
1909 const gfx::Rect bounds = GetBoundsInScreen(); | 1909 const gfx::Rect bounds = GetBoundsInScreen(); |
1910 int distance = shelf_->SelectValueForShelfAlignment( | 1910 int distance = shelf_->SelectValueForShelfAlignment( |
1911 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1911 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
1912 bounds.x() - coordinate.x()); | 1912 bounds.x() - coordinate.x()); |
1913 return distance > 0 ? distance : 0; | 1913 return distance > 0 ? distance : 0; |
1914 } | 1914 } |
1915 | 1915 |
1916 } // namespace ash | 1916 } // namespace ash |
OLD | NEW |