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

Side by Side Diff: ash/common/system/chromeos/palette/common_palette_tool.cc

Issue 2308823002: Add UMA stats for pen palette (Closed)
Patch Set: rebase Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/common/system/chromeos/palette/common_palette_tool.h" 5 #include "ash/common/system/chromeos/palette/common_palette_tool.h"
6 6
7 #include "ash/common/shelf/shelf_constants.h" 7 #include "ash/common/shelf/shelf_constants.h"
8 #include "ash/common/system/chromeos/palette/palette_ids.h" 8 #include "ash/common/system/chromeos/palette/palette_ids.h"
9 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" 9 #include "ash/common/system/chromeos/palette/palette_tool_manager.h"
10 #include "ash/common/system/tray/hover_highlight_view.h" 10 #include "ash/common/system/tray/hover_highlight_view.h"
11 #include "ash/common/system/tray/view_click_listener.h" 11 #include "ash/common/system/tray/view_click_listener.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "grit/ash_resources.h" 15 #include "grit/ash_resources.h"
15 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/color_palette.h" 17 #include "ui/gfx/color_palette.h"
17 #include "ui/gfx/paint_vector_icon.h" 18 #include "ui/gfx/paint_vector_icon.h"
18 #include "ui/views/border.h" 19 #include "ui/views/border.h"
19 20
20 namespace ash { 21 namespace ash {
21 namespace { 22 namespace {
22 23
(...skipping 21 matching lines...) Expand all
44 return CreateDefaultView( 45 return CreateDefaultView(
45 base::ASCIIToUTF16("[TODO] " + PaletteToolIdToString(GetToolId()))); 46 base::ASCIIToUTF16("[TODO] " + PaletteToolIdToString(GetToolId())));
46 } 47 }
47 48
48 void CommonPaletteTool::OnViewDestroyed() { 49 void CommonPaletteTool::OnViewDestroyed() {
49 highlight_view_ = nullptr; 50 highlight_view_ = nullptr;
50 } 51 }
51 52
52 void CommonPaletteTool::OnEnable() { 53 void CommonPaletteTool::OnEnable() {
53 PaletteTool::OnEnable(); 54 PaletteTool::OnEnable();
55 start_time_ = base::TimeTicks::Now();
54 56
55 if (highlight_view_) { 57 if (highlight_view_) {
56 highlight_view_->SetHighlight(true); 58 highlight_view_->SetHighlight(true);
57 highlight_view_->SetRightIconVisible(true); 59 highlight_view_->SetRightIconVisible(true);
58 } 60 }
59 } 61 }
60 62
61 void CommonPaletteTool::OnDisable() { 63 void CommonPaletteTool::OnDisable() {
62 PaletteTool::OnDisable(); 64 PaletteTool::OnDisable();
63 65
66 if (GetToolId() == ash::PaletteToolId::LASER_POINTER) {
jdufault 2016/09/02 21:54:30 What about something like if (ShouldRecordUma(Get
Ilya Sherman 2016/09/02 22:02:49 Histogram names passed to UMA_HISTOGRAM_ macros mu
67 UMA_HISTOGRAM_LONG_TIMES_100("Ash.Shelf.Palette.InLaserPointerMode",
Ilya Sherman 2016/09/02 21:39:30 Hmm, are values under 100 ms at all likely? I wou
xiaoyinh(OOO Sep 11-29) 2016/09/06 17:40:04 Done.
68 base::TimeTicks::Now() - start_time_);
69 } else if (GetToolId() == ash::PaletteToolId::MAGNIFY) {
70 UMA_HISTOGRAM_LONG_TIMES_100("Ash.Shelf.Palette.InMagnifyMode",
71 base::TimeTicks::Now() - start_time_);
72 }
73
64 if (highlight_view_) { 74 if (highlight_view_) {
65 highlight_view_->SetHighlight(false); 75 highlight_view_->SetHighlight(false);
66 highlight_view_->SetRightIconVisible(false); 76 highlight_view_->SetRightIconVisible(false);
67 } 77 }
68 } 78 }
69 79
70 void CommonPaletteTool::OnViewClicked(views::View* sender) { 80 void CommonPaletteTool::OnViewClicked(views::View* sender) {
81 delegate()->RecordPaletteMetrics(
82 PaletteToolIdToPaletteTrayOptions(GetToolId()));
71 if (enabled()) 83 if (enabled())
72 delegate()->DisableTool(GetToolId()); 84 delegate()->DisableTool(GetToolId());
73 else 85 else
74 delegate()->EnableTool(GetToolId()); 86 delegate()->EnableTool(GetToolId());
75 } 87 }
76 88
77 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { 89 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) {
78 gfx::ImageSkia icon = 90 gfx::ImageSkia icon =
79 CreateVectorIcon(GetPaletteIconId(), kIconSize, gfx::kChromeIconGrey); 91 CreateVectorIcon(GetPaletteIconId(), kIconSize, gfx::kChromeIconGrey);
80 gfx::ImageSkia check = CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, 92 gfx::ImageSkia check = CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE,
81 kIconSize, gfx::kGoogleGreen700); 93 kIconSize, gfx::kGoogleGreen700);
82 94
83 highlight_view_ = new HoverHighlightView(this); 95 highlight_view_ = new HoverHighlightView(this);
84 highlight_view_->SetBorder( 96 highlight_view_->SetBorder(
85 views::Border::CreateEmptyBorder(0, kExtraMarginFromLeftEdge, 0, 0)); 97 views::Border::CreateEmptyBorder(0, kExtraMarginFromLeftEdge, 0, 0));
86 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kIconSize, 98 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kIconSize,
87 kMarginFromEdges, 99 kMarginFromEdges,
88 kMarginBetweenIconAndText); 100 kMarginBetweenIconAndText);
89 highlight_view_->AddRightIcon(check, kIconSize); 101 highlight_view_->AddRightIcon(check, kIconSize);
90 102
91 if (enabled()) 103 if (enabled())
92 highlight_view_->SetHighlight(true); 104 highlight_view_->SetHighlight(true);
93 else 105 else
94 highlight_view_->SetRightIconVisible(false); 106 highlight_view_->SetRightIconVisible(false);
95 107
96 return highlight_view_; 108 return highlight_view_;
97 } 109 }
98 110
99 } // namespace ash 111 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698