chromium/chrome/enterprise_companion/enterprise_companion_client.cc

// Copyright 2024 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/enterprise_companion/enterprise_companion_client.h"

#include <memory>
#include <optional>
#include <utility>

#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/process/launch.h"
#include "base/task/bind_post_task.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/enterprise_companion/enterprise_companion_branding.h"
#include "chrome/enterprise_companion/installer_paths.h"
#include "chrome/enterprise_companion/mojom/enterprise_companion.mojom.h"
#include "components/named_mojo_ipc_server/named_mojo_ipc_server_client_util.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/platform/named_platform_channel.h"
#include "mojo/public/cpp/platform/platform_channel_endpoint.h"
#include "mojo/public/cpp/system/isolated_connection.h"

namespace enterprise_companion {

const char kEnableUsageStatsSwitch[] =;

namespace {

#if BUILDFLAG(IS_MAC)
constexpr char kServerName[] = MAC_BUNDLE_IDENTIFIER_STRING ".service";
#elif BUILDFLAG(IS_LINUX)
constexpr char kServerName[] = COMPANY_SHORTNAME_STRING "/" PRODUCT_FULLNAME_STRING "/service.sk";
#elif BUILDFLAG(IS_WIN)
constexpr wchar_t kServerName[] = PRODUCT_FULLNAME_STRING L"Service";
#endif

bool LaunchEnterpriseCompanionApp(bool enable_usagestats) {}

void OnEndpointReceived(
    base::OnceCallback<void(std::unique_ptr<mojo::IsolatedConnection>,
                            mojo::Remote<mojom::EnterpriseCompanion>)> callback,
    mojo::PlatformChannelEndpoint endpoint) {}

// Repeatedly attempts to connect to the remote service until `deadline` is
// exhausted. If the service could not be reached after the first attempt, the
// application is launched.
void ConnectWithRetries(
    const mojo::NamedPlatformChannel::ServerName& server_name,
    const base::Clock* clock,
    int tries,
    base::Time deadline,
    bool enable_usagestats,
    base::OnceCallback<void(mojo::PlatformChannelEndpoint)> callback) {}

}  // namespace

mojo::NamedPlatformChannel::ServerName GetServerName() {}

void ConnectToServer(
    base::OnceCallback<void(std::unique_ptr<mojo::IsolatedConnection>,
                            mojo::Remote<mojom::EnterpriseCompanion>)> callback,
    const mojo::NamedPlatformChannel::ServerName& server_name) {}

void ConnectAndLaunchServer(
    const base::Clock* clock,
    base::TimeDelta timeout,
    bool enable_usagestats,
    base::OnceCallback<void(std::unique_ptr<mojo::IsolatedConnection>,
                            mojo::Remote<mojom::EnterpriseCompanion>)> callback,
    const mojo::NamedPlatformChannel::ServerName& server_name) {}

}  // namespace enterprise_companion