Commit f7d59baf authored by Darren Shen's avatar Darren Shen Committed by Commit Bot

[Views] Add histogram logging to text services context menus.

This patch adds histogram logging to the text services context menus,
based on how the simple menu model does histogram logging.

Bug: 838710
Change-Id: I090a02860ea64972386042b3e656fd8534b28d9e
Reviewed-on: https://chromium-review.googlesource.com/1067519Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563130}
parent b43ea004
...@@ -47114,6 +47114,10 @@ Full version information for the fingerprint enum values: ...@@ -47114,6 +47114,10 @@ Full version information for the fingerprint enum values:
<int value="66" label=".gslides"/> <int value="66" label=".gslides"/>
</enum> </enum>
<enum name="ViewsTextServicesContextMenu">
<int value="0" label="EMOJI"/>
</enum>
<enum name="VirtualKeyboardContainerType"> <enum name="VirtualKeyboardContainerType">
<int value="0" label="FULL_WIDTH"/> <int value="0" label="FULL_WIDTH"/>
<int value="1" label="FLOATING"/> <int value="1" label="FLOATING"/>
...@@ -25,4 +25,4 @@ bool ViewsTextServicesContextMenu::IsTextDirectionCheckedForTesting( ...@@ -25,4 +25,4 @@ bool ViewsTextServicesContextMenu::IsTextDirectionCheckedForTesting(
return false; return false;
} }
} // namespace views } // namespace views
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ui/views/controls/views_text_services_context_menu_base.h" #include "ui/views/controls/views_text_services_context_menu_base.h"
#include "base/metrics/histogram_macros.h"
#include "ui/base/emoji/emoji_panel_helper.h" #include "ui/base/emoji/emoji_panel_helper.h"
#include "ui/base/models/simple_menu_model.h" #include "ui/base/models/simple_menu_model.h"
#include "ui/resources/grit/ui_resources.h" #include "ui/resources/grit/ui_resources.h"
...@@ -12,6 +13,9 @@ ...@@ -12,6 +13,9 @@
namespace views { namespace views {
const char kViewsTextServicesContextMenuHistogram[] =
"ViewsTextServicesContextMenu.Used";
ViewsTextServicesContextMenuBase::ViewsTextServicesContextMenuBase( ViewsTextServicesContextMenuBase::ViewsTextServicesContextMenuBase(
ui::SimpleMenuModel* menu, ui::SimpleMenuModel* menu,
Textfield* client) Textfield* client)
...@@ -21,7 +25,7 @@ ViewsTextServicesContextMenuBase::ViewsTextServicesContextMenuBase( ...@@ -21,7 +25,7 @@ ViewsTextServicesContextMenuBase::ViewsTextServicesContextMenuBase(
// Not inserted on read-only fields or if the OS/version doesn't support it. // Not inserted on read-only fields or if the OS/version doesn't support it.
if (!client_->read_only() && ui::IsEmojiPanelSupported()) { if (!client_->read_only() && ui::IsEmojiPanelSupported()) {
menu->InsertSeparatorAt(0, ui::NORMAL_SEPARATOR); menu->InsertSeparatorAt(0, ui::NORMAL_SEPARATOR);
menu->InsertItemWithStringIdAt(0, IDS_CONTENT_CONTEXT_EMOJI, menu->InsertItemWithStringIdAt(0, static_cast<int>(Command::kEmoji),
IDS_CONTENT_CONTEXT_EMOJI); IDS_CONTENT_CONTEXT_EMOJI);
} }
} }
...@@ -29,7 +33,7 @@ ViewsTextServicesContextMenuBase::ViewsTextServicesContextMenuBase( ...@@ -29,7 +33,7 @@ ViewsTextServicesContextMenuBase::ViewsTextServicesContextMenuBase(
ViewsTextServicesContextMenuBase::~ViewsTextServicesContextMenuBase() {} ViewsTextServicesContextMenuBase::~ViewsTextServicesContextMenuBase() {}
bool ViewsTextServicesContextMenuBase::SupportsCommand(int command_id) const { bool ViewsTextServicesContextMenuBase::SupportsCommand(int command_id) const {
return command_id == IDS_CONTENT_CONTEXT_EMOJI; return command_id == static_cast<int>(Command::kEmoji);
} }
bool ViewsTextServicesContextMenuBase::IsCommandIdChecked( bool ViewsTextServicesContextMenuBase::IsCommandIdChecked(
...@@ -39,15 +43,18 @@ bool ViewsTextServicesContextMenuBase::IsCommandIdChecked( ...@@ -39,15 +43,18 @@ bool ViewsTextServicesContextMenuBase::IsCommandIdChecked(
bool ViewsTextServicesContextMenuBase::IsCommandIdEnabled( bool ViewsTextServicesContextMenuBase::IsCommandIdEnabled(
int command_id) const { int command_id) const {
if (command_id == IDS_CONTENT_CONTEXT_EMOJI) if (command_id == static_cast<int>(Command::kEmoji))
return true; return true;
return false; return false;
} }
void ViewsTextServicesContextMenuBase::ExecuteCommand(int command_id) { void ViewsTextServicesContextMenuBase::ExecuteCommand(int command_id) {
if (command_id == IDS_CONTENT_CONTEXT_EMOJI) if (command_id == static_cast<int>(Command::kEmoji)) {
ui::ShowEmojiPanel(); ui::ShowEmojiPanel();
UMA_HISTOGRAM_ENUMERATION(kViewsTextServicesContextMenuHistogram,
Command::kEmoji);
}
} }
} // namespace views } // namespace views
\ No newline at end of file
...@@ -30,6 +30,9 @@ class ViewsTextServicesContextMenuBase : public ViewsTextServicesContextMenu { ...@@ -30,6 +30,9 @@ class ViewsTextServicesContextMenuBase : public ViewsTextServicesContextMenu {
Textfield* client() const { return client_; } Textfield* client() const { return client_; }
private: private:
// Do not change the values in this enum as they are used by UMA.
enum class Command { kEmoji = 0, kMaxValue = kEmoji };
// The view associated with the menu. Weak. Owns |this|. // The view associated with the menu. Weak. Owns |this|.
Textfield* client_ = nullptr; Textfield* client_ = nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment