chromium/ui/qt/qt_ui.cc

// 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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

// IMPORTANT NOTE: All QtUi members that use `shim_` must be decorated
// with DISABLE_CFI_VCALL.

#include "ui/qt/qt_ui.h"

#include <dlfcn.h>

#include <algorithm>

#include "base/check.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/environment.h"
#include "base/memory/raw_ptr.h"
#include "base/nix/xdg_util.h"
#include "base/notreached.h"
#include "base/path_service.h"
#include "base/scoped_environment_variable_override.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "cc/paint/paint_canvas.h"
#include "chrome/browser/themes/theme_properties.h"  // nogncheck
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/ime/linux/linux_input_method_context.h"
#include "ui/color/color_mixer.h"
#include "ui/color/color_provider.h"
#include "ui/color/color_provider_manager.h"
#include "ui/color/color_recipe.h"
#include "ui/color/color_transform.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/font.h"
#include "ui/gfx/font_render_params.h"
#include "ui/gfx/font_render_params_linux.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/image/image_skia_source.h"
#include "ui/linux/device_scale_factor_observer.h"
#include "ui/linux/linux_ui.h"
#include "ui/linux/linux_ui_delegate.h"
#include "ui/linux/nav_button_provider.h"
#include "ui/native_theme/native_theme_aura.h"
#include "ui/native_theme/native_theme_base.h"
#include "ui/qt/qt_interface.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/select_file_policy.h"
#include "ui/views/controls/button/label_button_border.h"

namespace qt {

namespace {

const char kQtVersionFlag[] =;

void* LoadLibrary(const base::FilePath& path) {}

bool PreferQt6() {}

int Qt5WeightToCssWeight(int weight) {}

gfx::FontRenderParams::Hinting QtHintingToGfxHinting(
    qt::FontHinting hinting,
    gfx::FontRenderParams::Hinting default_hinting) {}

}  // namespace

class QtNativeTheme : public ui::NativeThemeAura {};

QtUi::QtUi(ui::LinuxUi* fallback_linux_ui)
    :{}

QtUi::~QtUi() = default;

std::unique_ptr<ui::LinuxInputMethodContext> QtUi::CreateInputMethodContext(
    ui::LinuxInputMethodContextDelegate* delegate) const {}

gfx::FontRenderParams QtUi::GetDefaultFontRenderParams() {}

ui::SelectFileDialog* QtUi::CreateSelectFileDialog(
    void* listener,
    std::unique_ptr<ui::SelectFilePolicy> policy) const {}

DISABLE_CFI_DLSYM
DISABLE_CFI_VCALL
bool QtUi::Initialize() {}

DISABLE_CFI_VCALL
void QtUi::InitializeFontSettings() {}

ui::NativeTheme* QtUi::GetNativeTheme() const {}

bool QtUi::GetColor(int id, SkColor* color, bool use_custom_frame) const {}

bool QtUi::GetDisplayProperty(int id, int* result) const {}

DISABLE_CFI_VCALL
void QtUi::GetFocusRingColor(SkColor* color) const {}

DISABLE_CFI_VCALL
void QtUi::GetActiveSelectionBgColor(SkColor* color) const {}

DISABLE_CFI_VCALL
void QtUi::GetActiveSelectionFgColor(SkColor* color) const {}

DISABLE_CFI_VCALL
void QtUi::GetInactiveSelectionBgColor(SkColor* color) const {}

DISABLE_CFI_VCALL
void QtUi::GetInactiveSelectionFgColor(SkColor* color) const {}

DISABLE_CFI_VCALL
base::TimeDelta QtUi::GetCursorBlinkInterval() const {}

DISABLE_CFI_VCALL
gfx::Image QtUi::GetIconForContentType(const std::string& content_type,
                                       int size,
                                       float scale) const {}

QtUi::WindowFrameAction QtUi::GetWindowFrameAction(
    WindowFrameActionSource source) {}

DISABLE_CFI_VCALL
bool QtUi::PreferDarkTheme() const {}

DISABLE_CFI_VCALL
void QtUi::SetDarkTheme(bool dark) {}

DISABLE_CFI_VCALL
void QtUi::SetAccentColor(std::optional<SkColor> accent_color) {}

DISABLE_CFI_VCALL
bool QtUi::AnimationsEnabled() const {}

void QtUi::AddWindowButtonOrderObserver(
    ui::WindowButtonOrderObserver* observer) {}

void QtUi::RemoveWindowButtonOrderObserver(
    ui::WindowButtonOrderObserver* observer) {}

std::unique_ptr<ui::NavButtonProvider> QtUi::CreateNavButtonProvider() {}

ui::WindowFrameProvider* QtUi::GetWindowFrameProvider(bool solid_frame,
                                                      bool tiled) {}

base::flat_map<std::string, std::string> QtUi::GetKeyboardLayoutMap() {}

std::string QtUi::GetCursorThemeName() {}

int QtUi::GetCursorThemeSize() {}

bool QtUi::GetTextEditCommandsForEvent(
    const ui::Event& event,
    int text_flags,
    std::vector<ui::TextEditCommandAuraLinux>* commands) {}

#if BUILDFLAG(ENABLE_PRINTING)
printing::PrintDialogLinuxInterface* QtUi::CreatePrintDialog(
    printing::PrintingContextLinux* context) {}

gfx::Size QtUi::GetPdfPaperSize(printing::PrintingContextLinux* context) {}
#endif

void QtUi::FontChanged() {}

void QtUi::ThemeChanged() {}

void QtUi::ScaleFactorMaybeChanged() {}

DISABLE_CFI_VCALL
void QtUi::AddNativeColorMixer(ui::ColorProvider* provider,
                               const ui::ColorProviderKey& key) {}

DISABLE_CFI_VCALL
std::optional<SkColor> QtUi::GetColor(int id, bool use_custom_frame) const {}

DISABLE_CFI_VCALL
void QtUi::ScaleFactorMaybeChangedImpl() {}

std::unique_ptr<ui::LinuxUiAndTheme> CreateQtUi(
    ui::LinuxUi* fallback_linux_ui) {}

}  // namespace qt