chromium/chrome/browser/devtools/protocol/pwa_handler.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/browser/devtools/protocol/pwa_handler.h"

#include <vector>

#include "base/check.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/concurrent_callbacks.h"
#include "base/numerics/clamped_math.h"
#include "base/strings/strcat.h"
#include "base/strings/to_string.h"
#include "base/types/expected.h"
#include "build/build_config.h"
#include "chrome/browser/badging/badge_manager.h"
#include "chrome/browser/badging/badge_manager_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/web_applications/locks/app_lock.h"
#include "chrome/browser/web_applications/os_integration/web_app_file_handler_manager.h"
#include "chrome/browser/web_applications/proto/web_app_os_integration_state.pb.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "chrome/browser/web_applications/web_app_install_params.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/common/url_constants.h"
#include "components/webapps/browser/install_result_code.h"
#include "components/webapps/browser/installable/installable_metrics.h"
#include "components/webapps/common/web_app_id.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/web_contents.h"
#include "third_party/blink/public/common/features.h"
#include "url/gurl.h"

namespace {

namespace errors {

// Returns a common error when WebApp component is unavailable in the scenario,
// e.g. in incognito mode.
protocol::Response WebAppUnavailable() {}

// Returns a common error when the to-be-installed webapp has a different
// manifest id than the required.
protocol::Response InconsistentManifestId(const std::string& in_manifest_id,
                                          const std::string& url_or_appid) {}

}  // namespace errors

FileHandlers;

base::expected<FileHandlers, protocol::Response> GetFileHandlersFromApp(
    const webapps::AppId app_id,
    const std::string in_manifest_id,
    web_app::AppLock& app_lock,
    base::Value::Dict& debug_value) {}

// A shared way to handle the callback of WebAppUiManager::LaunchApp.
base::expected<std::string, protocol::Response> GetTargetIdFromLaunch(
    const std::string& in_manifest_id,
    const std::optional<GURL>& url,
    base::WeakPtr<Browser> browser,
    base::WeakPtr<content::WebContents> web_contents,
    apps::LaunchContainer container) {}

}  // namespace

PWAHandler::PWAHandler(protocol::UberDispatcher* dispatcher,
                       const std::string& target_id)
    :{}

PWAHandler::~PWAHandler() = default;

// TODO(crbug.com/331214986): Consider if the API should allow setting a browser
// context id as the profile id to override the default behavior.
Profile* PWAHandler::GetProfile() const {}

web_app::WebAppCommandScheduler* PWAHandler::GetScheduler() const {}

content::WebContents* PWAHandler::GetWebContents() const {}

void PWAHandler::GetOsAppState(
    const std::string& in_manifest_id,
    std::unique_ptr<GetOsAppStateCallback> callback) {}

// Install from the manifest_id only. Require a WebContents.
void PWAHandler::InstallFromManifestId(
    const std::string& in_manifest_id,
    std::unique_ptr<InstallCallback> callback) {}

void PWAHandler::InstallFromUrl(const std::string& in_manifest_id,
                                const std::string& in_install_url_or_bundle_url,
                                std::unique_ptr<InstallCallback> callback) {}

void PWAHandler::InstallFromInstallInfo(
    const std::string& in_manifest_id,
    const std::string& in_install_url_or_bundle_url,
    std::unique_ptr<InstallCallback> callback,
    std::unique_ptr<web_app::WebAppInstallInfo> web_app_info) {}

void PWAHandler::Install(
    const std::string& in_manifest_id,
    protocol::Maybe<std::string> in_install_url_or_bundle_url,
    std::unique_ptr<InstallCallback> callback) {}

void PWAHandler::Uninstall(const std::string& in_manifest_id,
                           std::unique_ptr<UninstallCallback> callback) {}

void PWAHandler::Launch(const std::string& in_manifest_id,
                        protocol::Maybe<std::string> in_url,
                        std::unique_ptr<LaunchCallback> callback) {}

void PWAHandler::LaunchFilesInApp(
    const std::string& in_manifest_id,
    std::unique_ptr<protocol::Array<std::string>> in_files,
    std::unique_ptr<LaunchFilesInAppCallback> callback) {}

protocol::Response PWAHandler::OpenCurrentPageInApp(
    const std::string& in_manifest_id) {}

void PWAHandler::ChangeAppUserSettings(
    const std::string& in_manifest_id,
    protocol::Maybe<bool> in_link_capturing,
    protocol::Maybe<protocol::PWA::DisplayMode> in_display_mode,
    std::unique_ptr<ChangeAppUserSettingsCallback> callback) {}