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 | 8 |
9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
11 #include "ash/drag_drop/drag_image_view.h" | 11 #include "ash/drag_drop/drag_image_view.h" |
12 #include "ash/launcher/launcher_button.h" | 12 #include "ash/launcher/launcher_button.h" |
13 #include "ash/launcher/launcher_delegate.h" | 13 #include "ash/launcher/launcher_delegate.h" |
14 #include "ash/launcher/launcher_icon_observer.h" | 14 #include "ash/launcher/launcher_icon_observer.h" |
15 #include "ash/launcher/launcher_item_delegate.h" | 15 #include "ash/launcher/launcher_item_delegate.h" |
16 #include "ash/launcher/launcher_item_delegate_manager.h" | 16 #include "ash/launcher/launcher_item_delegate_manager.h" |
17 #include "ash/launcher/launcher_model.h" | 17 #include "ash/launcher/launcher_model.h" |
18 #include "ash/root_window_controller.h" | 18 #include "ash/root_window_controller.h" |
19 #include "ash/scoped_target_root_window.h" | 19 #include "ash/scoped_target_root_window.h" |
20 #include "ash/shelf/alternate_app_list_button.h" | 20 #include "ash/shelf/alternate_app_list_button.h" |
21 #include "ash/shelf/app_list_button.h" | 21 #include "ash/shelf/app_list_button.h" |
22 #include "ash/shelf/overflow_bubble.h" | 22 #include "ash/shelf/overflow_bubble.h" |
23 #include "ash/shelf/overflow_button.h" | 23 #include "ash/shelf/overflow_button.h" |
24 #include "ash/shelf/shelf_layout_manager.h" | 24 #include "ash/shelf/shelf_layout_manager.h" |
25 #include "ash/shelf/shelf_tooltip_manager.h" | 25 #include "ash/shelf/shelf_tooltip_manager.h" |
26 #include "ash/shelf/shelf_widget.h" | 26 #include "ash/shelf/shelf_widget.h" |
27 #include "ash/shell_delegate.h" | 27 #include "ash/shell_delegate.h" |
28 #include "base/auto_reset.h" | 28 #include "base/auto_reset.h" |
29 #include "base/memory/scoped_ptr.h" | 29 #include "base/memory/scoped_ptr.h" |
30 #include "base/metrics/histogram.h" | |
30 #include "grit/ash_resources.h" | 31 #include "grit/ash_resources.h" |
31 #include "grit/ash_strings.h" | 32 #include "grit/ash_strings.h" |
32 #include "ui/aura/client/screen_position_client.h" | 33 #include "ui/aura/client/screen_position_client.h" |
33 #include "ui/aura/root_window.h" | 34 #include "ui/aura/root_window.h" |
34 #include "ui/aura/window.h" | 35 #include "ui/aura/window.h" |
35 #include "ui/base/accessibility/accessible_view_state.h" | 36 #include "ui/base/accessibility/accessible_view_state.h" |
36 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/base/models/simple_menu_model.h" | 38 #include "ui/base/models/simple_menu_model.h" |
38 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
39 #include "ui/compositor/layer.h" | 40 #include "ui/compositor/layer.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
51 #include "ui/views/view_model.h" | 52 #include "ui/views/view_model.h" |
52 #include "ui/views/view_model_utils.h" | 53 #include "ui/views/view_model_utils.h" |
53 #include "ui/views/widget/widget.h" | 54 #include "ui/views/widget/widget.h" |
54 | 55 |
55 using gfx::Animation; | 56 using gfx::Animation; |
56 using views::View; | 57 using views::View; |
57 | 58 |
58 namespace ash { | 59 namespace ash { |
59 namespace internal { | 60 namespace internal { |
60 | 61 |
62 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM = 0; | |
63 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT = 1; | |
64 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT = 2; | |
65 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT = 3; | |
66 | |
61 // Default amount content is inset on the left edge. | 67 // Default amount content is inset on the left edge. |
62 const int kDefaultLeadingInset = 8; | 68 const int kDefaultLeadingInset = 8; |
63 | 69 |
64 // Minimum distance before drag starts. | 70 // Minimum distance before drag starts. |
65 const int kMinimumDragDistance = 8; | 71 const int kMinimumDragDistance = 8; |
66 | 72 |
67 // Size between the buttons. | 73 // Size between the buttons. |
68 const int kButtonSpacing = 4; | 74 const int kButtonSpacing = 4; |
69 const int kAlternateButtonSpacing = 10; | 75 const int kAlternateButtonSpacing = 10; |
70 | 76 |
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1519 return; | 1525 return; |
1520 | 1526 |
1521 int index = view_model_->GetIndexOfView(view); | 1527 int index = view_model_->GetIndexOfView(view); |
1522 if (index == -1) | 1528 if (index == -1) |
1523 return; | 1529 return; |
1524 | 1530 |
1525 LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate( | 1531 LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate( |
1526 model_->items()[index].id); | 1532 model_->items()[index].id); |
1527 if (view_model_->view_size() <= 1 || !item_delegate->IsDraggable()) | 1533 if (view_model_->view_size() <= 1 || !item_delegate->IsDraggable()) |
1528 return; // View is being deleted or not draggable, ignore request. | 1534 return; // View is being deleted or not draggable, ignore request. |
1529 | |
1530 drag_view_ = view; | 1535 drag_view_ = view; |
1531 drag_offset_ = layout_manager_->PrimaryAxisValue(event.x(), event.y()); | 1536 drag_offset_ = layout_manager_->PrimaryAxisValue(event.x(), event.y()); |
1537 RecordCurrentAlignmentForUMAHistogram("Ash.ShelfAlignmentUsage"); | |
1532 } | 1538 } |
1533 | 1539 |
1534 void ShelfView::PointerDraggedOnButton(views::View* view, | 1540 void ShelfView::PointerDraggedOnButton(views::View* view, |
1535 Pointer pointer, | 1541 Pointer pointer, |
1536 const ui::LocatedEvent& event) { | 1542 const ui::LocatedEvent& event) { |
1537 if (!dragging() && drag_view_ && | 1543 if (!dragging() && drag_view_ && |
1538 layout_manager_->PrimaryAxisValue(abs(event.x() - drag_offset_), | 1544 layout_manager_->PrimaryAxisValue(abs(event.x() - drag_offset_), |
1539 abs(event.y() - drag_offset_)) >= | 1545 abs(event.y() - drag_offset_)) >= |
1540 kMinimumDragDistance) { | 1546 kMinimumDragDistance) { |
1541 PrepareForDrag(pointer, event); | 1547 PrepareForDrag(pointer, event); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1877 case ash::SHELF_ALIGNMENT_RIGHT: | 1883 case ash::SHELF_ALIGNMENT_RIGHT: |
1878 distance = bounds.x() - coordinate.x(); | 1884 distance = bounds.x() - coordinate.x(); |
1879 break; | 1885 break; |
1880 case ash::SHELF_ALIGNMENT_TOP: | 1886 case ash::SHELF_ALIGNMENT_TOP: |
1881 distance = coordinate.y() - bounds.bottom(); | 1887 distance = coordinate.y() - bounds.bottom(); |
1882 break; | 1888 break; |
1883 } | 1889 } |
1884 return distance > 0 ? distance : 0; | 1890 return distance > 0 ? distance : 0; |
1885 } | 1891 } |
1886 | 1892 |
1893 void ShelfView::RecordCurrentAlignmentForUMAHistogram( | |
1894 const char* histogram_name) { | |
1895 UMA_HISTOGRAM_ENUMERATION(histogram_name, | |
James Cook
2013/10/30 16:49:12
This won't work. UMA_HISTOGRAM_ENUMERATION does so
| |
1896 layout_manager_->SelectValueForShelfAlignment( | |
1897 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM, | |
1898 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT, | |
1899 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT, | |
1900 -1), | |
1901 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT); | |
1902 } | |
1903 | |
1887 } // namespace internal | 1904 } // namespace internal |
1888 } // namespace ash | 1905 } // namespace ash |
OLD | NEW |