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:
<int value="66" label=".gslides"/>
</enum>
<enum name="ViewsTextServicesContextMenu">
<int value="0" label="EMOJI"/>
</enum>
<enum name="VirtualKeyboardContainerType">
<int value="0" label="FULL_WIDTH"/>
<int value="1" label="FLOATING"/>
......@@ -25,4 +25,4 @@ bool ViewsTextServicesContextMenu::IsTextDirectionCheckedForTesting(
return false;
}
} // namespace views
\ No newline at end of file
} // namespace views
......@@ -4,6 +4,7 @@
#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/models/simple_menu_model.h"
#include "ui/resources/grit/ui_resources.h"
......@@ -12,6 +13,9 @@
namespace views {
const char kViewsTextServicesContextMenuHistogram[] =
"ViewsTextServicesContextMenu.Used";
ViewsTextServicesContextMenuBase::ViewsTextServicesContextMenuBase(
ui::SimpleMenuModel* menu,
Textfield* client)
......@@ -21,7 +25,7 @@ ViewsTextServicesContextMenuBase::ViewsTextServicesContextMenuBase(
// Not inserted on read-only fields or if the OS/version doesn't support it.
if (!client_->read_only() && ui::IsEmojiPanelSupported()) {
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);
}
}
......@@ -29,7 +33,7 @@ ViewsTextServicesContextMenuBase::ViewsTextServicesContextMenuBase(
ViewsTextServicesContextMenuBase::~ViewsTextServicesContextMenuBase() {}
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(
......@@ -39,15 +43,18 @@ bool ViewsTextServicesContextMenuBase::IsCommandIdChecked(
bool ViewsTextServicesContextMenuBase::IsCommandIdEnabled(
int command_id) const {
if (command_id == IDS_CONTENT_CONTEXT_EMOJI)
if (command_id == static_cast<int>(Command::kEmoji))
return true;
return false;
}
void ViewsTextServicesContextMenuBase::ExecuteCommand(int command_id) {
if (command_id == IDS_CONTENT_CONTEXT_EMOJI)
if (command_id == static_cast<int>(Command::kEmoji)) {
ui::ShowEmojiPanel();
UMA_HISTOGRAM_ENUMERATION(kViewsTextServicesContextMenuHistogram,
Command::kEmoji);
}
}
} // namespace views
\ No newline at end of file
} // namespace views
......@@ -30,6 +30,9 @@ class ViewsTextServicesContextMenuBase : public ViewsTextServicesContextMenu {
Textfield* client() const { return client_; }
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|.
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