chromium/ui/file_manager/base/gn/uma_enums.cc.jinja

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ash/file_manager/uma_enums.gen.h"

#include <algorithm>

#include "base/strings/string_util.h"

// File generated by //ui/file_manager/base/gn/uma_enums_generate.py.
namespace file_manager::file_tasks {

ViewFileType GetViewFileType(const base::FilePath& path) {
  static constexpr auto kViewFileTypes = {
{% for e in enums %}
      "{{e.lower()}}",
{% endfor %}
  };

  auto* const* it = std::find(kViewFileTypes.begin(), kViewFileTypes.end(),
                              base::ToLowerASCII(path.FinalExtension()));
  if (it != kViewFileTypes.end()) {
    return static_cast<ViewFileType>(std::distance(kViewFileTypes.begin(), it));
  }
  return ViewFileType::kOther;
}

}  // namespace file_manager::file_tasks