Commit 6ef75adf authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Fix SIs in terminal_system_app_menu_model_chromeos.cc.

Incorrect base::NoDestructor usage generated 6 static initializers.
As is, the static global has to be initialized when the program begins.
Move the declaration so it becomes a static local constant that is
instead initialized on first use.

Bug: 537099
Change-Id: Ieb64c7ba476331cd22ae2fb98960301166200d9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1820262Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699379}
parent 1479f75b
...@@ -20,21 +20,6 @@ ...@@ -20,21 +20,6 @@
#include "url/third_party/mozilla/url_parse.h" #include "url/third_party/mozilla/url_parse.h"
#include "url/url_canon.h" #include "url/url_canon.h"
namespace {
static const base::NoDestructor<base::flat_map<int, std::string>> g_commands({
// Opens settings page.
{IDC_OPTIONS, "options"},
// Split the currently selected pane vertically.
{IDC_TERMINAL_SPLIT_VERTICAL, "splitv"},
// Split the currently selected pane horizontally.
{IDC_TERMINAL_SPLIT_HORIZONTAL, "splith"},
// Open the find dialog.
{IDC_FIND, "find"},
});
} // namespace
TerminalSystemAppMenuModel::TerminalSystemAppMenuModel( TerminalSystemAppMenuModel::TerminalSystemAppMenuModel(
ui::AcceleratorProvider* provider, ui::AcceleratorProvider* provider,
Browser* browser) Browser* browser)
...@@ -57,12 +42,23 @@ bool TerminalSystemAppMenuModel::IsCommandIdEnabled(int command_id) const { ...@@ -57,12 +42,23 @@ bool TerminalSystemAppMenuModel::IsCommandIdEnabled(int command_id) const {
void TerminalSystemAppMenuModel::ExecuteCommand(int command_id, void TerminalSystemAppMenuModel::ExecuteCommand(int command_id,
int event_flags) { int event_flags) {
auto it = g_commands->find(command_id); static const base::NoDestructor<base::flat_map<int, std::string>> kCommands({
if (it == g_commands->end()) { // Opens settings page.
{IDC_OPTIONS, "options"},
// Split the currently selected pane vertically.
{IDC_TERMINAL_SPLIT_VERTICAL, "splitv"},
// Split the currently selected pane horizontally.
{IDC_TERMINAL_SPLIT_HORIZONTAL, "splith"},
// Open the find dialog.
{IDC_FIND, "find"},
});
auto it = kCommands->find(command_id);
if (it == kCommands->end()) {
NOTREACHED() << "Unknown command " << command_id; NOTREACHED() << "Unknown command " << command_id;
return; return;
} }
std::string fragment = it->second; const std::string& fragment = it->second;
url::Replacements<char> replacements; url::Replacements<char> replacements;
replacements.SetRef(fragment.c_str(), url::Component(0, fragment.size())); replacements.SetRef(fragment.c_str(), url::Component(0, fragment.size()));
NavigateParams params( NavigateParams params(
......
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