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..bb8caf010110cb35753caf35a6139573d5c68680 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) { |
+ 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(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(type != PaletteModeCancelType::PALETTE_MODE_CANCEL_TYPE_COUNT); |
Ilya Sherman
2016/09/06 20:45:32
nit: DCHECK_NE (and ditto above)
xiaoyinh(OOO Sep 11-29)
2016/09/06 22:31:35
Done.
|
+ 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) { |