chromium/ui/shell_dialogs/select_file_dialog_linux_portal.cc

// Copyright 2021 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

#include "ui/shell_dialogs/select_file_dialog_linux_portal.h"

#include <string_view>

#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "components/dbus/thread_linux/dbus_thread_linux.h"
#include "dbus/object_path.h"
#include "dbus/property.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/linux/linux_ui_delegate.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/selected_file_info.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
#include "url/gurl.h"
#include "url/url_util.h"

namespace ui {

namespace {

constexpr char kDBusMethodNameHasOwner[] =;
constexpr char kDBusMethodListActivatableNames[] =;
constexpr char kMethodStartServiceByName[] =;

constexpr char kXdgPortalService[] =;
constexpr char kXdgPortalObject[] =;

constexpr int kXdgPortalRequiredVersion =;

constexpr char kXdgPortalRequestInterfaceName[] =;
constexpr char kXdgPortalResponseSignal[] =;

constexpr char kFileChooserInterfaceName[] =;

constexpr char kFileChooserMethodOpenFile[] =;
constexpr char kFileChooserMethodSaveFile[] =;

constexpr char kFileChooserOptionHandleToken[] =;
constexpr char kFileChooserOptionAcceptLabel[] =;
constexpr char kFileChooserOptionMultiple[] =;
constexpr char kFileChooserOptionDirectory[] =;
constexpr char kFileChooserOptionFilters[] =;
constexpr char kFileChooserOptionCurrentFilter[] =;
constexpr char kFileChooserOptionCurrentFolder[] =;
constexpr char kFileChooserOptionCurrentName[] =;
constexpr char kFileChooserOptionModal[] =;

constexpr int kFileChooserFilterKindGlob =;

constexpr char kFileUriPrefix[] =;

// Time to wait for the notification service to start, in milliseconds.
constexpr base::TimeDelta kStartServiceTimeout =;

struct FileChooserProperties : dbus::PropertySet {};

void AppendStringOption(dbus::MessageWriter* writer,
                        const std::string& name,
                        const std::string& value) {}

void AppendByteStringOption(dbus::MessageWriter* writer,
                            const std::string& name,
                            const std::string& value) {}

void AppendBoolOption(dbus::MessageWriter* writer,
                      const std::string& name,
                      bool value) {}

scoped_refptr<dbus::Bus>* AcquireBusStorageOnBusThread() {}

dbus::Bus* AcquireBusOnBusThread() {}

void DestroyBusOnBusThread() {}

}  // namespace

SelectFileDialogLinuxPortal::SelectFileDialogLinuxPortal(
    Listener* listener,
    std::unique_ptr<ui::SelectFilePolicy> policy)
    :{}

SelectFileDialogLinuxPortal::~SelectFileDialogLinuxPortal() {}

// static
void SelectFileDialogLinuxPortal::StartAvailabilityTestInBackground() {}

// static
bool SelectFileDialogLinuxPortal::IsPortalAvailable() {}

// static
void SelectFileDialogLinuxPortal::DestroyPortalConnection() {}

bool SelectFileDialogLinuxPortal::IsRunning(
    gfx::NativeWindow parent_window) const {}

void SelectFileDialogLinuxPortal::SelectFileImpl(
    Type type,
    const std::u16string& title,
    const base::FilePath& default_path,
    const FileTypeInfo* file_types,
    int file_type_index,
    const base::FilePath::StringType& default_extension,
    gfx::NativeWindow owning_window,
    const GURL* caller) {}

bool SelectFileDialogLinuxPortal::HasMultipleFileTypeChoicesImpl() {}

// static
void SelectFileDialogLinuxPortal::CheckPortalAvailabilityOnBusThread() {}

// static
bool SelectFileDialogLinuxPortal::IsPortalRunningOnBusThread(
    dbus::ObjectProxy* dbus_proxy) {}

// static
bool SelectFileDialogLinuxPortal::IsPortalActivatableOnBusThread(
    dbus::ObjectProxy* dbus_proxy) {}

SelectFileDialogLinuxPortal::PortalFilter::PortalFilter() = default;
SelectFileDialogLinuxPortal::PortalFilter::PortalFilter(
    const PortalFilter& other) = default;
SelectFileDialogLinuxPortal::PortalFilter::PortalFilter(PortalFilter&& other) =
    default;
SelectFileDialogLinuxPortal::PortalFilter::~PortalFilter() = default;

SelectFileDialogLinuxPortal::PortalFilterSet::PortalFilterSet() = default;
SelectFileDialogLinuxPortal::PortalFilterSet::PortalFilterSet(
    const PortalFilterSet& other) = default;
SelectFileDialogLinuxPortal::PortalFilterSet::PortalFilterSet(
    PortalFilterSet&& other) = default;
SelectFileDialogLinuxPortal::PortalFilterSet::~PortalFilterSet() = default;

SelectFileDialogLinuxPortal::DialogInfo::DialogInfo(
    base::OnceClosure created_callback,
    OnSelectFileExecutedCallback selected_callback,
    OnSelectFileCanceledCallback canceled_callback)
    :{}
SelectFileDialogLinuxPortal::DialogInfo::~DialogInfo() = default;

// static
base::AtomicFlag*
SelectFileDialogLinuxPortal::GetAvailabilityTestCompletionFlag() {}

SelectFileDialogLinuxPortal::PortalFilterSet
SelectFileDialogLinuxPortal::BuildFilterSet() {}

void SelectFileDialogLinuxPortal::SelectFileImplWithParentHandle(
    std::u16string title,
    base::FilePath default_path,
    PortalFilterSet filter_set,
    base::FilePath::StringType default_extension,
    std::string parent_handle) {}

void SelectFileDialogLinuxPortal::DialogInfo::SelectFileImplOnBusThread(
    std::u16string title,
    base::FilePath default_path,
    const bool default_path_exists,
    PortalFilterSet filter_set,
    base::FilePath::StringType default_extension,
    std::string parent_handle) {}

void SelectFileDialogLinuxPortal::DialogInfo::AppendOptions(
    dbus::MessageWriter* writer,
    const std::string& response_handle_token,
    const base::FilePath& default_path,
    const bool default_path_exists,
    const SelectFileDialogLinuxPortal::PortalFilterSet& filter_set) {}

void SelectFileDialogLinuxPortal::DialogInfo::AppendFiltersOption(
    dbus::MessageWriter* writer,
    const std::vector<PortalFilter>& filters) {}

void SelectFileDialogLinuxPortal::DialogInfo::AppendFilterStruct(
    dbus::MessageWriter* writer,
    const PortalFilter& filter) {}

void SelectFileDialogLinuxPortal::DialogInfo::ConnectToHandle() {}

void SelectFileDialogLinuxPortal::DialogInfo::CompleteOpen(
    std::vector<base::FilePath> paths,
    std::string current_filter) {}

void SelectFileDialogLinuxPortal::DialogInfo::CancelOpen() {}

void SelectFileDialogLinuxPortal::DialogCreatedOnMainThread() {}

void SelectFileDialogLinuxPortal::CompleteOpenOnMainThread(
    std::vector<base::FilePath> paths,
    std::string current_filter) {}

void SelectFileDialogLinuxPortal::CancelOpenOnMainThread() {}

void SelectFileDialogLinuxPortal::UnparentOnMainThread() {}

void SelectFileDialogLinuxPortal::DialogInfo::OnCallResponse(
    dbus::Bus* bus,
    dbus::Response* response,
    dbus::ErrorResponse* error_response) {}

void SelectFileDialogLinuxPortal::DialogInfo::OnResponseSignalConnected(
    const std::string& interface,
    const std::string& signal,
    bool connected) {}

void SelectFileDialogLinuxPortal::DialogInfo::OnResponseSignalEmitted(
    dbus::Signal* signal) {}

bool SelectFileDialogLinuxPortal::DialogInfo::CheckResponseCode(
    dbus::MessageReader* reader) {}

bool SelectFileDialogLinuxPortal::DialogInfo::ReadResponseResults(
    dbus::MessageReader* reader,
    std::vector<std::string>* uris,
    std::string* current_filter) {}

std::vector<base::FilePath>
SelectFileDialogLinuxPortal::DialogInfo::ConvertUrisToPaths(
    const std::vector<std::string>& uris) {}

bool SelectFileDialogLinuxPortal::is_portal_available_ =;
int SelectFileDialogLinuxPortal::handle_token_counter_ =;

}  // namespace ui