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

Side by Side Diff: ash/shelf/shelf_view.cc

Issue 1097393002: Added Launcher_SwitchTask UMA user action. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « ash/shelf/shelf_view.h ('k') | ash/shelf/shelf_view_unittest.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/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/metrics/user_metrics_recorder.h" 12 #include "ash/metrics/user_metrics_recorder.h"
13 #include "ash/root_window_controller.h" 13 #include "ash/root_window_controller.h"
14 #include "ash/scoped_target_root_window.h" 14 #include "ash/scoped_target_root_window.h"
15 #include "ash/shelf/app_list_button.h" 15 #include "ash/shelf/app_list_button.h"
16 #include "ash/shelf/overflow_bubble.h" 16 #include "ash/shelf/overflow_bubble.h"
17 #include "ash/shelf/overflow_bubble_view.h" 17 #include "ash/shelf/overflow_bubble_view.h"
18 #include "ash/shelf/overflow_button.h" 18 #include "ash/shelf/overflow_button.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_icon_observer.h" 22 #include "ash/shelf/shelf_icon_observer.h"
23 #include "ash/shelf/shelf_item_delegate.h"
24 #include "ash/shelf/shelf_item_delegate_manager.h" 23 #include "ash/shelf/shelf_item_delegate_manager.h"
25 #include "ash/shelf/shelf_layout_manager.h" 24 #include "ash/shelf/shelf_layout_manager.h"
26 #include "ash/shelf/shelf_menu_model.h" 25 #include "ash/shelf/shelf_menu_model.h"
27 #include "ash/shelf/shelf_model.h" 26 #include "ash/shelf/shelf_model.h"
28 #include "ash/shelf/shelf_tooltip_manager.h" 27 #include "ash/shelf/shelf_tooltip_manager.h"
29 #include "ash/shelf/shelf_widget.h" 28 #include "ash/shelf/shelf_widget.h"
30 #include "ash/shell.h" 29 #include "ash/shell.h"
31 #include "ash/wm/coordinate_conversion.h" 30 #include "ash/wm/coordinate_conversion.h"
32 #include "base/auto_reset.h" 31 #include "base/auto_reset.h"
33 #include "base/memory/scoped_ptr.h" 32 #include "base/memory/scoped_ptr.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 button->ClearState(ShelfButton::STATE_ATTENTION); 301 button->ClearState(ShelfButton::STATE_ATTENTION);
303 break; 302 break;
304 case STATUS_ATTENTION: 303 case STATUS_ATTENTION:
305 button->ClearState(ShelfButton::STATE_ACTIVE); 304 button->ClearState(ShelfButton::STATE_ACTIVE);
306 button->ClearState(ShelfButton::STATE_RUNNING); 305 button->ClearState(ShelfButton::STATE_RUNNING);
307 button->AddState(ShelfButton::STATE_ATTENTION); 306 button->AddState(ShelfButton::STATE_ATTENTION);
308 break; 307 break;
309 } 308 }
310 } 309 }
311 310
312 void RecordIconActivatedAction(const ui::Event& event) {
313 if (event.IsMouseEvent()) {
314 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
315 UMA_LAUNCHER_BUTTON_PRESSED_WITH_MOUSE);
316 } else if (event.IsGestureEvent()) {
317 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
318 UMA_LAUNCHER_BUTTON_PRESSED_WITH_TOUCH);
319 }
320 }
321
322 } // namespace 311 } // namespace
323 312
324 // AnimationDelegate used when deleting an item. This steadily decreased the 313 // AnimationDelegate used when deleting an item. This steadily decreased the
325 // opacity of the layer as the animation progress. 314 // opacity of the layer as the animation progress.
326 class ShelfView::FadeOutAnimationDelegate : public gfx::AnimationDelegate { 315 class ShelfView::FadeOutAnimationDelegate : public gfx::AnimationDelegate {
327 public: 316 public:
328 FadeOutAnimationDelegate(ShelfView* host, views::View* view) 317 FadeOutAnimationDelegate(ShelfView* host, views::View* view)
329 : shelf_view_(host), 318 : shelf_view_(host),
330 view_(view) {} 319 view_(view) {}
331 ~FadeOutAnimationDelegate() override {} 320 ~FadeOutAnimationDelegate() override {}
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 return item_delegate->GetTitle(); 1675 return item_delegate->GetTitle();
1687 } 1676 }
1688 1677
1689 void ShelfView::ButtonPressed(views::Button* sender, const ui::Event& event) { 1678 void ShelfView::ButtonPressed(views::Button* sender, const ui::Event& event) {
1690 // Do not handle mouse release during drag. 1679 // Do not handle mouse release during drag.
1691 if (dragging()) 1680 if (dragging())
1692 return; 1681 return;
1693 1682
1694 if (sender == overflow_button_) { 1683 if (sender == overflow_button_) {
1695 ToggleOverflowBubble(); 1684 ToggleOverflowBubble();
1696 RecordIconActivatedAction(event); 1685 RecordIconActivatedSource(event);
1697 return; 1686 return;
1698 } 1687 }
1699 1688
1700 int view_index = view_model_->GetIndexOfView(sender); 1689 int view_index = view_model_->GetIndexOfView(sender);
1701 // May be -1 while in the process of animating closed. 1690 // May be -1 while in the process of animating closed.
1702 if (view_index == -1) 1691 if (view_index == -1)
1703 return; 1692 return;
1704 1693
1705 // If the menu was just closed by the same event as this one, we ignore 1694 // If the menu was just closed by the same event as this one, we ignore
1706 // the call and don't open the menu again. See crbug.com/343005 for more 1695 // the call and don't open the menu again. See crbug.com/343005 for more
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 1734
1746 case TYPE_APP_PANEL: 1735 case TYPE_APP_PANEL:
1747 case TYPE_DIALOG: 1736 case TYPE_DIALOG:
1748 break; 1737 break;
1749 1738
1750 case TYPE_UNDEFINED: 1739 case TYPE_UNDEFINED:
1751 NOTREACHED() << "ShelfItemType must be set."; 1740 NOTREACHED() << "ShelfItemType must be set.";
1752 break; 1741 break;
1753 } 1742 }
1754 1743
1755 RecordIconActivatedAction(event); 1744 RecordIconActivatedSource(event);
1756 1745
1757 switch (item_manager_->GetShelfItemDelegate(model_->items()[view_index].id) 1746 ShelfItemDelegate::PerformedAction performed_action =
1758 ->ItemSelected(event)) { 1747 item_manager_->GetShelfItemDelegate(model_->items()[view_index].id)
1759 case ShelfItemDelegate::kNoAction: 1748 ->ItemSelected(event);
1760 case ShelfItemDelegate::kExistingWindowActivated: 1749
1761 case ShelfItemDelegate::kExistingWindowMinimized: 1750 RecordIconActivatedAction(performed_action);
1762 case ShelfItemDelegate::kAppListMenuShown: 1751
1763 ShowListMenuForView(model_->items()[view_index], sender, event); 1752 if (performed_action != ShelfItemDelegate::kNewWindowCreated)
1764 break; 1753 ShowListMenuForView(model_->items()[view_index], sender, event);
1765 case ShelfItemDelegate::kNewWindowCreated:
1766 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
1767 UMA_LAUNCHER_LAUNCH_TASK);
1768 break;
1769 }
1770 } 1754 }
1771 } 1755 }
1772 1756
1757 void ShelfView::RecordIconActivatedSource(const ui::Event& event) {
1758 if (event.IsMouseEvent()) {
1759 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
1760 UMA_LAUNCHER_BUTTON_PRESSED_WITH_MOUSE);
1761 } else if (event.IsGestureEvent()) {
1762 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
1763 UMA_LAUNCHER_BUTTON_PRESSED_WITH_TOUCH);
1764 }
1765 }
1766
1767 void ShelfView::RecordIconActivatedAction(
1768 ShelfItemDelegate::PerformedAction performed_action) {
1769 switch (performed_action) {
1770 case ShelfItemDelegate::kNoAction:
1771 case ShelfItemDelegate::kExistingWindowMinimized:
1772 case ShelfItemDelegate::kAppListMenuShown:
1773 break;
1774 case ShelfItemDelegate::kNewWindowCreated:
1775 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
1776 UMA_LAUNCHER_LAUNCH_TASK);
1777 break;
1778 case ShelfItemDelegate::kExistingWindowActivated:
1779 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
1780 UMA_LAUNCHER_SWITCH_TASK);
1781 break;
1782 }
1783 }
1784
1773 bool ShelfView::ShowListMenuForView(const ShelfItem& item, 1785 bool ShelfView::ShowListMenuForView(const ShelfItem& item,
1774 views::View* source, 1786 views::View* source,
1775 const ui::Event& event) { 1787 const ui::Event& event) {
1776 ShelfItemDelegate* item_delegate = 1788 ShelfItemDelegate* item_delegate =
1777 item_manager_->GetShelfItemDelegate(item.id); 1789 item_manager_->GetShelfItemDelegate(item.id);
1778 scoped_ptr<ui::MenuModel> list_menu_model( 1790 scoped_ptr<ui::MenuModel> list_menu_model(
1779 item_delegate->CreateApplicationMenu(event.flags())); 1791 item_delegate->CreateApplicationMenu(event.flags()));
1780 1792
1781 // Make sure we have a menu and it has at least two items in addition to the 1793 // Make sure we have a menu and it has at least two items in addition to the
1782 // application title and the 3 spacing separators. 1794 // application title and the 3 spacing separators.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 distance = bounds.x() - coordinate.x(); 1991 distance = bounds.x() - coordinate.x();
1980 break; 1992 break;
1981 case SHELF_ALIGNMENT_TOP: 1993 case SHELF_ALIGNMENT_TOP:
1982 distance = coordinate.y() - bounds.bottom(); 1994 distance = coordinate.y() - bounds.bottom();
1983 break; 1995 break;
1984 } 1996 }
1985 return distance > 0 ? distance : 0; 1997 return distance > 0 ? distance : 0;
1986 } 1998 }
1987 1999
1988 } // namespace ash 2000 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_view.h ('k') | ash/shelf/shelf_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698