mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update to Chromium version 122.0.6261.0 (#1250580)
Frame identifiers have changed from int64_t to string type. This is due to https://crbug.com/1502660 which removes access to frame routing IDs in the renderer process. New cross-process frame identifiers are 160-bit values (32-bit child process ID + 128-bit local frame token) and most easily represented as strings. All other frame-related expectations and behaviors remain the same.
This commit is contained in:
@@ -124,10 +124,10 @@ std::u16string AlloyContentClient::GetLocalizedString(
|
||||
return value;
|
||||
}
|
||||
|
||||
base::StringPiece AlloyContentClient::GetDataResource(
|
||||
std::string_view AlloyContentClient::GetDataResource(
|
||||
int resource_id,
|
||||
ui::ResourceScaleFactor scale_factor) {
|
||||
base::StringPiece value =
|
||||
auto value =
|
||||
ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
|
||||
resource_id, scale_factor);
|
||||
if (value.empty()) {
|
||||
|
@@ -23,7 +23,7 @@ class AlloyContentClient : public content::ContentClient {
|
||||
std::u16string GetLocalizedString(int message_id) override;
|
||||
std::u16string GetLocalizedString(int message_id,
|
||||
const std::u16string& replacement) override;
|
||||
base::StringPiece GetDataResource(
|
||||
std::string_view GetDataResource(
|
||||
int resource_id,
|
||||
ui::ResourceScaleFactor scale_factor) override;
|
||||
base::RefCountedMemory* GetDataResourceBytes(int resource_id) override;
|
||||
|
@@ -428,23 +428,23 @@ std::optional<int> AlloyMainDelegate::BasicStartupComplete() {
|
||||
log_settings.lock_log = logging::DONT_LOCK_LOG_FILE;
|
||||
log_settings.delete_old = logging::APPEND_TO_OLD_LOG_FILE;
|
||||
|
||||
logging::LogSeverity log_severity = logging::LOG_INFO;
|
||||
logging::LogSeverity log_severity = logging::LOGGING_INFO;
|
||||
|
||||
std::string log_severity_str =
|
||||
command_line->GetSwitchValueASCII(switches::kLogSeverity);
|
||||
if (!log_severity_str.empty()) {
|
||||
if (base::EqualsCaseInsensitiveASCII(log_severity_str,
|
||||
switches::kLogSeverity_Verbose)) {
|
||||
log_severity = logging::LOG_VERBOSE;
|
||||
log_severity = logging::LOGGING_VERBOSE;
|
||||
} else if (base::EqualsCaseInsensitiveASCII(
|
||||
log_severity_str, switches::kLogSeverity_Warning)) {
|
||||
log_severity = logging::LOG_WARNING;
|
||||
log_severity = logging::LOGGING_WARNING;
|
||||
} else if (base::EqualsCaseInsensitiveASCII(log_severity_str,
|
||||
switches::kLogSeverity_Error)) {
|
||||
log_severity = logging::LOG_ERROR;
|
||||
log_severity = logging::LOGGING_ERROR;
|
||||
} else if (base::EqualsCaseInsensitiveASCII(log_severity_str,
|
||||
switches::kLogSeverity_Fatal)) {
|
||||
log_severity = logging::LOG_FATAL;
|
||||
log_severity = logging::LOGGING_FATAL;
|
||||
} else if (base::EqualsCaseInsensitiveASCII(
|
||||
log_severity_str, switches::kLogSeverity_Disable)) {
|
||||
log_severity = LOGSEVERITY_DISABLE;
|
||||
@@ -456,7 +456,7 @@ std::optional<int> AlloyMainDelegate::BasicStartupComplete() {
|
||||
// By default, ERROR and FATAL messages will always be output to stderr due
|
||||
// to the kAlwaysPrintErrorLevel value in base/logging.cc. We change the log
|
||||
// level here so that only FATAL messages are output.
|
||||
logging::SetMinLogLevel(logging::LOG_FATAL);
|
||||
logging::SetMinLogLevel(logging::LOGGING_FATAL);
|
||||
} else {
|
||||
log_settings.logging_dest = logging::LOG_TO_ALL;
|
||||
logging::SetMinLogLevel(log_severity);
|
||||
|
@@ -59,7 +59,7 @@ bool CefExtensionsAPIProvider::IsAPISchemaGenerated(const std::string& name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
base::StringPiece CefExtensionsAPIProvider::GetAPISchema(
|
||||
std::string_view CefExtensionsAPIProvider::GetAPISchema(
|
||||
const std::string& name) {
|
||||
// Schema for CEF-only APIs.
|
||||
// TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See
|
||||
@@ -72,7 +72,7 @@ base::StringPiece CefExtensionsAPIProvider::GetAPISchema(
|
||||
return api::cef::ChromeGeneratedSchemas::Get(name);
|
||||
}
|
||||
|
||||
return base::StringPiece();
|
||||
return std::string_view();
|
||||
}
|
||||
|
||||
void CefExtensionsAPIProvider::RegisterPermissions(
|
||||
|
@@ -23,7 +23,7 @@ class CefExtensionsAPIProvider : public ExtensionsAPIProvider {
|
||||
void AddBehaviorFeatures(FeatureProvider* provider) override;
|
||||
void AddAPIJSONSources(JSONFeatureProviderSource* json_source) override;
|
||||
bool IsAPISchemaGenerated(const std::string& name) override;
|
||||
base::StringPiece GetAPISchema(const std::string& name) override;
|
||||
std::string_view GetAPISchema(const std::string& name) override;
|
||||
void RegisterPermissions(PermissionsInfo* permissions_info) override;
|
||||
void RegisterManifestHandlers() override;
|
||||
};
|
||||
|
@@ -6,9 +6,8 @@
|
||||
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "content/public/browser/navigation_handle.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
|
||||
@@ -22,18 +21,59 @@ content::GlobalRenderFrameHostId GetGlobalId(
|
||||
: navigation_handle->GetPreviousRenderFrameHostId();
|
||||
}
|
||||
|
||||
std::string GetFrameDebugString(int64_t frame_id) {
|
||||
uint32_t process_id = frame_id >> 32;
|
||||
uint32_t routing_id = std::numeric_limits<uint32_t>::max() & frame_id;
|
||||
std::optional<content::GlobalRenderFrameHostToken> ParseFrameIdentifier(
|
||||
const std::string& identifier) {
|
||||
if (identifier.size() < 3) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << frame_id << " [" << process_id << "," << routing_id << "]";
|
||||
return ss.str();
|
||||
const size_t pos = identifier.find('-');
|
||||
if (pos == std::string::npos || pos == 0 || pos == identifier.size() - 1) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string_view process_id_str(identifier.c_str(), pos);
|
||||
int process_id;
|
||||
if (!base::HexStringToInt(process_id_str, &process_id) ||
|
||||
!IsValidChildId(process_id)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string_view frame_token_str(identifier.c_str() + pos + 1,
|
||||
identifier.size() - pos - 1);
|
||||
auto token = base::Token::FromString(frame_token_str);
|
||||
if (token) {
|
||||
auto unguessable_token =
|
||||
base::UnguessableToken::Deserialize(token->high(), token->low());
|
||||
if (unguessable_token) {
|
||||
return content::GlobalRenderFrameHostToken(
|
||||
process_id, blink::LocalFrameToken(unguessable_token.value()));
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string MakeFrameIdentifier(
|
||||
const content::GlobalRenderFrameHostToken& global_token) {
|
||||
if (!IsValidGlobalToken(global_token)) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
// All upper-case hex values.
|
||||
return base::StringPrintf("%X-%s", global_token.child_id,
|
||||
global_token.frame_token.ToString().c_str());
|
||||
}
|
||||
|
||||
std::string GetFrameDebugString(
|
||||
const content::GlobalRenderFrameHostId& global_id) {
|
||||
return GetFrameDebugString(MakeFrameId(global_id));
|
||||
return base::StringPrintf("[%d,%d]", global_id.child_id,
|
||||
global_id.frame_routing_id);
|
||||
}
|
||||
|
||||
std::string GetFrameDebugString(
|
||||
const content::GlobalRenderFrameHostToken& global_token) {
|
||||
return MakeFrameIdentifier(global_token);
|
||||
}
|
||||
|
||||
} // namespace frame_util
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#define CEF_LIBCEF_COMMON_FRAME_UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "base/logging.h"
|
||||
@@ -18,17 +19,6 @@ class NavigationHandle;
|
||||
|
||||
namespace frame_util {
|
||||
|
||||
// Create a frame ID in the format exposed by the CEF API.
|
||||
inline int64_t MakeFrameId(int child_id, int frame_routing_id) {
|
||||
return (static_cast<uint64_t>(child_id) << 32) |
|
||||
static_cast<uint64_t>(frame_routing_id);
|
||||
}
|
||||
|
||||
// Create a frame ID in the format exposed by the CEF API.
|
||||
inline int64_t MakeFrameId(const content::GlobalRenderFrameHostId& global_id) {
|
||||
return MakeFrameId(global_id.child_id, global_id.frame_routing_id);
|
||||
}
|
||||
|
||||
// Returns true if |child_id| is valid.
|
||||
inline bool IsValidChildId(int child_id) {
|
||||
// See comments in ChildProcessHostImpl::GenerateChildProcessUniqueId().
|
||||
@@ -57,13 +47,6 @@ inline content::GlobalRenderFrameHostId MakeGlobalId(
|
||||
return content::GlobalRenderFrameHostId(child_id, frame_routing_id);
|
||||
}
|
||||
|
||||
// Create a global ID from a frame ID.
|
||||
inline content::GlobalRenderFrameHostId MakeGlobalId(int64_t frame_id) {
|
||||
uint32_t child_id = frame_id >> 32;
|
||||
uint32_t frame_routing_id = std::numeric_limits<uint32_t>::max() & frame_id;
|
||||
return MakeGlobalId(child_id, frame_routing_id);
|
||||
}
|
||||
|
||||
// Returns an invalid global ID value.
|
||||
inline content::GlobalRenderFrameHostId InvalidGlobalId() {
|
||||
return content::GlobalRenderFrameHostId();
|
||||
@@ -74,10 +57,33 @@ inline content::GlobalRenderFrameHostId InvalidGlobalId() {
|
||||
content::GlobalRenderFrameHostId GetGlobalId(
|
||||
content::NavigationHandle* navigation_handle);
|
||||
|
||||
// Returns a human-readable version of the ID.
|
||||
std::string GetFrameDebugString(int64_t frame_id);
|
||||
// Returns true if |frame_token| is valid.
|
||||
inline bool IsValidFrameToken(const blink::LocalFrameToken& frame_token) {
|
||||
return !frame_token->is_empty();
|
||||
}
|
||||
|
||||
// Returns true if |global_token| is valid.
|
||||
inline bool IsValidGlobalToken(
|
||||
const content::GlobalRenderFrameHostToken& global_token) {
|
||||
return IsValidChildId(global_token.child_id) &&
|
||||
IsValidFrameToken(global_token.frame_token);
|
||||
}
|
||||
|
||||
// Create a global token from a frame identifier. Returns std::nullopt if
|
||||
// |identifier| is invalid.
|
||||
std::optional<content::GlobalRenderFrameHostToken> ParseFrameIdentifier(
|
||||
const std::string& identifier);
|
||||
|
||||
// Return the frame identifier for a global token. Returns empty if
|
||||
// |global_token| is invalid.
|
||||
std::string MakeFrameIdentifier(
|
||||
const content::GlobalRenderFrameHostToken& global_token);
|
||||
|
||||
// Returns a human-readable version of the ID/token.
|
||||
std::string GetFrameDebugString(
|
||||
const content::GlobalRenderFrameHostId& global_id);
|
||||
std::string GetFrameDebugString(
|
||||
const content::GlobalRenderFrameHostToken& global_token);
|
||||
|
||||
} // namespace frame_util
|
||||
|
||||
|
@@ -10,6 +10,7 @@ import "mojo/public/mojom/base/values.mojom";
|
||||
import "services/network/public/mojom/site_for_cookies.mojom";
|
||||
import "services/network/public/mojom/url_request.mojom";
|
||||
import "third_party/blink/public/mojom/loader/referrer.mojom";
|
||||
import "third_party/blink/public/mojom/tokens/tokens.mojom";
|
||||
import "ui/gfx/geometry/mojom/geometry.mojom";
|
||||
import "url/mojom/url.mojom";
|
||||
|
||||
@@ -128,7 +129,8 @@ interface BrowserManager {
|
||||
|
||||
// Retrieve info for a new CefBrowser.
|
||||
[Sync]
|
||||
GetNewBrowserInfo(int32 render_frame_routing_id) => (NewBrowserInfo info);
|
||||
GetNewBrowserInfo(blink.mojom.LocalFrameToken render_frame_token) =>
|
||||
(NewBrowserInfo info);
|
||||
};
|
||||
|
||||
// Interface for communicating with browser management to the render process.
|
||||
|
Reference in New Issue
Block a user