Commit 5fadbe2d authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Fix some nits in renderer_context_menu.cc.

- Make IDC to UMA maps constants.
- Use base::Contains() to improve readability.

Change-Id: I100d8b5dfc87cca4fb26eef06df082364a0ea8fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429538Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810715}
parent ec504a5b
...@@ -257,7 +257,7 @@ const std::map<int, int>& GetIdcToUmaMap(UmaEnumIdLookupType type) { ...@@ -257,7 +257,7 @@ const std::map<int, int>& GetIdcToUmaMap(UmaEnumIdLookupType type) {
// These UMA values are for the the RenderViewContextMenuItem enum, used for // These UMA values are for the the RenderViewContextMenuItem enum, used for
// the RenderViewContextMenu.Shown and RenderViewContextMenu.Used histograms. // the RenderViewContextMenu.Shown and RenderViewContextMenu.Used histograms.
static base::NoDestructor<std::map<int, int>> general_map( static const base::NoDestructor<std::map<int, int>> kGeneralMap(
{// NB: UMA values for 0 and 1 are detected using {// NB: UMA values for 0 and 1 are detected using
// RenderViewContextMenu::IsContentCustomCommandId() and // RenderViewContextMenu::IsContentCustomCommandId() and
// ContextMenuMatcher::IsExtensionsCustomCommandId() // ContextMenuMatcher::IsExtensionsCustomCommandId()
...@@ -375,7 +375,7 @@ const std::map<int, int>& GetIdcToUmaMap(UmaEnumIdLookupType type) { ...@@ -375,7 +375,7 @@ const std::map<int, int>& GetIdcToUmaMap(UmaEnumIdLookupType type) {
// These UMA values are for the the ContextMenuOptionDesktop enum, used for // These UMA values are for the the ContextMenuOptionDesktop enum, used for
// the ContextMenu.SelectedOptionDesktop histograms. // the ContextMenu.SelectedOptionDesktop histograms.
static base::NoDestructor<std::map<int, int>> specific_map( static const base::NoDestructor<std::map<int, int>> kSpecificMap(
{{IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0}, {{IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0},
{IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, 1}, {IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, 1},
{IDC_CONTENT_CONTEXT_COPYLINKLOCATION, 2}, {IDC_CONTENT_CONTEXT_COPYLINKLOCATION, 2},
...@@ -404,8 +404,8 @@ const std::map<int, int>& GetIdcToUmaMap(UmaEnumIdLookupType type) { ...@@ -404,8 +404,8 @@ const std::map<int, int>& GetIdcToUmaMap(UmaEnumIdLookupType type) {
// tools/metrics/histograms/enums.xml. // tools/metrics/histograms/enums.xml.
{0, 20}}); {0, 20}});
return *(type == UmaEnumIdLookupType::GeneralEnumId ? general_map return *(type == UmaEnumIdLookupType::GeneralEnumId ? kGeneralMap
: specific_map); : kSpecificMap);
} }
int GetUmaValueMax(UmaEnumIdLookupType type) { int GetUmaValueMax(UmaEnumIdLookupType type) {
...@@ -1628,10 +1628,11 @@ void RenderViewContextMenu::AppendSearchProvider() { ...@@ -1628,10 +1628,11 @@ void RenderViewContextMenu::AppendSearchProvider() {
if (!default_provider) if (!default_provider)
return; return;
if (params_.properties.find( if (!base::Contains(
prefs::kDefaultSearchProviderContextMenuAccessAllowed) == params_.properties,
params_.properties.end()) prefs::kDefaultSearchProviderContextMenuAccessAllowed)) {
return; return;
}
menu_model_.AddItem( menu_model_.AddItem(
IDC_CONTENT_CONTEXT_SEARCHWEBFOR, IDC_CONTENT_CONTEXT_SEARCHWEBFOR,
......
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