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

Unified Diff: ash/common/system/chromeos/palette/palette_tray.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 side-by-side diff with in-line comments
Download patch
Index: ash/common/system/chromeos/palette/palette_tray.cc
diff --git a/ash/common/system/chromeos/palette/palette_tray.cc b/ash/common/system/chromeos/palette/palette_tray.cc
index 80ecc3bb8117eda76ff491066ee15d2dd80d69b0..3710d9ab82d7920044c1383847bcb3674d909f72 100644
--- a/ash/common/system/chromeos/palette/palette_tray.cc
+++ b/ash/common/system/chromeos/palette/palette_tray.cc
@@ -18,6 +18,7 @@
#include "ash/common/wm_root_window_controller.h"
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
+#include "base/metrics/histogram.h"
Ilya Sherman 2016/09/02 21:39:30 nit: histogram_macros
xiaoyinh(OOO Sep 11-29) 2016/09/06 17:40:05 Done.
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
@@ -108,9 +109,13 @@ class TitleView : public views::View, public views::ButtonListener {
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override {
if (sender == settings_button_) {
+ palette_tray_->RecordPaletteMetrics(
+ ash::PaletteTrayOptions::PALETTE_SETTINGS_BUTTON);
WmShell::Get()->system_tray_delegate()->ShowPaletteSettings();
jdufault 2016/09/02 21:54:30 ShowPaletteSettings should already be recording a
xiaoyinh(OOO Sep 11-29) 2016/09/06 17:40:05 Should I remove mine if that's case? It might stil
palette_tray_->HidePalette();
} else if (sender == help_button_) {
+ palette_tray_->RecordPaletteMetrics(
+ ash::PaletteTrayOptions::PALETTE_HELP_BUTTON);
WmShell::Get()->system_tray_delegate()->ShowPaletteHelp();
palette_tray_->HidePalette();
} else {
@@ -173,7 +178,10 @@ PaletteTray::~PaletteTray() {
bool PaletteTray::PerformAction(const ui::Event& event) {
if (bubble_) {
- bubble_.reset();
+ if (num_actions_in_palette == 0) {
+ RecordPaletteMetrics(ash::PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION);
+ }
+ HidePalette();
return true;
}
@@ -236,7 +244,9 @@ void PaletteTray::OnLockStateChanged(bool locked) {
}
void PaletteTray::ClickedOutsideBubble() {
- bubble_.reset();
+ if (num_actions_in_palette == 0)
+ RecordPaletteMetrics(ash::PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION);
+ HidePalette();
}
base::string16 PaletteTray::GetAccessibleNameForTray() {
@@ -245,7 +255,7 @@ base::string16 PaletteTray::GetAccessibleNameForTray() {
void PaletteTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) {
if (bubble_->bubble_view() == bubble_view)
- bubble_.reset();
+ HidePalette();
}
void PaletteTray::BubbleViewDestroyed() {
@@ -303,14 +313,29 @@ void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) {
}
void PaletteTray::HidePalette() {
+ is_palette_auto_opened = false;
+ num_actions_in_palette = 0;
bubble_.reset();
}
+void PaletteTray::RecordPaletteMetrics(ash::PaletteTrayOptions option) {
+ if (option == ash::PaletteTrayOptions::PALETTE_OPTIONS_COUNT)
jdufault 2016/09/02 21:54:30 Do we want to DCHECK on this?
xiaoyinh(OOO Sep 11-29) 2016/09/06 17:40:05 Added. Thanks
+ return;
+
+ if (is_palette_auto_opened)
Ilya Sherman 2016/09/02 21:39:30 nit: Please use curly braces, since the body spans
jdufault 2016/09/02 21:54:30 nit: add {} for both if/else
xiaoyinh(OOO Sep 11-29) 2016/09/06 17:40:05 Done.
xiaoyinh(OOO Sep 11-29) 2016/09/06 17:40:05 Done.
+ UMA_HISTOGRAM_ENUMERATION("Ash.Shelf.PaletteUsage.AutoOpened", option,
+ ash::PaletteTrayOptions::PALETTE_OPTIONS_COUNT);
+ else
+ UMA_HISTOGRAM_ENUMERATION("Ash.Shelf.PaletteUsage", option,
+ ash::PaletteTrayOptions::PALETTE_OPTIONS_COUNT);
+}
+
bool PaletteTray::ShouldBlockShelfAutoHide() const {
return !!bubble_;
}
void PaletteTray::OnActiveToolChanged() {
+ ++num_actions_in_palette;
UpdateTrayIcon();
}
@@ -353,10 +378,12 @@ void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) {
if (!WmShell::Get()->palette_delegate()->ShouldAutoOpenPalette())
return;
- if (stylus_state == ui::StylusState::REMOVED && !bubble_)
+ if (stylus_state == ui::StylusState::REMOVED && !bubble_) {
+ is_palette_auto_opened = true;
ShowPalette();
- else if (stylus_state == ui::StylusState::INSERTED && bubble_)
- bubble_.reset();
+ } else if (stylus_state == ui::StylusState::INSERTED && bubble_) {
+ HidePalette();
+ }
}
void PaletteTray::OnPaletteEnabledPrefChanged(bool enabled) {

Powered by Google App Engine
This is Rietveld 408576698