chromium/chrome/test/chromedriver/chrome_launcher.cc

// Copyright 2013 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/test/chromedriver/chrome_launcher.h"

#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <memory>
#include <utility>
#include <vector>

#include "base/base64.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/format_macros.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "base/process/process.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_version.h"
#include "chrome/test/chromedriver/chrome/browser_info.h"
#include "chrome/test/chromedriver/chrome/chrome_android_impl.h"
#include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h"
#include "chrome/test/chromedriver/chrome/chrome_finder.h"
#include "chrome/test/chromedriver/chrome/chrome_remote_impl.h"
#include "chrome/test/chromedriver/chrome/device_manager.h"
#include "chrome/test/chromedriver/chrome/devtools_client_impl.h"
#include "chrome/test/chromedriver/chrome/devtools_event_listener.h"
#include "chrome/test/chromedriver/chrome/devtools_http_client.h"
#include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/chrome/target_utils.h"
#include "chrome/test/chromedriver/chrome/user_data_dir.h"
#include "chrome/test/chromedriver/chrome/web_view.h"
#include "chrome/test/chromedriver/constants/version.h"
#include "chrome/test/chromedriver/log_replay/chrome_replay_impl.h"
#include "chrome/test/chromedriver/log_replay/log_replay_socket.h"
#include "chrome/test/chromedriver/log_replay/replay_http_client.h"
#include "chrome/test/chromedriver/net/net_util.h"
#include "chrome/test/chromedriver/net/pipe_builder.h"
#include "chrome/test/chromedriver/net/sync_websocket.h"
#include "chrome/test/chromedriver/net/sync_websocket_factory.h"
#include "components/crx_file/crx_verifier.h"
#include "components/embedder_support/switches.h"
#include "crypto/rsa_private_key.h"
#include "crypto/sha2.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "third_party/zlib/google/zip.h"
#include "url/gurl.h"

#if BUILDFLAG(IS_MAC)
#include "chrome/test/chromedriver/buildflags.h"
#endif

#if BUILDFLAG(IS_POSIX)
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#elif BUILDFLAG(IS_WIN)
#include <windows.h>

#include "chrome/test/chromedriver/keycode_text_conversion.h"
#endif

namespace {

const char* const kCommonSwitches[] =;

const char* const kDesktopSwitches[] =;

#if BUILDFLAG(IS_WIN)

const char* const kWindowsDesktopSwitches[] = {
    "disable-backgrounding-occluded-windows",
};

#endif

const char* const kAndroidSwitches[] =;

const char kEnableCrashReport[] =;
const base::FilePath::CharType kDevToolsActivePort[] =);

enum ChromeType {};

Status WrapStatusIfNeeded(Status status, StatusCode code) {}

Status PrepareDesktopCommandLine(const Capabilities& capabilities,
                                 bool enable_chrome_logs,
                                 base::ScopedTempDir& user_data_dir_temp_dir,
                                 base::ScopedTempDir& extension_dir,
                                 base::CommandLine& prepared_command,
                                 std::vector<std::string>& extension_bg_pages,
                                 base::FilePath& user_data_dir) {}

Status GetBrowserInfo(DevToolsClient& client,
                      const Timeout& timeout,
                      BrowserInfo& browser_info) {}

Status CheckVersion(const BrowserInfo& browser_info,
                    const Capabilities& capabilities,
                    ChromeType ct,
                    std::string fp = "") {}

Status WaitForDevToolsAndCheckVersion(
    const DevToolsEndpoint& endpoint,
    network::mojom::URLLoaderFactory* factory,
    const Capabilities& capabilities,
    const Timeout& timeout,
    ChromeType ct,
    std::unique_ptr<DevToolsHttpClient>& user_client,
    bool& retry,
    std::string fp = "") {}

Status CreateBrowserwideDevToolsClientAndConnect(
    std::unique_ptr<SyncWebSocket> socket,
    const std::vector<std::unique_ptr<DevToolsEventListener>>&
        devtools_event_listeners,
    const std::string& web_socket_url,
    bool autoaccept_beforeunload,
    std::unique_ptr<DevToolsClient>& browser_client) {}

Status LaunchRemoteChromeSession(
    network::mojom::URLLoaderFactory* factory,
    const SyncWebSocketFactory& socket_factory,
    const Capabilities& capabilities,
    std::vector<std::unique_ptr<DevToolsEventListener>>
        devtools_event_listeners,
    std::unique_ptr<Chrome>& chrome) {}

Status LaunchDesktopChrome(network::mojom::URLLoaderFactory* factory,
                           const SyncWebSocketFactory& socket_factory,
                           const Capabilities& capabilities,
                           std::vector<std::unique_ptr<DevToolsEventListener>>
                               devtools_event_listeners,
                           bool w3c_compliant,
                           std::unique_ptr<Chrome>& chrome) {}

Status LaunchAndroidChrome(network::mojom::URLLoaderFactory* factory,
                           const SyncWebSocketFactory& socket_factory,
                           const Capabilities& capabilities,
                           std::vector<std::unique_ptr<DevToolsEventListener>>
                               devtools_event_listeners,
                           DeviceManager& device_manager,
                           std::unique_ptr<Chrome>& chrome) {}

Status LaunchReplayChrome(network::mojom::URLLoaderFactory* factory,
                          const Capabilities& capabilities,
                          std::vector<std::unique_ptr<DevToolsEventListener>>
                              devtools_event_listeners,
                          bool w3c_compliant,
                          std::unique_ptr<Chrome>& chrome) {}

}  // namespace

Switches GetDesktopSwitches() {}

Status LaunchChrome(network::mojom::URLLoaderFactory* factory,
                    const SyncWebSocketFactory& socket_factory,
                    DeviceManager& device_manager,
                    const Capabilities& capabilities,
                    std::vector<std::unique_ptr<DevToolsEventListener>>
                        devtools_event_listeners,
                    bool w3c_compliant,
                    std::unique_ptr<Chrome>& chrome) {}

namespace internal {

void ConvertHexadecimalToIDAlphabet(std::string& id) {}

std::string GenerateExtensionId(const std::string& input) {}

Status GetExtensionBackgroundPage(const base::Value::Dict& manifest,
                                  const std::string& id,
                                  std::string& bg_page) {}

Status ProcessExtension(const std::string& extension,
                        const base::FilePath& temp_dir,
                        base::FilePath& path,
                        std::string& bg_page) {}

void UpdateExtensionSwitch(Switches& switches,
                           const char name[],
                           const std::string& extension) {}

Status ProcessExtensions(const std::vector<std::string>& extensions,
                         const base::FilePath& temp_dir,
                         Switches& switches,
                         std::vector<std::string>& bg_pages) {}

Status WritePrefsFile(const std::string& template_string,
                      const base::FilePath& path,
                      const base::Value::Dict* custom_prefs) {}

Status PrepareUserDataDir(const base::FilePath& user_data_dir,
                          const base::Value::Dict* custom_prefs,
                          const base::Value::Dict* custom_local_state) {}

Status ParseDevToolsActivePortFile(const base::FilePath& user_data_dir,
                                   int& port) {}

Status RemoveOldDevToolsActivePortFile(const base::FilePath& user_data_dir) {}

std::string GetTerminationReason(base::TerminationStatus status) {}

}  // namespace internal