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

#ifndef CHROME_BROWSER_EXTENSIONS_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_UTILS_H_
#define CHROME_BROWSER_EXTENSIONS_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_UTILS_H_

#include "ash/display/cros_display_config.h"
#include "extensions/common/api/system_display.h"
#include "ui/display/display_layout.h"
#include "ui/display/manager/touch_device_manager.h"
#include "ui/gfx/geometry/insets.h"

namespace display {
class Display;
}  // namespace display

namespace extensions {

// Converts display id string to number.
// Returns invalid id in case of error.
int64_t GetDisplayId(const std::string& display_id_str);

// Returns a display object for if display id is found.
// Return empty display object otherwise.
display::Display GetDisplayForId(int64_t display_id);

// Converts display layout `position` from extension api to ui type.
display::DisplayPlacement::Position GetDisplayLayoutPosition(
    api::system_display::LayoutPosition position);

// Converts system display `insets` to gfx type.
gfx::Insets GetInsets(const api::system_display::Insets& insets);

// Validates the DisplayProperties input. Does not perform any tests with
// DisplayManager dependencies. Returns an error string on failure or nullopt
// on success.
std::optional<std::string> ValidateDisplayPropertiesInput(
    int64_t display_id,
    const api::system_display::DisplayProperties& info);

// Converts display unit info from ash type to api type.
api::system_display::DisplayUnitInfo GetDisplayUnitInfoFromAsh(
    const ash::DisplayUnitInfo& ash_info);

// Converts from the api type of touch calibration pairs to the ui one.
display::TouchCalibrationData::CalibrationPointPair GetTouchCalibrationPair(
    const api::system_display::TouchCalibrationPair& pair);

void SetDisplayUnitInfoLayoutProperties(
    const ash::DisplayLayoutInfo& layout,
    api::system_display::DisplayUnitInfo* display);

}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_UTILS_H_
