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

Unified Diff: ash/common/system/chromeos/palette/palette_tray.cc

Issue 2308823002: Add UMA stats for pen palette (Closed)
Patch Set: nits 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..1d6c8030680ac2b260a5ff0c2222bd9af8425da1 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_macros.h"
#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_->RecordPaletteOptionsUsage(
+ PaletteTrayOptions::PALETTE_SETTINGS_BUTTON);
WmShell::Get()->system_tray_delegate()->ShowPaletteSettings();
palette_tray_->HidePalette();
} else if (sender == help_button_) {
+ palette_tray_->RecordPaletteOptionsUsage(
+ 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_bubble_ == 0) {
jdufault 2016/09/08 19:51:35 nit: drop {}
xiaoyinh(OOO Sep 11-29) 2016/09/08 23:20:58 Done.
+ RecordPaletteOptionsUsage(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_bubble_ == 0)
+ RecordPaletteOptionsUsage(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,36 @@ void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) {
}
void PaletteTray::HidePalette() {
+ is_bubble_auto_opened_ = false;
+ num_actions_in_bubble_ = 0;
bubble_.reset();
}
+void PaletteTray::RecordPaletteOptionsUsage(PaletteTrayOptions option) {
+ DCHECK_NE(option, PaletteTrayOptions::PALETTE_OPTIONS_COUNT);
+
+ if (is_bubble_auto_opened_) {
+ UMA_HISTOGRAM_ENUMERATION("Ash.Shelf.Palette.Usage.AutoOpened", option,
+ PaletteTrayOptions::PALETTE_OPTIONS_COUNT);
+ } else {
+ UMA_HISTOGRAM_ENUMERATION("Ash.Shelf.Palette.Usage", option,
+ PaletteTrayOptions::PALETTE_OPTIONS_COUNT);
+ }
+}
+
+void PaletteTray::RecordPaletteModeCancellation(PaletteModeCancelType type) {
+ DCHECK_NE(type, PaletteModeCancelType::PALETTE_MODE_CANCEL_TYPE_COUNT);
+ UMA_HISTOGRAM_ENUMERATION(
+ "Ash.Shelf.Palette.ModeCancellation", type,
+ PaletteModeCancelType::PALETTE_MODE_CANCEL_TYPE_COUNT);
+}
+
bool PaletteTray::ShouldBlockShelfAutoHide() const {
return !!bubble_;
}
void PaletteTray::OnActiveToolChanged() {
+ ++num_actions_in_bubble_;
UpdateTrayIcon();
}
@@ -353,10 +385,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_bubble_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