#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/test/chromedriver/util.h"
#include <stddef.h>
#include <stdint.h>
#include <string>
#include <string_view>
#include "base/base64.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/format_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/rand_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/third_party/icu/icu_utf.h"
#include "base/values.h"
#include "chrome/test/chromedriver/chrome/browser_info.h"
#include "chrome/test/chromedriver/chrome/chrome.h"
#include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/chrome/ui_events.h"
#include "chrome/test/chromedriver/chrome/web_view.h"
#include "chrome/test/chromedriver/command_listener.h"
#include "chrome/test/chromedriver/constants/version.h"
#include "chrome/test/chromedriver/key_converter.h"
#include "chrome/test/chromedriver/session.h"
#include "third_party/zlib/google/zip.h"
std::string GenerateId() { … }
namespace {
const double kCentimetersPerInch = …;
Status FlattenStringArray(const base::Value::List* src, std::u16string* dest) { … }
}
Status SendKeysOnWindow(WebView* web_view,
const base::Value::List* key_list,
bool release_modifiers,
int* sticky_modifiers) { … }
bool Base64Decode(const std::string& base64,
std::string* bytes) { … }
namespace {
Status UnzipArchive(const base::FilePath& unzip_dir,
const std::string& bytes) { … }
class DataOutputStream { … };
class DataInputStream { … };
struct ZipEntry { … };
const uint32_t ZipEntry::kFileHeaderSignature = …;
const uint32_t ZipEntry::kDataDescriptorSignature = …;
const uint32_t ZipEntry::kCentralDirSignature = …;
const uint32_t ZipEntry::kEndOfCentralDirSignature = …;
Status UnzipEntry(const base::FilePath& unzip_dir,
const std::string& bytes) { … }
}
Status UnzipSoleFile(const base::FilePath& unzip_dir,
const std::string& bytes,
base::FilePath* file) { … }
Status NotifyCommandListenersBeforeCommand(Session* session,
const std::string& command_name) { … }
double ConvertCentimeterToInch(double centimeter) { … }
namespace {
template <typename T>
bool GetOptionalValue(const base::Value::Dict& dict,
std::string_view path,
T* out_value,
bool* has_value,
std::optional<T> (base::Value::*getter)() const) { … }
}
bool GetOptionalBool(const base::Value::Dict& dict,
std::string_view path,
bool* out_value,
bool* has_value) { … }
bool GetOptionalInt(const base::Value::Dict& dict,
std::string_view path,
int* out_value,
bool* has_value) { … }
bool GetOptionalDouble(const base::Value::Dict& dict,
std::string_view path,
double* out_value,
bool* has_value) { … }
bool GetOptionalString(const base::Value::Dict& dict,
std::string_view path,
std::string* out_value,
bool* has_value) { … }
bool GetOptionalDictionary(const base::Value::Dict& dict,
std::string_view path,
const base::Value::Dict** out_value,
bool* has_value) { … }
bool GetOptionalList(const base::Value::Dict& dict,
std::string_view path,
const base::Value::List** out_value,
bool* has_value) { … }
bool GetOptionalSafeInt(const base::Value::Dict& dict,
std::string_view path,
int64_t* out_value,
bool* has_value) { … }
bool SetSafeInt(base::Value::Dict& dict,
const std::string_view path,
int64_t in_value_64) { … }