mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update to Chromium version 125.0.6422.0 (#1287751)
This commit is contained in:
@@ -29,7 +29,7 @@ CefDevToolsController::~CefDevToolsController() {
|
||||
}
|
||||
|
||||
bool CefDevToolsController::SendDevToolsMessage(
|
||||
const base::StringPiece& message) {
|
||||
const std::string_view& message) {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!EnsureAgentHost()) {
|
||||
return false;
|
||||
@@ -100,8 +100,8 @@ void CefDevToolsController::DispatchProtocolMessage(
|
||||
return;
|
||||
}
|
||||
|
||||
base::StringPiece str_message(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
std::string_view str_message(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
if (!devtools_util::ProtocolParser::IsValidMessage(str_message)) {
|
||||
LOG(WARNING) << "Invalid message: " << str_message.substr(0, 100);
|
||||
return;
|
||||
|
@@ -7,13 +7,12 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "content/public/browser/devtools_agent_host_client.h"
|
||||
|
||||
#include "base/containers/span.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/devtools_agent_host_client.h"
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
@@ -24,12 +23,12 @@ class CefDevToolsController : public content::DevToolsAgentHostClient {
|
||||
class Observer : public base::CheckedObserver {
|
||||
public:
|
||||
// See CefDevToolsMessageObserver documentation.
|
||||
virtual bool OnDevToolsMessage(const base::StringPiece& message) = 0;
|
||||
virtual bool OnDevToolsMessage(const std::string_view& message) = 0;
|
||||
virtual void OnDevToolsMethodResult(int message_id,
|
||||
bool success,
|
||||
const base::StringPiece& result) = 0;
|
||||
virtual void OnDevToolsEvent(const base::StringPiece& method,
|
||||
const base::StringPiece& params) = 0;
|
||||
const std::string_view& result) = 0;
|
||||
virtual void OnDevToolsEvent(const std::string_view& method,
|
||||
const std::string_view& params) = 0;
|
||||
virtual void OnDevToolsAgentAttached() = 0;
|
||||
virtual void OnDevToolsAgentDetached() = 0;
|
||||
|
||||
@@ -48,7 +47,7 @@ class CefDevToolsController : public content::DevToolsAgentHostClient {
|
||||
~CefDevToolsController() override;
|
||||
|
||||
// See CefBrowserHost methods of the same name for documentation.
|
||||
bool SendDevToolsMessage(const base::StringPiece& message);
|
||||
bool SendDevToolsMessage(const std::string_view& message);
|
||||
int ExecuteDevToolsMethod(int message_id,
|
||||
const std::string& method,
|
||||
const base::Value::Dict* params);
|
||||
|
@@ -50,7 +50,7 @@ class CefDevToolsRegistrationImpl : public CefRegistration,
|
||||
|
||||
private:
|
||||
// CefDevToolsController::Observer methods:
|
||||
bool OnDevToolsMessage(const base::StringPiece& message) override {
|
||||
bool OnDevToolsMessage(const std::string_view& message) override {
|
||||
CEF_REQUIRE_UIT();
|
||||
return observer_->OnDevToolsMessage(browser_, message.data(),
|
||||
message.size());
|
||||
@@ -58,14 +58,14 @@ class CefDevToolsRegistrationImpl : public CefRegistration,
|
||||
|
||||
void OnDevToolsMethodResult(int message_id,
|
||||
bool success,
|
||||
const base::StringPiece& result) override {
|
||||
const std::string_view& result) override {
|
||||
CEF_REQUIRE_UIT();
|
||||
observer_->OnDevToolsMethodResult(browser_, message_id, success,
|
||||
result.data(), result.size());
|
||||
}
|
||||
|
||||
void OnDevToolsEvent(const base::StringPiece& method,
|
||||
const base::StringPiece& params) override {
|
||||
void OnDevToolsEvent(const std::string_view& method,
|
||||
const std::string_view& params) override {
|
||||
CEF_REQUIRE_UIT();
|
||||
observer_->OnDevToolsEvent(browser_, std::string(method), params.data(),
|
||||
params.size());
|
||||
@@ -119,7 +119,7 @@ bool CefDevToolsProtocolManager::SendDevToolsMessage(const void* message,
|
||||
}
|
||||
|
||||
return devtools_controller_->SendDevToolsMessage(
|
||||
base::StringPiece(static_cast<const char*>(message), message_size));
|
||||
std::string_view(static_cast<const char*>(message), message_size));
|
||||
}
|
||||
|
||||
int CefDevToolsProtocolManager::ExecuteDevToolsMethod(
|
||||
|
@@ -11,16 +11,16 @@ namespace devtools_util {
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsValidDictionary(const base::StringPiece& str, bool allow_empty) {
|
||||
bool IsValidDictionary(const std::string_view& str, bool allow_empty) {
|
||||
return str.length() >= (allow_empty ? 2 : 3) && str[0] == '{' &&
|
||||
str[str.length() - 1] == '}';
|
||||
}
|
||||
|
||||
// Example:
|
||||
// {"method":"Target.targetDestroyed","params":{"targetId":"1234..."}}
|
||||
bool ParseEvent(const base::StringPiece& message,
|
||||
base::StringPiece& method,
|
||||
base::StringPiece& params) {
|
||||
bool ParseEvent(const std::string_view& message,
|
||||
std::string_view& method,
|
||||
std::string_view& params) {
|
||||
static const char kMethodStart[] = "{\"method\":\"";
|
||||
static const char kMethodEnd[] = "\"";
|
||||
static const char kParamsStart[] = ",\"params\":";
|
||||
@@ -31,7 +31,7 @@ bool ParseEvent(const base::StringPiece& message,
|
||||
|
||||
const size_t method_start = sizeof(kMethodStart) - 1;
|
||||
const size_t method_end = message.find(kMethodEnd, method_start);
|
||||
if (method_end == base::StringPiece::npos) {
|
||||
if (method_end == std::string_view::npos) {
|
||||
return false;
|
||||
}
|
||||
method = message.substr(method_start, method_end - method_start);
|
||||
@@ -42,9 +42,9 @@ bool ParseEvent(const base::StringPiece& message,
|
||||
size_t remainder_start = method_end + sizeof(kMethodEnd) - 1;
|
||||
if (remainder_start == message.size() - 1) {
|
||||
// No more contents.
|
||||
params = base::StringPiece();
|
||||
params = std::string_view();
|
||||
} else {
|
||||
const base::StringPiece& remainder = message.substr(remainder_start);
|
||||
const std::string_view& remainder = message.substr(remainder_start);
|
||||
if (base::StartsWith(remainder, kParamsStart)) {
|
||||
// Stop immediately before the message closing bracket.
|
||||
remainder_start += sizeof(kParamsStart) - 1;
|
||||
@@ -67,10 +67,10 @@ bool ParseEvent(const base::StringPiece& message,
|
||||
// {"id":3,"result":{}}
|
||||
// {"id":4,"result":{"debuggerId":"-2193881606781505058.81393575456727957"}}
|
||||
// {"id":5,"error":{"code":-32000,"message":"Not supported"}}
|
||||
bool ParseResult(const base::StringPiece& message,
|
||||
bool ParseResult(const std::string_view& message,
|
||||
int& message_id,
|
||||
bool& success,
|
||||
base::StringPiece& result) {
|
||||
std::string_view& result) {
|
||||
static const char kIdStart[] = "{\"id\":";
|
||||
static const char kIdEnd[] = ",";
|
||||
static const char kResultStart[] = "\"result\":";
|
||||
@@ -82,16 +82,16 @@ bool ParseResult(const base::StringPiece& message,
|
||||
|
||||
const size_t id_start = sizeof(kIdStart) - 1;
|
||||
const size_t id_end = message.find(kIdEnd, id_start);
|
||||
if (id_end == base::StringPiece::npos) {
|
||||
if (id_end == std::string_view::npos) {
|
||||
return false;
|
||||
}
|
||||
const base::StringPiece& id_str = message.substr(id_start, id_end - id_start);
|
||||
const std::string_view& id_str = message.substr(id_start, id_end - id_start);
|
||||
if (id_str.empty() || !base::StringToInt(id_str, &message_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t remainder_start = id_end + sizeof(kIdEnd) - 1;
|
||||
const base::StringPiece& remainder = message.substr(remainder_start);
|
||||
const std::string_view& remainder = message.substr(remainder_start);
|
||||
if (base::StartsWith(remainder, kResultStart)) {
|
||||
// Stop immediately before the message closing bracket.
|
||||
remainder_start += sizeof(kResultStart) - 1;
|
||||
@@ -119,11 +119,11 @@ bool ParseResult(const base::StringPiece& message,
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
bool ProtocolParser::IsValidMessage(const base::StringPiece& message) {
|
||||
bool ProtocolParser::IsValidMessage(const std::string_view& message) {
|
||||
return IsValidDictionary(message, /*allow_empty=*/false);
|
||||
}
|
||||
|
||||
bool ProtocolParser::Initialize(const base::StringPiece& message) {
|
||||
bool ProtocolParser::Initialize(const std::string_view& message) {
|
||||
if (status_ != UNINITIALIZED) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include <string_view>
|
||||
|
||||
namespace devtools_util {
|
||||
|
||||
@@ -31,10 +31,10 @@ struct ProtocolParser {
|
||||
ProtocolParser() = default;
|
||||
|
||||
// Checks for a non-empty JSON dictionary.
|
||||
static bool IsValidMessage(const base::StringPiece& message);
|
||||
static bool IsValidMessage(const std::string_view& message);
|
||||
|
||||
// Returns false if already initialized.
|
||||
bool Initialize(const base::StringPiece& message);
|
||||
bool Initialize(const std::string_view& message);
|
||||
|
||||
bool IsInitialized() const { return status_ != UNINITIALIZED; }
|
||||
bool IsEvent() const { return status_ == EVENT; }
|
||||
@@ -45,7 +45,7 @@ struct ProtocolParser {
|
||||
|
||||
// For event messages:
|
||||
// "method" string:
|
||||
base::StringPiece method_;
|
||||
std::string_view method_;
|
||||
|
||||
// For result messages:
|
||||
// "id" int:
|
||||
@@ -55,7 +55,7 @@ struct ProtocolParser {
|
||||
|
||||
// For both:
|
||||
// "params", "result" or "error" dictionary:
|
||||
base::StringPiece params_;
|
||||
std::string_view params_;
|
||||
|
||||
private:
|
||||
enum Status {
|
||||
@@ -69,4 +69,4 @@ struct ProtocolParser {
|
||||
|
||||
} // namespace devtools_util
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_UTIL_H_
|
||||
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_UTIL_H_
|
||||
|
Reference in New Issue
Block a user