Remove deprecated base::[Dictionary|List]Value API usage
This commit is contained in:
parent
36ee304ed4
commit
4c41f14360
|
@ -264,8 +264,8 @@ void AlloyBrowserContext::LoadExtension(
|
|||
if (manifest && manifest->GetSize() > 0) {
|
||||
CefDictionaryValueImpl* value_impl =
|
||||
static_cast<CefDictionaryValueImpl*>(manifest.get());
|
||||
std::unique_ptr<base::DictionaryValue> value_copy(value_impl->CopyValue());
|
||||
extension_system()->LoadExtension(std::move(*value_copy).TakeDict(),
|
||||
auto value = value_impl->CopyValue();
|
||||
extension_system()->LoadExtension(std::move(value.GetDict()),
|
||||
root_directory, false /* builtin */,
|
||||
loader_context, handler);
|
||||
} else {
|
||||
|
|
|
@ -34,7 +34,7 @@ void CefBrowserFrame::RegisterBrowserInterfaceBindersForFrame(
|
|||
}
|
||||
|
||||
void CefBrowserFrame::SendMessage(const std::string& name,
|
||||
base::Value arguments) {
|
||||
base::Value::List arguments) {
|
||||
// Always send to the newly created RFH, which may be speculative when
|
||||
// navigating cross-origin.
|
||||
if (auto host = GetFrameHost(/*prefer_speculative=*/true)) {
|
||||
|
|
|
@ -35,7 +35,8 @@ class CefBrowserFrame
|
|||
|
||||
private:
|
||||
// cef::mojom::BrowserFrame methods:
|
||||
void SendMessage(const std::string& name, base::Value arguments) override;
|
||||
void SendMessage(const std::string& name,
|
||||
base::Value::List arguments) override;
|
||||
void SendSharedMemoryRegion(const std::string& name,
|
||||
base::ReadOnlySharedMemoryRegion region) override;
|
||||
void FrameAttached(mojo::PendingRemote<cef::mojom::RenderFrame> render_frame,
|
||||
|
|
|
@ -514,8 +514,8 @@ void CefBrowserInfoManager::SendNewBrowserInfoResponse(
|
|||
if (extra_info) {
|
||||
auto extra_info_impl =
|
||||
static_cast<CefDictionaryValueImpl*>(extra_info.get());
|
||||
auto extra_info_value = base::WrapUnique(extra_info_impl->CopyValue());
|
||||
params->extra_info = std::move(*extra_info_value);
|
||||
auto extra_info_value = extra_info_impl->CopyValue();
|
||||
params->extra_info = std::move(extra_info_value.GetDict());
|
||||
}
|
||||
} else {
|
||||
// The new browser info response has timed out.
|
||||
|
|
|
@ -43,7 +43,7 @@ bool CefDevToolsController::SendDevToolsMessage(
|
|||
int CefDevToolsController::ExecuteDevToolsMethod(
|
||||
int suggested_message_id,
|
||||
const std::string& method,
|
||||
const base::DictionaryValue* params) {
|
||||
const base::Value::Dict* params) {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!EnsureAgentHost()) {
|
||||
return 0;
|
||||
|
@ -57,11 +57,11 @@ int CefDevToolsController::ExecuteDevToolsMethod(
|
|||
next_message_id_ = message_id + 1;
|
||||
}
|
||||
|
||||
base::DictionaryValue message;
|
||||
message.SetIntKey("id", message_id);
|
||||
message.SetStringKey("method", method);
|
||||
base::Value::Dict message;
|
||||
message.Set("id", message_id);
|
||||
message.Set("method", method);
|
||||
if (params) {
|
||||
message.SetKey("params", params->Clone());
|
||||
message.Set("params", params->Clone());
|
||||
}
|
||||
|
||||
std::string protocol_message;
|
||||
|
|
|
@ -51,7 +51,7 @@ class CefDevToolsController : public content::DevToolsAgentHostClient {
|
|||
bool SendDevToolsMessage(const base::StringPiece& message);
|
||||
int ExecuteDevToolsMethod(int message_id,
|
||||
const std::string& method,
|
||||
const base::DictionaryValue* params);
|
||||
const base::Value::Dict* params);
|
||||
|
||||
// |observer| must outlive this object or be removed.
|
||||
void AddObserver(Observer* observer);
|
||||
|
|
|
@ -77,10 +77,10 @@ static std::string GetFrontendURL() {
|
|||
scheme::kChromeDevToolsHost);
|
||||
}
|
||||
|
||||
base::DictionaryValue BuildObjectForResponse(const net::HttpResponseHeaders* rh,
|
||||
base::Value::Dict BuildObjectForResponse(const net::HttpResponseHeaders* rh,
|
||||
bool success,
|
||||
int net_error) {
|
||||
base::DictionaryValue response;
|
||||
base::Value::Dict response;
|
||||
int responseCode = 200;
|
||||
if (rh) {
|
||||
responseCode = rh->response_code();
|
||||
|
@ -88,18 +88,18 @@ base::DictionaryValue BuildObjectForResponse(const net::HttpResponseHeaders* rh,
|
|||
// In case of no headers, assume file:// URL and failed to load
|
||||
responseCode = 404;
|
||||
}
|
||||
response.SetInteger("statusCode", responseCode);
|
||||
response.SetInteger("netError", net_error);
|
||||
response.SetString("netErrorName", net::ErrorToString(net_error));
|
||||
response.Set("statusCode", responseCode);
|
||||
response.Set("netError", net_error);
|
||||
response.Set("netErrorName", net::ErrorToString(net_error));
|
||||
|
||||
auto headers = std::make_unique<base::DictionaryValue>();
|
||||
base::Value::Dict headers;
|
||||
size_t iterator = 0;
|
||||
std::string name;
|
||||
std::string value;
|
||||
// TODO(caseq): this probably needs to handle duplicate header names
|
||||
// correctly by folding them.
|
||||
while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value)) {
|
||||
headers->SetString(name, value);
|
||||
headers.Set(name, value);
|
||||
}
|
||||
|
||||
response.Set("headers", std::move(headers));
|
||||
|
@ -222,7 +222,7 @@ class CefDevToolsFrontend::NetworkResourceLoader
|
|||
void OnComplete(bool success) override {
|
||||
auto response = BuildObjectForResponse(response_headers_.get(), success,
|
||||
loader_->NetError());
|
||||
bindings_->SendMessageAck(request_id_, std::move(response));
|
||||
bindings_->SendMessageAck(request_id_, base::Value(std::move(response)));
|
||||
|
||||
bindings_->loaders_.erase(bindings_->loaders_.find(this));
|
||||
}
|
||||
|
@ -473,9 +473,9 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
|||
std::make_unique<network::WrapperPendingSharedURLLoaderFactory>(
|
||||
std::move(pending_remote)));
|
||||
} else if (content::HasWebUIScheme(gurl)) {
|
||||
base::DictionaryValue response;
|
||||
response.SetInteger("statusCode", 403);
|
||||
SendMessageAck(request_id, std::move(response));
|
||||
base::Value::Dict response;
|
||||
response.Set("statusCode", 403);
|
||||
SendMessageAck(request_id, base::Value(std::move(response)));
|
||||
return;
|
||||
} else {
|
||||
auto* partition =
|
||||
|
|
|
@ -176,8 +176,8 @@ int CefDevToolsManager::ExecuteDevToolsMethod(
|
|||
CefDictionaryValueImpl* impl =
|
||||
static_cast<CefDictionaryValueImpl*>(params.get());
|
||||
CefValueController::AutoLock lock_scope(impl->controller());
|
||||
return devtools_controller_->ExecuteDevToolsMethod(message_id, method,
|
||||
impl->GetValueUnsafe());
|
||||
return devtools_controller_->ExecuteDevToolsMethod(
|
||||
message_id, method, impl->GetValueUnsafe()->GetIfDict());
|
||||
} else {
|
||||
return devtools_controller_->ExecuteDevToolsMethod(message_id, method,
|
||||
nullptr);
|
||||
|
|
|
@ -15,11 +15,9 @@ CefExtensionImpl::CefExtensionImpl(const extensions::Extension* extension,
|
|||
CefRefPtr<CefExtensionHandler> handler)
|
||||
: id_(extension->id()),
|
||||
path_(extension->path().value()),
|
||||
manifest_(new CefDictionaryValueImpl(
|
||||
static_cast<base::DictionaryValue*>(
|
||||
new base::Value(extension->manifest()->value()->Clone())),
|
||||
true,
|
||||
true)),
|
||||
manifest_(
|
||||
new CefDictionaryValueImpl(extension->manifest()->value()->Clone(),
|
||||
/*read_only=*/true)),
|
||||
loader_context_(loader_context),
|
||||
handler_(handler) {}
|
||||
|
||||
|
|
|
@ -275,11 +275,10 @@ void CefFrameHostImpl::SendProcessMessage(
|
|||
// Invalidate the message object immediately by taking the argument list.
|
||||
auto argument_list =
|
||||
static_cast<CefProcessMessageImpl*>(message.get())->TakeArgumentList();
|
||||
|
||||
SendToRenderFrame(
|
||||
__FUNCTION__,
|
||||
base::BindOnce(
|
||||
[](const CefString& name, base::ListValue argument_list,
|
||||
[](const CefString& name, base::Value::List argument_list,
|
||||
const RenderFrameType& render_frame) {
|
||||
render_frame->SendMessage(name, std::move(argument_list));
|
||||
},
|
||||
|
@ -631,12 +630,11 @@ void CefFrameHostImpl::OnRenderFrameDisconnect() {
|
|||
}
|
||||
|
||||
void CefFrameHostImpl::SendMessage(const std::string& name,
|
||||
base::Value arguments) {
|
||||
base::Value::List arguments) {
|
||||
if (auto browser = GetBrowserHostBase()) {
|
||||
if (auto client = browser->GetClient()) {
|
||||
auto& list_value = base::Value::AsListValue(arguments);
|
||||
CefRefPtr<CefProcessMessageImpl> message(new CefProcessMessageImpl(
|
||||
name, std::move(const_cast<base::ListValue&>(list_value)),
|
||||
CefRefPtr<CefProcessMessageImpl> message(
|
||||
new CefProcessMessageImpl(name, std::move(arguments),
|
||||
/*read_only=*/true));
|
||||
browser->GetClient()->OnProcessMessageReceived(
|
||||
browser.get(), this, PID_RENDERER, message.get());
|
||||
|
|
|
@ -135,7 +135,8 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
|||
content::RenderFrameHost* render_frame_host);
|
||||
|
||||
// cef::mojom::BrowserFrame methods forwarded from CefBrowserFrame.
|
||||
void SendMessage(const std::string& name, base::Value arguments) override;
|
||||
void SendMessage(const std::string& name,
|
||||
base::Value::List arguments) override;
|
||||
void SendSharedMemoryRegion(const std::string& name,
|
||||
base::ReadOnlySharedMemoryRegion region) override;
|
||||
void FrameAttached(mojo::PendingRemote<cef::mojom::RenderFrame> render_frame,
|
||||
|
|
|
@ -51,21 +51,18 @@ CefRefPtr<CefValue> GetPreference(PrefService* pref_service,
|
|||
if (!pref) {
|
||||
return nullptr;
|
||||
}
|
||||
return new CefValueImpl(new base::Value(pref->GetValue()->Clone()));
|
||||
return new CefValueImpl(pref->GetValue()->Clone());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDictionaryValue> GetAllPreferences(PrefService* pref_service,
|
||||
bool include_defaults) {
|
||||
// Returns a DeepCopy of the value.
|
||||
base::Value values = pref_service->GetPreferenceValues(
|
||||
include_defaults ? PrefService::INCLUDE_DEFAULTS
|
||||
: PrefService::EXCLUDE_DEFAULTS);
|
||||
|
||||
// CefDictionaryValueImpl takes ownership of |values|.
|
||||
return new CefDictionaryValueImpl(
|
||||
base::DictionaryValue::From(
|
||||
base::Value::ToUniquePtrValue(std::move(values)))
|
||||
.release(),
|
||||
true, false);
|
||||
// CefDictionaryValueImpl takes ownership of |values| contents.
|
||||
return new CefDictionaryValueImpl(std::move(values), /*read_only=*/false);
|
||||
}
|
||||
|
||||
bool CanSetPreference(PrefService* pref_service, const CefString& name) {
|
||||
|
|
|
@ -67,15 +67,12 @@ class CefPreferenceRegistrarImpl : public CefPreferenceRegistrar {
|
|||
void RegisterComplexPref(const std::string& name,
|
||||
CefRefPtr<CefValue> default_value) {
|
||||
CefValueImpl* impl = static_cast<CefValueImpl*>(default_value.get());
|
||||
auto impl_value = impl->CopyValue();
|
||||
|
||||
CefValueImpl::ScopedLockedValue scoped_locked_value(impl);
|
||||
base::Value* impl_value = impl->GetValueUnsafe();
|
||||
|
||||
// Will make a deep copy of |impl_value|.
|
||||
if (impl_value->type() == base::Value::Type::DICT) {
|
||||
registry_->RegisterDictionaryPref(name, impl_value->Clone());
|
||||
} else if (impl_value->type() == base::Value::Type::LIST) {
|
||||
registry_->RegisterListPref(name, impl_value->Clone());
|
||||
if (impl_value.type() == base::Value::Type::DICT) {
|
||||
registry_->RegisterDictionaryPref(name, std::move(impl_value));
|
||||
} else if (impl_value.type() == base::Value::Type::LIST) {
|
||||
registry_->RegisterListPref(name, std::move(impl_value));
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
|
|
@ -191,11 +191,11 @@ void CefBrowserViewImpl::Detach() {
|
|||
}
|
||||
}
|
||||
|
||||
void CefBrowserViewImpl::GetDebugInfo(base::DictionaryValue* info,
|
||||
void CefBrowserViewImpl::GetDebugInfo(base::Value::Dict* info,
|
||||
bool include_children) {
|
||||
ParentClass::GetDebugInfo(info, include_children);
|
||||
if (browser_) {
|
||||
info->SetString("url", browser_->GetMainFrame()->GetURL().ToString());
|
||||
info->Set("url", browser_->GetMainFrame()->GetURL().ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,7 @@ class CefBrowserViewImpl
|
|||
// CefViewAdapter methods:
|
||||
void Detach() override;
|
||||
std::string GetDebugType() override { return "BrowserView"; }
|
||||
void GetDebugInfo(base::DictionaryValue* info,
|
||||
bool include_children) override;
|
||||
void GetDebugInfo(base::Value::Dict* info, bool include_children) override;
|
||||
|
||||
// CefBrowserViewView::Delegate methods:
|
||||
void OnBrowserViewAdded() override;
|
||||
|
|
|
@ -48,10 +48,9 @@ CEF_LABEL_BUTTON_IMPL_T class CefLabelButtonImpl : public CEF_BUTTON_IMPL_D {
|
|||
CefRefPtr<CefLabelButton> AsLabelButton() override { return this; }
|
||||
|
||||
// CefViewAdapter methods:
|
||||
void GetDebugInfo(base::DictionaryValue* info,
|
||||
bool include_children) override {
|
||||
void GetDebugInfo(base::Value::Dict* info, bool include_children) override {
|
||||
ParentClass::GetDebugInfo(info, include_children);
|
||||
info->SetString("text", ParentClass::root_view()->GetText());
|
||||
info->Set("text", ParentClass::root_view()->GetText());
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -49,21 +49,20 @@ CEF_PANEL_IMPL_T class CefPanelImpl : public CEF_VIEW_IMPL_D {
|
|||
CefRefPtr<CefPanel> AsPanel() override { return this; }
|
||||
|
||||
// CefViewAdapter methods:
|
||||
void GetDebugInfo(base::DictionaryValue* info,
|
||||
bool include_children) override {
|
||||
void GetDebugInfo(base::Value::Dict* info, bool include_children) override {
|
||||
ParentClass::GetDebugInfo(info, include_children);
|
||||
if (include_children) {
|
||||
const size_t count = ParentClass::content_view()->children().size();
|
||||
if (count > 0U) {
|
||||
std::unique_ptr<base::ListValue> children(new base::ListValue());
|
||||
base::Value::List children;
|
||||
|
||||
for (size_t i = 0U; i < count; ++i) {
|
||||
views::View* view = ParentClass::content_view()->children()[i];
|
||||
CefViewAdapter* adapter = CefViewAdapter::GetFor(view);
|
||||
if (adapter) {
|
||||
base::DictionaryValue child_info;
|
||||
base::Value::Dict child_info;
|
||||
adapter->GetDebugInfo(&child_info, include_children);
|
||||
children->Append(std::move(child_info));
|
||||
children.Append(std::move(child_info));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,16 +64,15 @@ int CefScrollViewImpl::GetVerticalScrollbarWidth() {
|
|||
return root_view()->GetScrollBarLayoutWidth();
|
||||
}
|
||||
|
||||
void CefScrollViewImpl::GetDebugInfo(base::DictionaryValue* info,
|
||||
void CefScrollViewImpl::GetDebugInfo(base::Value::Dict* info,
|
||||
bool include_children) {
|
||||
ParentClass::GetDebugInfo(info, include_children);
|
||||
if (include_children) {
|
||||
views::View* view = root_view()->contents();
|
||||
CefViewAdapter* adapter = CefViewAdapter::GetFor(view);
|
||||
if (adapter) {
|
||||
std::unique_ptr<base::DictionaryValue> child_info(
|
||||
new base::DictionaryValue());
|
||||
adapter->GetDebugInfo(child_info.get(), include_children);
|
||||
base::Value::Dict child_info;
|
||||
adapter->GetDebugInfo(&child_info, include_children);
|
||||
info->Set("content_view", std::move(child_info));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,7 @@ class CefScrollViewImpl
|
|||
|
||||
// CefViewAdapter methods:
|
||||
std::string GetDebugType() override { return "ScrollView"; }
|
||||
void GetDebugInfo(base::DictionaryValue* info,
|
||||
bool include_children) override;
|
||||
void GetDebugInfo(base::Value::Dict* info, bool include_children) override;
|
||||
|
||||
private:
|
||||
// Create a new implementation object.
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
|
||||
#include "include/views/cef_view.h"
|
||||
|
||||
namespace base {
|
||||
class DictionaryValue;
|
||||
}
|
||||
#include "base/values.h"
|
||||
|
||||
namespace views {
|
||||
class View;
|
||||
|
@ -48,8 +46,7 @@ class CefViewAdapter {
|
|||
virtual std::string GetDebugType() = 0;
|
||||
|
||||
// Override this method to provide debug info specific to the View type.
|
||||
virtual void GetDebugInfo(base::DictionaryValue* info,
|
||||
bool include_children) = 0;
|
||||
virtual void GetDebugInfo(base::Value::Dict* info, bool include_children) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~CefViewAdapter() {}
|
||||
|
|
|
@ -343,19 +343,17 @@ CEF_VIEW_IMPL_T class CefViewImpl : public CefViewAdapter, public CefViewClass {
|
|||
}
|
||||
root_view_ref_ = nullptr;
|
||||
}
|
||||
void GetDebugInfo(base::DictionaryValue* info,
|
||||
bool include_children) override {
|
||||
info->SetString("type", GetDebugType());
|
||||
info->SetInteger("id", root_view()->GetID());
|
||||
void GetDebugInfo(base::Value::Dict* info, bool include_children) override {
|
||||
info->Set("type", GetDebugType());
|
||||
info->Set("id", root_view()->GetID());
|
||||
|
||||
// Use GetBounds() because some subclasses (like CefWindowImpl) override it.
|
||||
const CefRect& bounds = GetBounds();
|
||||
std::unique_ptr<base::DictionaryValue> bounds_value(
|
||||
new base::DictionaryValue());
|
||||
bounds_value->SetInteger("x", bounds.x);
|
||||
bounds_value->SetInteger("y", bounds.y);
|
||||
bounds_value->SetInteger("width", bounds.width);
|
||||
bounds_value->SetInteger("height", bounds.height);
|
||||
base::Value::Dict bounds_value;
|
||||
bounds_value.Set("x", bounds.x);
|
||||
bounds_value.Set("y", bounds.y);
|
||||
bounds_value.Set("width", bounds.width);
|
||||
bounds_value.Set("height", bounds.height);
|
||||
info->Set("bounds", std::move(bounds_value));
|
||||
}
|
||||
|
||||
|
@ -454,15 +452,15 @@ CEF_VIEW_IMPL_T CefString CEF_VIEW_IMPL_D::GetTypeString() {
|
|||
|
||||
CEF_VIEW_IMPL_T CefString CEF_VIEW_IMPL_D::ToString(bool include_children) {
|
||||
CEF_REQUIRE_UIT_RETURN(CefString());
|
||||
std::unique_ptr<base::DictionaryValue> info(new base::DictionaryValue());
|
||||
base::Value::Dict info;
|
||||
if (IsValid()) {
|
||||
GetDebugInfo(info.get(), include_children);
|
||||
GetDebugInfo(&info, include_children);
|
||||
} else {
|
||||
info->SetString("type", GetDebugType());
|
||||
info.Set("type", GetDebugType());
|
||||
}
|
||||
|
||||
std::string json_string;
|
||||
base::JSONWriter::WriteWithOptions(*info, 0, &json_string);
|
||||
base::JSONWriter::WriteWithOptions(info, 0, &json_string);
|
||||
return json_string;
|
||||
}
|
||||
|
||||
|
|
|
@ -315,11 +315,11 @@ CefRefPtr<CefOverlayController> CefWindowImpl::AddOverlayView(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void CefWindowImpl::GetDebugInfo(base::DictionaryValue* info,
|
||||
void CefWindowImpl::GetDebugInfo(base::Value::Dict* info,
|
||||
bool include_children) {
|
||||
ParentClass::GetDebugInfo(info, include_children);
|
||||
if (root_view()) {
|
||||
info->SetString("title", root_view()->title());
|
||||
info->Set("title", root_view()->title());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,8 +113,7 @@ class CefWindowImpl
|
|||
|
||||
// CefViewAdapter methods:
|
||||
std::string GetDebugType() override { return "Window"; }
|
||||
void GetDebugInfo(base::DictionaryValue* info,
|
||||
bool include_children) override;
|
||||
void GetDebugInfo(base::Value::Dict* info, bool include_children) override;
|
||||
|
||||
// ui::AcceleratorTarget methods:
|
||||
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
|
||||
|
|
|
@ -51,9 +51,7 @@ CefRefPtr<CefValue> CefParseJSON(const void* json,
|
|||
base::StringPiece(static_cast<const char*>(json), json_size),
|
||||
GetJSONReaderOptions(options));
|
||||
if (parse_result) {
|
||||
return new CefValueImpl(
|
||||
base::Value::ToUniquePtrValue(std::move(parse_result.value()))
|
||||
.release());
|
||||
return new CefValueImpl(std::move(parse_result.value()));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -68,8 +66,7 @@ CefRefPtr<CefValue> CefParseJSONAndReturnError(
|
|||
auto result = base::JSONReader::ReadAndReturnValueWithError(
|
||||
json, GetJSONReaderOptions(options));
|
||||
if (result.has_value()) {
|
||||
return new CefValueImpl(
|
||||
base::Value::ToUniquePtrValue(std::move(*result)).release());
|
||||
return new CefValueImpl(std::move(*result));
|
||||
}
|
||||
|
||||
error_msg_out = result.error().message;
|
||||
|
|
|
@ -56,7 +56,7 @@ interface RenderFrame {
|
|||
FrameDetached();
|
||||
|
||||
// Send a message to the render process.
|
||||
SendMessage(string name, mojo_base.mojom.Value arguments);
|
||||
SendMessage(string name, mojo_base.mojom.ListValue arguments);
|
||||
|
||||
// Send a shared memory region to the render process.
|
||||
SendSharedMemoryRegion(string name, mojo_base.mojom.ReadOnlySharedMemoryRegion region);
|
||||
|
@ -88,7 +88,7 @@ interface RenderFrame {
|
|||
// Interface for communicating with a frame in the browser process.
|
||||
interface BrowserFrame {
|
||||
// Send a message to the browser process.
|
||||
SendMessage(string name, mojo_base.mojom.Value arguments);
|
||||
SendMessage(string name, mojo_base.mojom.ListValue arguments);
|
||||
|
||||
// Send a shared memory region to the browser process.
|
||||
SendSharedMemoryRegion(string name, mojo_base.mojom.ReadOnlySharedMemoryRegion region);
|
||||
|
@ -117,7 +117,7 @@ struct NewBrowserInfo {
|
|||
bool is_popup;
|
||||
bool is_windowless;
|
||||
bool is_guest_view;
|
||||
mojo_base.mojom.Value? extra_info;
|
||||
mojo_base.mojom.DictionaryValue? extra_info;
|
||||
};
|
||||
|
||||
// Interface for communicating with browser management in the browser process.
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "libcef/common/values_impl.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
|
||||
// static
|
||||
CefRefPtr<CefProcessMessage> CefProcessMessage::Create(const CefString& name) {
|
||||
|
@ -24,25 +23,22 @@ CefProcessMessageImpl::CefProcessMessageImpl(const CefString& name,
|
|||
}
|
||||
|
||||
CefProcessMessageImpl::CefProcessMessageImpl(const CefString& name,
|
||||
base::ListValue arguments,
|
||||
base::Value::List arguments,
|
||||
bool read_only)
|
||||
: name_(name) {
|
||||
DCHECK(!name_.empty());
|
||||
|
||||
auto new_obj = std::make_unique<base::ListValue>();
|
||||
*new_obj = std::move(arguments);
|
||||
arguments_ =
|
||||
new CefListValueImpl(new_obj.release(), /*will_delete=*/true, read_only);
|
||||
arguments_ = new CefListValueImpl(std::move(arguments), read_only);
|
||||
}
|
||||
|
||||
CefProcessMessageImpl::~CefProcessMessageImpl() = default;
|
||||
|
||||
base::ListValue CefProcessMessageImpl::TakeArgumentList() {
|
||||
base::Value::List CefProcessMessageImpl::TakeArgumentList() {
|
||||
DCHECK(IsValid());
|
||||
CefListValueImpl* value_impl =
|
||||
static_cast<CefListValueImpl*>(arguments_.get());
|
||||
auto value = base::WrapUnique(value_impl->CopyOrDetachValue(nullptr));
|
||||
return std::move(*value);
|
||||
auto value = value_impl->CopyOrDetachValue(nullptr);
|
||||
return std::move(value->GetList());
|
||||
}
|
||||
|
||||
bool CefProcessMessageImpl::IsValid() {
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
|
||||
#include "include/cef_process_message.h"
|
||||
|
||||
namespace base {
|
||||
class ListValue;
|
||||
}
|
||||
#include "base/values.h"
|
||||
|
||||
// CefProcessMessage implementation.
|
||||
class CefProcessMessageImpl : public CefProcessMessage {
|
||||
|
@ -22,7 +20,7 @@ class CefProcessMessageImpl : public CefProcessMessage {
|
|||
// Constructor for creating a new CefListValue that takes ownership of
|
||||
// |arguments|.
|
||||
CefProcessMessageImpl(const CefString& name,
|
||||
base::ListValue arguments,
|
||||
base::Value::List arguments,
|
||||
bool read_only);
|
||||
|
||||
CefProcessMessageImpl(const CefProcessMessageImpl&) = delete;
|
||||
|
@ -34,7 +32,7 @@ class CefProcessMessageImpl : public CefProcessMessage {
|
|||
// a copy if the argument list is already owned by something else.
|
||||
// TODO: Pass by reference instead of ownership if/when Mojo adds support
|
||||
// for that.
|
||||
[[nodiscard]] base::ListValue TakeArgumentList();
|
||||
[[nodiscard]] base::Value::List TakeArgumentList();
|
||||
|
||||
// CefProcessMessage methods.
|
||||
bool IsValid() override;
|
||||
|
|
|
@ -297,10 +297,10 @@ class CefValueBase : public CefType, public CefValueController::Object {
|
|||
inline bool read_only() const { return read_only_; }
|
||||
|
||||
// True if the underlying value has been detached.
|
||||
inline bool detached() { return !controller_.get(); }
|
||||
inline bool detached() const { return !controller_.get(); }
|
||||
|
||||
// Returns the controller.
|
||||
inline CefValueController* controller() { return controller_.get(); }
|
||||
inline CefValueController* controller() const { return controller_.get(); }
|
||||
|
||||
// Deletes the underlying value.
|
||||
void Delete() {
|
||||
|
@ -346,7 +346,7 @@ class CefValueBase : public CefType, public CefValueController::Object {
|
|||
}
|
||||
|
||||
// Verify that the value is attached.
|
||||
inline bool VerifyAttached() {
|
||||
inline bool VerifyAttached() const {
|
||||
if (detached()) {
|
||||
// This object should not be accessed after being detached.
|
||||
NOTREACHED() << "object accessed after being detached.";
|
||||
|
@ -371,21 +371,27 @@ class CefValueBase : public CefType, public CefValueController::Object {
|
|||
virtual void DeleteValue(ValueType* value) { delete value; }
|
||||
|
||||
// Returns a mutable reference to the value.
|
||||
inline ValueType* mutable_value() {
|
||||
inline ValueType* mutable_value() const {
|
||||
DCHECK(value_);
|
||||
DCHECK(!read_only_);
|
||||
DCHECK(controller()->locked());
|
||||
return value_;
|
||||
}
|
||||
|
||||
// Returns a const reference to the value.
|
||||
inline const ValueType& const_value() {
|
||||
inline const ValueType& const_value() const {
|
||||
DCHECK(value_);
|
||||
DCHECK(controller()->locked());
|
||||
return *value_;
|
||||
}
|
||||
|
||||
// Returns an mutable reference to the value without checking read-only state.
|
||||
inline ValueType* mutable_value_unchecked() const {
|
||||
return const_cast<ValueType*>(&const_value());
|
||||
}
|
||||
|
||||
// Verify that the value can be accessed.
|
||||
inline bool VerifyAccess(bool modify) {
|
||||
inline bool VerifyAccess(bool modify) const {
|
||||
// The controller must already be locked.
|
||||
DCHECK(controller()->locked());
|
||||
|
||||
|
|
|
@ -36,7 +36,8 @@ void RemoveEmptyValueDicts(base::Value::Dict& dict) {
|
|||
|
||||
// static
|
||||
CefRefPtr<CefValue> CefValue::Create() {
|
||||
return new CefValueImpl(new base::Value());
|
||||
// Start with VTYPE_NULL instead of VTYPE_INVALID for backwards compatibility.
|
||||
return new CefValueImpl(base::Value());
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -53,25 +54,22 @@ CefRefPtr<CefValue> CefValueImpl::GetOrCreateRefOrCopy(
|
|||
}
|
||||
|
||||
if (value->is_dict()) {
|
||||
base::DictionaryValue* dict_value =
|
||||
static_cast<base::DictionaryValue*>(value);
|
||||
return new CefValueImpl(CefDictionaryValueImpl::GetOrCreateRef(
|
||||
dict_value, parent_value, read_only, controller));
|
||||
value, parent_value, read_only, controller));
|
||||
}
|
||||
|
||||
if (value->is_list()) {
|
||||
base::ListValue* list_value = static_cast<base::ListValue*>(value);
|
||||
return new CefValueImpl(CefListValueImpl::GetOrCreateRef(
|
||||
list_value, parent_value, read_only, controller));
|
||||
value, parent_value, read_only, controller));
|
||||
}
|
||||
|
||||
return new CefValueImpl(new base::Value(value->Clone()));
|
||||
return new CefValueImpl(value->Clone());
|
||||
}
|
||||
|
||||
CefValueImpl::CefValueImpl() {}
|
||||
|
||||
CefValueImpl::CefValueImpl(base::Value* value) {
|
||||
SetValue(value);
|
||||
CefValueImpl::CefValueImpl(base::Value value) {
|
||||
SetValue(std::move(value));
|
||||
}
|
||||
|
||||
CefValueImpl::CefValueImpl(CefRefPtr<CefBinaryValue> value)
|
||||
|
@ -85,12 +83,31 @@ CefValueImpl::CefValueImpl(CefRefPtr<CefListValue> value)
|
|||
|
||||
CefValueImpl::~CefValueImpl() {}
|
||||
|
||||
void CefValueImpl::SetValue(base::Value* value) {
|
||||
void CefValueImpl::SetValue(base::Value value) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
SetValueInternal(value);
|
||||
SetValueInternal(absl::make_optional(std::move(value)));
|
||||
}
|
||||
|
||||
base::Value* CefValueImpl::CopyOrDetachValue(
|
||||
base::Value CefValueImpl::CopyValue() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
if (binary_value_) {
|
||||
return static_cast<CefBinaryValueImpl*>(binary_value_.get())->CopyValue();
|
||||
}
|
||||
|
||||
if (dictionary_value_) {
|
||||
return static_cast<CefDictionaryValueImpl*>(dictionary_value_.get())
|
||||
->CopyValue();
|
||||
}
|
||||
|
||||
if (list_value_) {
|
||||
return static_cast<CefListValueImpl*>(list_value_.get())->CopyValue();
|
||||
}
|
||||
|
||||
return value_->Clone();
|
||||
}
|
||||
|
||||
std::unique_ptr<base::Value> CefValueImpl::CopyOrDetachValue(
|
||||
CefValueController* new_controller) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
|
@ -109,7 +126,7 @@ base::Value* CefValueImpl::CopyOrDetachValue(
|
|||
->CopyOrDetachValue(new_controller);
|
||||
}
|
||||
|
||||
return new base::Value(value_->Clone());
|
||||
return std::make_unique<base::Value>(value_->Clone());
|
||||
}
|
||||
|
||||
void CefValueImpl::SwapValue(base::Value* new_value,
|
||||
|
@ -122,12 +139,10 @@ void CefValueImpl::SwapValue(base::Value* new_value,
|
|||
new_value, new_parent_value, new_controller);
|
||||
} else if (dictionary_value_) {
|
||||
dictionary_value_ = CefDictionaryValueImpl::GetOrCreateRef(
|
||||
static_cast<base::DictionaryValue*>(new_value), new_parent_value, false,
|
||||
new_controller);
|
||||
new_value, new_parent_value, false, new_controller);
|
||||
} else if (list_value_) {
|
||||
list_value_ = CefListValueImpl::GetOrCreateRef(
|
||||
static_cast<base::ListValue*>(new_value), new_parent_value, false,
|
||||
new_controller);
|
||||
list_value_ = CefListValueImpl::GetOrCreateRef(new_value, new_parent_value,
|
||||
false, new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,7 +264,7 @@ CefRefPtr<CefValue> CefValueImpl::Copy() {
|
|||
return new CefValueImpl(list_value_->Copy());
|
||||
}
|
||||
if (value_) {
|
||||
return new CefValueImpl(new base::Value(value_->Clone()));
|
||||
return new CefValueImpl(value_->Clone());
|
||||
}
|
||||
|
||||
return new CefValueImpl();
|
||||
|
@ -345,52 +360,52 @@ CefRefPtr<CefListValue> CefValueImpl::GetList() {
|
|||
}
|
||||
|
||||
bool CefValueImpl::SetNull() {
|
||||
SetValue(new base::Value());
|
||||
SetValue(base::Value());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefValueImpl::SetBool(bool value) {
|
||||
SetValue(new base::Value(value));
|
||||
SetValue(base::Value(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefValueImpl::SetInt(int value) {
|
||||
SetValue(new base::Value(value));
|
||||
SetValue(base::Value(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefValueImpl::SetDouble(double value) {
|
||||
SetValue(new base::Value(value));
|
||||
SetValue(base::Value(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefValueImpl::SetString(const CefString& value) {
|
||||
SetValue(new base::Value(value.ToString()));
|
||||
SetValue(base::Value(value.ToString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefValueImpl::SetBinary(CefRefPtr<CefBinaryValue> value) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
SetValueInternal(nullptr);
|
||||
SetValueInternal(absl::nullopt);
|
||||
binary_value_ = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefValueImpl::SetDictionary(CefRefPtr<CefDictionaryValue> value) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
SetValueInternal(nullptr);
|
||||
SetValueInternal(absl::nullopt);
|
||||
dictionary_value_ = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefValueImpl::SetList(CefRefPtr<CefListValue> value) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
SetValueInternal(nullptr);
|
||||
SetValueInternal(absl::nullopt);
|
||||
list_value_ = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefValueImpl::SetValueInternal(base::Value* value) {
|
||||
void CefValueImpl::SetValueInternal(absl::optional<base::Value> value) {
|
||||
lock_.AssertAcquired();
|
||||
|
||||
value_.reset(nullptr);
|
||||
|
@ -399,20 +414,21 @@ void CefValueImpl::SetValueInternal(base::Value* value) {
|
|||
list_value_ = nullptr;
|
||||
|
||||
if (value) {
|
||||
switch (value->type()) {
|
||||
switch ((*value).type()) {
|
||||
case base::Value::Type::BINARY:
|
||||
binary_value_ = new CefBinaryValueImpl(value, true);
|
||||
return;
|
||||
binary_value_ = new CefBinaryValueImpl(std::move(*value));
|
||||
break;
|
||||
case base::Value::Type::DICTIONARY:
|
||||
dictionary_value_ = new CefDictionaryValueImpl(
|
||||
static_cast<base::DictionaryValue*>(value), true, false);
|
||||
return;
|
||||
dictionary_value_ =
|
||||
new CefDictionaryValueImpl(std::move(*value), /*read_only=*/false);
|
||||
break;
|
||||
case base::Value::Type::LIST:
|
||||
list_value_ = new CefListValueImpl(static_cast<base::ListValue*>(value),
|
||||
true, false);
|
||||
return;
|
||||
list_value_ =
|
||||
new CefListValueImpl(std::move(*value), /*read_only=*/false);
|
||||
break;
|
||||
default:
|
||||
value_.reset(value);
|
||||
value_ = std::make_unique<base::Value>(std::move(*value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -499,41 +515,39 @@ CefRefPtr<CefBinaryValue> CefBinaryValueImpl::GetOrCreateRef(
|
|||
CefBinaryValueImpl::kReference, controller);
|
||||
}
|
||||
|
||||
CefBinaryValueImpl::CefBinaryValueImpl(base::Value value)
|
||||
: CefBinaryValueImpl(new base::Value(std::move(value)),
|
||||
/*will_delete=*/true) {}
|
||||
|
||||
CefBinaryValueImpl::CefBinaryValueImpl(base::Value* value, bool will_delete)
|
||||
: CefValueBase<CefBinaryValue, base::Value>(
|
||||
value,
|
||||
: CefBinaryValueImpl(value,
|
||||
nullptr,
|
||||
will_delete ? kOwnerWillDelete : kOwnerNoDelete,
|
||||
true,
|
||||
nullptr) {}
|
||||
|
||||
CefBinaryValueImpl::CefBinaryValueImpl(char* data, size_t data_size)
|
||||
: CefValueBase<CefBinaryValue, base::Value>(
|
||||
: CefBinaryValueImpl(
|
||||
new base::Value(std::vector<char>(data, data + data_size)),
|
||||
nullptr,
|
||||
kOwnerWillDelete,
|
||||
true,
|
||||
nullptr) {}
|
||||
|
||||
base::Value* CefBinaryValueImpl::CopyValue() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
return new base::Value(const_value().Clone());
|
||||
base::Value CefBinaryValueImpl::CopyValue() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, base::Value());
|
||||
return const_value().Clone();
|
||||
}
|
||||
|
||||
base::Value* CefBinaryValueImpl::CopyOrDetachValue(
|
||||
std::unique_ptr<base::Value> CefBinaryValueImpl::CopyOrDetachValue(
|
||||
CefValueController* new_controller) {
|
||||
base::Value* new_value;
|
||||
|
||||
if (!will_delete()) {
|
||||
// Copy the value.
|
||||
new_value = CopyValue();
|
||||
} else {
|
||||
// Take ownership of the value.
|
||||
new_value = Detach(new_controller);
|
||||
return std::make_unique<base::Value>(CopyValue());
|
||||
}
|
||||
|
||||
DCHECK(new_value);
|
||||
return new_value;
|
||||
// Take ownership of the value.
|
||||
auto value = base::WrapUnique(Detach(new_controller));
|
||||
DCHECK(value.get());
|
||||
return value;
|
||||
}
|
||||
|
||||
bool CefBinaryValueImpl::IsSameValue(const base::Value* that) {
|
||||
|
@ -546,12 +560,12 @@ bool CefBinaryValueImpl::IsEqualValue(const base::Value* that) {
|
|||
return const_value() == *that;
|
||||
}
|
||||
|
||||
base::Value* CefBinaryValueImpl::GetValueUnsafe() {
|
||||
base::Value* CefBinaryValueImpl::GetValueUnsafe() const {
|
||||
if (!VerifyAttached()) {
|
||||
return nullptr;
|
||||
}
|
||||
controller()->AssertLockAcquired();
|
||||
return const_cast<base::Value*>(&const_value());
|
||||
return mutable_value_unchecked();
|
||||
}
|
||||
|
||||
bool CefBinaryValueImpl::IsValid() {
|
||||
|
@ -590,8 +604,7 @@ bool CefBinaryValueImpl::IsEqual(CefRefPtr<CefBinaryValue> that) {
|
|||
|
||||
CefRefPtr<CefBinaryValue> CefBinaryValueImpl::Copy() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
return new CefBinaryValueImpl(new base::Value(const_value().Clone()), nullptr,
|
||||
CefBinaryValueImpl::kOwnerWillDelete, nullptr);
|
||||
return new CefBinaryValueImpl(const_value().Clone());
|
||||
}
|
||||
|
||||
size_t CefBinaryValueImpl::GetSize() {
|
||||
|
@ -629,19 +642,20 @@ CefBinaryValueImpl::CefBinaryValueImpl(base::Value* value,
|
|||
: CefValueBase<CefBinaryValue, base::Value>(value,
|
||||
parent_value,
|
||||
value_mode,
|
||||
true,
|
||||
/*read_only=*/true,
|
||||
controller) {}
|
||||
|
||||
// CefDictionaryValueImpl implementation.
|
||||
|
||||
// static
|
||||
CefRefPtr<CefDictionaryValue> CefDictionaryValue::Create() {
|
||||
return new CefDictionaryValueImpl(new base::DictionaryValue(), true, false);
|
||||
return new CefDictionaryValueImpl(base::Value(base::Value::Type::DICT),
|
||||
/*read_only=*/false);
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefDictionaryValue> CefDictionaryValueImpl::GetOrCreateRef(
|
||||
base::DictionaryValue* value,
|
||||
base::Value* value,
|
||||
void* parent_value,
|
||||
bool read_only,
|
||||
CefValueController* controller) {
|
||||
|
@ -655,54 +669,59 @@ CefRefPtr<CefDictionaryValue> CefDictionaryValueImpl::GetOrCreateRef(
|
|||
read_only, controller);
|
||||
}
|
||||
|
||||
CefDictionaryValueImpl::CefDictionaryValueImpl(base::DictionaryValue* value,
|
||||
CefDictionaryValueImpl::CefDictionaryValueImpl(base::Value value,
|
||||
bool read_only)
|
||||
: CefDictionaryValueImpl(new base::Value(std::move(value)),
|
||||
/*will_delete=*/true,
|
||||
read_only) {}
|
||||
|
||||
CefDictionaryValueImpl::CefDictionaryValueImpl(base::Value::Dict value,
|
||||
bool read_only)
|
||||
: CefDictionaryValueImpl(base::Value(std::move(value)), read_only) {}
|
||||
|
||||
CefDictionaryValueImpl::CefDictionaryValueImpl(base::Value* value,
|
||||
bool will_delete,
|
||||
bool read_only)
|
||||
: CefValueBase<CefDictionaryValue, base::DictionaryValue>(
|
||||
value,
|
||||
: CefDictionaryValueImpl(value,
|
||||
nullptr,
|
||||
will_delete ? kOwnerWillDelete : kOwnerNoDelete,
|
||||
read_only,
|
||||
nullptr) {}
|
||||
|
||||
base::DictionaryValue* CefDictionaryValueImpl::CopyValue() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
return static_cast<base::DictionaryValue*>(
|
||||
new base::Value(const_value().Clone()));
|
||||
base::Value CefDictionaryValueImpl::CopyValue() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, base::Value());
|
||||
return const_value().Clone();
|
||||
}
|
||||
|
||||
base::DictionaryValue* CefDictionaryValueImpl::CopyOrDetachValue(
|
||||
std::unique_ptr<base::Value> CefDictionaryValueImpl::CopyOrDetachValue(
|
||||
CefValueController* new_controller) {
|
||||
base::DictionaryValue* new_value;
|
||||
|
||||
if (!will_delete()) {
|
||||
// Copy the value.
|
||||
new_value = CopyValue();
|
||||
} else {
|
||||
return std::make_unique<base::Value>(CopyValue());
|
||||
}
|
||||
|
||||
// Take ownership of the value.
|
||||
new_value = Detach(new_controller);
|
||||
auto value = base::WrapUnique(Detach(new_controller));
|
||||
DCHECK(value.get());
|
||||
return value;
|
||||
}
|
||||
|
||||
DCHECK(new_value);
|
||||
return new_value;
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::IsSameValue(const base::DictionaryValue* that) {
|
||||
bool CefDictionaryValueImpl::IsSameValue(const base::Value* that) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return (&const_value() == that);
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::IsEqualValue(const base::DictionaryValue* that) {
|
||||
bool CefDictionaryValueImpl::IsEqualValue(const base::Value* that) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return const_value() == *that;
|
||||
}
|
||||
|
||||
base::DictionaryValue* CefDictionaryValueImpl::GetValueUnsafe() {
|
||||
base::Value* CefDictionaryValueImpl::GetValueUnsafe() const {
|
||||
if (!VerifyAttached()) {
|
||||
return nullptr;
|
||||
}
|
||||
controller()->AssertLockAcquired();
|
||||
return const_cast<base::DictionaryValue*>(&const_value());
|
||||
return mutable_value_unchecked();
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::IsValid() {
|
||||
|
@ -747,19 +766,17 @@ CefRefPtr<CefDictionaryValue> CefDictionaryValueImpl::Copy(
|
|||
bool exclude_empty_children) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
|
||||
base::DictionaryValue* value = static_cast<base::DictionaryValue*>(
|
||||
new base::Value(const_value().Clone()));
|
||||
auto value = const_value().Clone();
|
||||
if (exclude_empty_children) {
|
||||
RemoveEmptyValueDicts(value->GetDict());
|
||||
RemoveEmptyValueDicts(value.GetDict());
|
||||
}
|
||||
|
||||
return new CefDictionaryValueImpl(
|
||||
value, nullptr, CefDictionaryValueImpl::kOwnerWillDelete, false, nullptr);
|
||||
return new CefDictionaryValueImpl(std::move(value), /*read_only=*/false);
|
||||
}
|
||||
|
||||
size_t CefDictionaryValueImpl::GetSize() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||
return const_value().DictSize();
|
||||
return const_value().GetDict().size();
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::Clear() {
|
||||
|
@ -774,7 +791,7 @@ bool CefDictionaryValueImpl::Clear() {
|
|||
|
||||
bool CefDictionaryValueImpl::HasKey(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||
return const_value().FindKey(base::StringPiece(key));
|
||||
return const_value().GetDict().contains(base::StringPiece(key));
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::GetKeys(KeyList& keys) {
|
||||
|
@ -795,7 +812,8 @@ bool CefDictionaryValueImpl::Remove(const CefString& key) {
|
|||
CefValueType CefDictionaryValueImpl::GetType(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, VTYPE_INVALID);
|
||||
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
const base::Value* value =
|
||||
const_value().GetDict().Find(base::StringPiece(key));
|
||||
if (value) {
|
||||
switch (value->type()) {
|
||||
case base::Value::Type::NONE:
|
||||
|
@ -823,12 +841,12 @@ CefValueType CefDictionaryValueImpl::GetType(const CefString& key) {
|
|||
CefRefPtr<CefValue> CefDictionaryValueImpl::GetValue(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
const base::Value* value =
|
||||
const_value().GetDict().Find(base::StringPiece(key));
|
||||
if (value) {
|
||||
return CefValueImpl::GetOrCreateRefOrCopy(
|
||||
const_cast<base::Value*>(value),
|
||||
const_cast<base::DictionaryValue*>(&const_value()), read_only(),
|
||||
controller());
|
||||
return CefValueImpl::GetOrCreateRefOrCopy(const_cast<base::Value*>(value),
|
||||
mutable_value_unchecked(),
|
||||
read_only(), controller());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -839,7 +857,8 @@ bool CefDictionaryValueImpl::GetBool(const CefString& key) {
|
|||
|
||||
bool ret_value = false;
|
||||
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
const base::Value* value =
|
||||
const_value().GetDict().Find(base::StringPiece(key));
|
||||
if (value && value->is_bool()) {
|
||||
ret_value = value->GetBool();
|
||||
}
|
||||
|
@ -852,7 +871,8 @@ int CefDictionaryValueImpl::GetInt(const CefString& key) {
|
|||
|
||||
int ret_value = 0;
|
||||
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
const base::Value* value =
|
||||
const_value().GetDict().Find(base::StringPiece(key));
|
||||
if (value && value->is_int()) {
|
||||
ret_value = value->GetInt();
|
||||
}
|
||||
|
@ -865,7 +885,8 @@ double CefDictionaryValueImpl::GetDouble(const CefString& key) {
|
|||
|
||||
double ret_value = 0;
|
||||
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
const base::Value* value =
|
||||
const_value().GetDict().Find(base::StringPiece(key));
|
||||
if (value && value->is_double()) {
|
||||
ret_value = value->GetDouble();
|
||||
}
|
||||
|
@ -878,7 +899,8 @@ CefString CefDictionaryValueImpl::GetString(const CefString& key) {
|
|||
|
||||
std::string ret_value;
|
||||
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
const base::Value* value =
|
||||
const_value().GetDict().Find(base::StringPiece(key));
|
||||
if (value && value->is_string()) {
|
||||
ret_value = value->GetString();
|
||||
}
|
||||
|
@ -890,12 +912,12 @@ CefRefPtr<CefBinaryValue> CefDictionaryValueImpl::GetBinary(
|
|||
const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
const base::Value* value =
|
||||
const_value().GetDict().Find(base::StringPiece(key));
|
||||
if (value && value->is_blob()) {
|
||||
base::Value* binary_value = const_cast<base::Value*>(value);
|
||||
return CefBinaryValueImpl::GetOrCreateRef(
|
||||
binary_value, const_cast<base::DictionaryValue*>(&const_value()),
|
||||
controller());
|
||||
binary_value, mutable_value_unchecked(), controller());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -905,13 +927,12 @@ CefRefPtr<CefDictionaryValue> CefDictionaryValueImpl::GetDictionary(
|
|||
const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
const base::Value* value =
|
||||
const_value().GetDict().Find(base::StringPiece(key));
|
||||
if (value && value->is_dict()) {
|
||||
base::DictionaryValue* dict_value =
|
||||
static_cast<base::DictionaryValue*>(const_cast<base::Value*>(value));
|
||||
base::Value* dict_value = const_cast<base::Value*>(value);
|
||||
return CefDictionaryValueImpl::GetOrCreateRef(
|
||||
dict_value, const_cast<base::DictionaryValue*>(&const_value()),
|
||||
read_only(), controller());
|
||||
dict_value, mutable_value_unchecked(), read_only(), controller());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -920,13 +941,12 @@ CefRefPtr<CefDictionaryValue> CefDictionaryValueImpl::GetDictionary(
|
|||
CefRefPtr<CefListValue> CefDictionaryValueImpl::GetList(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
const base::Value* value =
|
||||
const_value().GetDict().Find(base::StringPiece(key));
|
||||
if (value && value->is_list()) {
|
||||
base::ListValue* list_value =
|
||||
static_cast<base::ListValue*>(const_cast<base::Value*>(value));
|
||||
base::Value* list_value = const_cast<base::Value*>(value);
|
||||
return CefListValueImpl::GetOrCreateRef(
|
||||
list_value, const_cast<base::DictionaryValue*>(&const_value()),
|
||||
read_only(), controller());
|
||||
list_value, mutable_value_unchecked(), read_only(), controller());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -939,40 +959,40 @@ bool CefDictionaryValueImpl::SetValue(const CefString& key,
|
|||
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
|
||||
DCHECK(impl);
|
||||
|
||||
base::Value* new_value = impl->CopyOrDetachValue(controller());
|
||||
base::Value* actual_value = SetInternal(key, new_value);
|
||||
base::Value* actual_value =
|
||||
SetInternal(key, impl->CopyOrDetachValue(controller()));
|
||||
impl->SwapValue(actual_value, mutable_value(), controller());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::SetNull(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(true, false);
|
||||
SetInternal(key, new base::Value());
|
||||
SetInternal(key, std::make_unique<base::Value>());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::SetBool(const CefString& key, bool value) {
|
||||
CEF_VALUE_VERIFY_RETURN(true, false);
|
||||
SetInternal(key, new base::Value(value));
|
||||
SetInternal(key, std::make_unique<base::Value>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::SetInt(const CefString& key, int value) {
|
||||
CEF_VALUE_VERIFY_RETURN(true, false);
|
||||
SetInternal(key, new base::Value(value));
|
||||
SetInternal(key, std::make_unique<base::Value>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::SetDouble(const CefString& key, double value) {
|
||||
CEF_VALUE_VERIFY_RETURN(true, false);
|
||||
SetInternal(key, new base::Value(value));
|
||||
SetInternal(key, std::make_unique<base::Value>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::SetString(const CefString& key,
|
||||
const CefString& value) {
|
||||
CEF_VALUE_VERIFY_RETURN(true, false);
|
||||
SetInternal(key, new base::Value(value.ToString()));
|
||||
SetInternal(key, std::make_unique<base::Value>(value.ToString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1018,14 +1038,14 @@ bool CefDictionaryValueImpl::RemoveInternal(const CefString& key) {
|
|||
// retrieve the actual Value pointer as it current exists first, for later
|
||||
// comparison purposes.
|
||||
const base::Value* actual_value =
|
||||
const_value().FindKey(base::StringPiece(key));
|
||||
const_value().GetDict().Find(base::StringPiece(key));
|
||||
if (!actual_value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// |actual_value| is no longer valid after this call.
|
||||
absl::optional<base::Value> out_value =
|
||||
mutable_value()->ExtractKey(base::StringPiece(key));
|
||||
mutable_value()->GetDict().Extract(base::StringPiece(key));
|
||||
if (!out_value.has_value()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1041,10 +1061,10 @@ bool CefDictionaryValueImpl::RemoveInternal(const CefString& key) {
|
|||
return true;
|
||||
}
|
||||
|
||||
base::Value* CefDictionaryValueImpl::SetInternal(const CefString& key,
|
||||
base::Value* value) {
|
||||
base::Value* CefDictionaryValueImpl::SetInternal(
|
||||
const CefString& key,
|
||||
std::unique_ptr<base::Value> value) {
|
||||
DCHECK(value);
|
||||
std::unique_ptr<base::Value> valueObj(value);
|
||||
|
||||
RemoveInternal(key);
|
||||
|
||||
|
@ -1057,32 +1077,35 @@ base::Value* CefDictionaryValueImpl::SetInternal(const CefString& key,
|
|||
|
||||
// |value| will be deleted when this method returns. Update the controller to
|
||||
// reference |actual_value| instead.
|
||||
controller()->Swap(value, actual_value);
|
||||
controller()->Swap(value.get(), actual_value);
|
||||
|
||||
return actual_value;
|
||||
}
|
||||
|
||||
CefDictionaryValueImpl::CefDictionaryValueImpl(base::DictionaryValue* value,
|
||||
CefDictionaryValueImpl::CefDictionaryValueImpl(base::Value* value,
|
||||
void* parent_value,
|
||||
ValueMode value_mode,
|
||||
bool read_only,
|
||||
CefValueController* controller)
|
||||
: CefValueBase<CefDictionaryValue, base::DictionaryValue>(value,
|
||||
: CefValueBase<CefDictionaryValue, base::Value>(value,
|
||||
parent_value,
|
||||
value_mode,
|
||||
read_only,
|
||||
controller) {}
|
||||
controller) {
|
||||
DCHECK(value->is_dict());
|
||||
}
|
||||
|
||||
// CefListValueImpl implementation.
|
||||
|
||||
// static
|
||||
CefRefPtr<CefListValue> CefListValue::Create() {
|
||||
return new CefListValueImpl(new base::ListValue(), true, false);
|
||||
return new CefListValueImpl(base::Value(base::Value::Type::LIST),
|
||||
/*read_only=*/false);
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefListValue> CefListValueImpl::GetOrCreateRef(
|
||||
base::ListValue* value,
|
||||
base::Value* value,
|
||||
void* parent_value,
|
||||
bool read_only,
|
||||
CefValueController* controller) {
|
||||
|
@ -1095,53 +1118,57 @@ CefRefPtr<CefListValue> CefListValueImpl::GetOrCreateRef(
|
|||
read_only, controller);
|
||||
}
|
||||
|
||||
CefListValueImpl::CefListValueImpl(base::ListValue* value,
|
||||
CefListValueImpl::CefListValueImpl(base::Value value, bool read_only)
|
||||
: CefListValueImpl(new base::Value(std::move(value)),
|
||||
/*will_delete=*/true,
|
||||
read_only) {}
|
||||
|
||||
CefListValueImpl::CefListValueImpl(base::Value::List value, bool read_only)
|
||||
: CefListValueImpl(base::Value(std::move(value)), read_only) {}
|
||||
|
||||
CefListValueImpl::CefListValueImpl(base::Value* value,
|
||||
bool will_delete,
|
||||
bool read_only)
|
||||
: CefValueBase<CefListValue, base::ListValue>(
|
||||
value,
|
||||
: CefListValueImpl(value,
|
||||
nullptr,
|
||||
will_delete ? kOwnerWillDelete : kOwnerNoDelete,
|
||||
read_only,
|
||||
nullptr) {}
|
||||
|
||||
base::ListValue* CefListValueImpl::CopyValue() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
return static_cast<base::ListValue*>(new base::Value(const_value().Clone()));
|
||||
base::Value CefListValueImpl::CopyValue() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, base::Value());
|
||||
return const_value().Clone();
|
||||
}
|
||||
|
||||
base::ListValue* CefListValueImpl::CopyOrDetachValue(
|
||||
std::unique_ptr<base::Value> CefListValueImpl::CopyOrDetachValue(
|
||||
CefValueController* new_controller) {
|
||||
base::ListValue* new_value;
|
||||
|
||||
if (!will_delete()) {
|
||||
// Copy the value.
|
||||
new_value = CopyValue();
|
||||
} else {
|
||||
return std::make_unique<base::Value>(CopyValue());
|
||||
}
|
||||
|
||||
// Take ownership of the value.
|
||||
new_value = Detach(new_controller);
|
||||
auto value = base::WrapUnique(Detach(new_controller));
|
||||
DCHECK(value.get());
|
||||
return value;
|
||||
}
|
||||
|
||||
DCHECK(new_value);
|
||||
return new_value;
|
||||
}
|
||||
|
||||
bool CefListValueImpl::IsSameValue(const base::ListValue* that) {
|
||||
bool CefListValueImpl::IsSameValue(const base::Value* that) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return (&const_value() == that);
|
||||
}
|
||||
|
||||
bool CefListValueImpl::IsEqualValue(const base::ListValue* that) {
|
||||
bool CefListValueImpl::IsEqualValue(const base::Value* that) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return const_value() == *that;
|
||||
}
|
||||
|
||||
base::ListValue* CefListValueImpl::GetValueUnsafe() {
|
||||
base::Value* CefListValueImpl::GetValueUnsafe() const {
|
||||
if (!VerifyAttached()) {
|
||||
return nullptr;
|
||||
}
|
||||
controller()->AssertLockAcquired();
|
||||
return const_cast<base::ListValue*>(&const_value());
|
||||
return mutable_value_unchecked();
|
||||
}
|
||||
|
||||
bool CefListValueImpl::IsValid() {
|
||||
|
@ -1185,9 +1212,7 @@ bool CefListValueImpl::IsEqual(CefRefPtr<CefListValue> that) {
|
|||
CefRefPtr<CefListValue> CefListValueImpl::Copy() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
|
||||
return new CefListValueImpl(
|
||||
static_cast<base::ListValue*>(new base::Value(const_value().Clone())),
|
||||
nullptr, CefListValueImpl::kOwnerWillDelete, false, nullptr);
|
||||
return new CefListValueImpl(const_value().Clone(), /*read_only=*/false);
|
||||
}
|
||||
|
||||
bool CefListValueImpl::SetSize(size_t size) {
|
||||
|
@ -1205,7 +1230,7 @@ bool CefListValueImpl::SetSize(size_t size) {
|
|||
// for background.
|
||||
auto& list = mutable_value()->GetList();
|
||||
while (list.size() < size) {
|
||||
mutable_value()->Append(base::Value());
|
||||
list.Append(base::Value());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -1266,10 +1291,9 @@ CefRefPtr<CefValue> CefListValueImpl::GetValue(size_t index) {
|
|||
const auto& list = const_value().GetList();
|
||||
if (index < list.size()) {
|
||||
const base::Value& value = list[index];
|
||||
return CefValueImpl::GetOrCreateRefOrCopy(
|
||||
const_cast<base::Value*>(&value),
|
||||
const_cast<base::ListValue*>(&const_value()), read_only(),
|
||||
controller());
|
||||
return CefValueImpl::GetOrCreateRefOrCopy(const_cast<base::Value*>(&value),
|
||||
mutable_value_unchecked(),
|
||||
read_only(), controller());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -1340,12 +1364,10 @@ CefRefPtr<CefBinaryValue> CefListValueImpl::GetBinary(size_t index) {
|
|||
|
||||
const auto& list = const_value().GetList();
|
||||
if (index < list.size()) {
|
||||
const base::Value& value = list[index];
|
||||
base::Value& value = const_cast<base::Value&>(list[index]);
|
||||
if (value.is_blob()) {
|
||||
base::Value* binary_value = const_cast<base::Value*>(&value);
|
||||
return CefBinaryValueImpl::GetOrCreateRef(
|
||||
binary_value, const_cast<base::ListValue*>(&const_value()),
|
||||
controller());
|
||||
&value, mutable_value_unchecked(), controller());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1357,13 +1379,10 @@ CefRefPtr<CefDictionaryValue> CefListValueImpl::GetDictionary(size_t index) {
|
|||
|
||||
const auto& list = const_value().GetList();
|
||||
if (index < list.size()) {
|
||||
const base::Value& value = list[index];
|
||||
base::Value& value = const_cast<base::Value&>(list[index]);
|
||||
if (value.is_dict()) {
|
||||
base::DictionaryValue* dict_value =
|
||||
static_cast<base::DictionaryValue*>(const_cast<base::Value*>(&value));
|
||||
return CefDictionaryValueImpl::GetOrCreateRef(
|
||||
dict_value, const_cast<base::ListValue*>(&const_value()), read_only(),
|
||||
controller());
|
||||
&value, mutable_value_unchecked(), read_only(), controller());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1375,13 +1394,10 @@ CefRefPtr<CefListValue> CefListValueImpl::GetList(size_t index) {
|
|||
|
||||
const auto& list = const_value().GetList();
|
||||
if (index < list.size()) {
|
||||
const base::Value& value = list[index];
|
||||
base::Value& value = const_cast<base::Value&>(list[index]);
|
||||
if (value.is_list()) {
|
||||
base::ListValue* list_value =
|
||||
static_cast<base::ListValue*>(const_cast<base::Value*>(&value));
|
||||
return CefListValueImpl::GetOrCreateRef(
|
||||
list_value, const_cast<base::ListValue*>(&const_value()), read_only(),
|
||||
controller());
|
||||
return CefListValueImpl::GetOrCreateRef(&value, mutable_value_unchecked(),
|
||||
read_only(), controller());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1394,39 +1410,39 @@ bool CefListValueImpl::SetValue(size_t index, CefRefPtr<CefValue> value) {
|
|||
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
|
||||
DCHECK(impl);
|
||||
|
||||
base::Value* new_value = impl->CopyOrDetachValue(controller());
|
||||
base::Value* actual_value = SetInternal(index, new_value);
|
||||
base::Value* actual_value =
|
||||
SetInternal(index, impl->CopyOrDetachValue(controller()));
|
||||
impl->SwapValue(actual_value, mutable_value(), controller());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefListValueImpl::SetNull(size_t index) {
|
||||
CEF_VALUE_VERIFY_RETURN(true, false);
|
||||
SetInternal(index, new base::Value());
|
||||
SetInternal(index, std::make_unique<base::Value>());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefListValueImpl::SetBool(size_t index, bool value) {
|
||||
CEF_VALUE_VERIFY_RETURN(true, false);
|
||||
SetInternal(index, new base::Value(value));
|
||||
SetInternal(index, std::make_unique<base::Value>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefListValueImpl::SetInt(size_t index, int value) {
|
||||
CEF_VALUE_VERIFY_RETURN(true, false);
|
||||
SetInternal(index, new base::Value(value));
|
||||
SetInternal(index, std::make_unique<base::Value>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefListValueImpl::SetDouble(size_t index, double value) {
|
||||
CEF_VALUE_VERIFY_RETURN(true, false);
|
||||
SetInternal(index, new base::Value(value));
|
||||
SetInternal(index, std::make_unique<base::Value>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefListValueImpl::SetString(size_t index, const CefString& value) {
|
||||
CEF_VALUE_VERIFY_RETURN(true, false);
|
||||
SetInternal(index, new base::Value(value.ToString()));
|
||||
SetInternal(index, std::make_unique<base::Value>(value.ToString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1491,9 +1507,9 @@ bool CefListValueImpl::RemoveInternal(size_t index) {
|
|||
return true;
|
||||
}
|
||||
|
||||
base::Value* CefListValueImpl::SetInternal(size_t index, base::Value* value) {
|
||||
base::Value* CefListValueImpl::SetInternal(size_t index,
|
||||
std::unique_ptr<base::Value> value) {
|
||||
DCHECK(value);
|
||||
std::unique_ptr<base::Value> valueObj(value);
|
||||
|
||||
auto& list = mutable_value()->GetList();
|
||||
if (RemoveInternal(index)) {
|
||||
|
@ -1505,7 +1521,7 @@ base::Value* CefListValueImpl::SetInternal(size_t index, base::Value* value) {
|
|||
// TODO: This approach seems inefficient. See
|
||||
// https://crbug.com/1187066#c17 for background.
|
||||
while (list.size() <= index) {
|
||||
mutable_value()->Append(base::Value());
|
||||
list.Append(base::Value());
|
||||
}
|
||||
}
|
||||
list[index] = std::move(*value);
|
||||
|
@ -1519,18 +1535,20 @@ base::Value* CefListValueImpl::SetInternal(size_t index, base::Value* value) {
|
|||
|
||||
// |value| will be deleted when this method returns. Update the controller to
|
||||
// reference |actual_value| instead.
|
||||
controller()->Swap(value, const_cast<base::Value*>(&actual_value));
|
||||
controller()->Swap(value.get(), const_cast<base::Value*>(&actual_value));
|
||||
|
||||
return const_cast<base::Value*>(&actual_value);
|
||||
}
|
||||
|
||||
CefListValueImpl::CefListValueImpl(base::ListValue* value,
|
||||
CefListValueImpl::CefListValueImpl(base::Value* value,
|
||||
void* parent_value,
|
||||
ValueMode value_mode,
|
||||
bool read_only,
|
||||
CefValueController* controller)
|
||||
: CefValueBase<CefListValue, base::ListValue>(value,
|
||||
: CefValueBase<CefListValue, base::Value>(value,
|
||||
parent_value,
|
||||
value_mode,
|
||||
read_only,
|
||||
controller) {}
|
||||
controller) {
|
||||
DCHECK(value->is_list());
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define CEF_LIBCEF_COMMON_VALUES_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_values.h"
|
||||
|
@ -28,7 +29,7 @@ class CefValueImpl : public CefValue {
|
|||
|
||||
// Take ownership of |value|. Do not pass in a value owned by something else
|
||||
// (use GetOrCreateRefOrCopy instead).
|
||||
explicit CefValueImpl(base::Value* value);
|
||||
explicit CefValueImpl(base::Value value);
|
||||
|
||||
// Keep a reference to |value|.
|
||||
explicit CefValueImpl(CefRefPtr<CefBinaryValue> value);
|
||||
|
@ -42,19 +43,23 @@ class CefValueImpl : public CefValue {
|
|||
|
||||
// Take ownership of |value|. Do not pass in a value owned by something else
|
||||
// (use GetOrCreateRefOrCopy or Set*() instead).
|
||||
void SetValue(base::Value* value);
|
||||
void SetValue(base::Value value);
|
||||
|
||||
// Return a copy of the value.
|
||||
[[nodiscard]] base::Value CopyValue();
|
||||
|
||||
// Copy a simple value or transfer ownership of a complex value. If ownership
|
||||
// of the value is tranferred then this object's internal reference to the
|
||||
// value will be updated and remain valid. base::Value now uses move semantics
|
||||
// so we need to perform the copy and swap in two steps.
|
||||
base::Value* CopyOrDetachValue(CefValueController* new_controller);
|
||||
[[nodiscard]] std::unique_ptr<base::Value> CopyOrDetachValue(
|
||||
CefValueController* new_controller);
|
||||
void SwapValue(base::Value* new_value,
|
||||
void* new_parent_value,
|
||||
CefValueController* new_controller);
|
||||
|
||||
// Returns a reference to the underlying data. Access must be protected by
|
||||
// calling AcquireLock/ReleaseLock.
|
||||
// calling AcquireLock/ReleaseLock (e.g. use ScopedLockedValue).
|
||||
base::Value* GetValueUnsafe() const;
|
||||
|
||||
// CefValue methods.
|
||||
|
@ -101,7 +106,7 @@ class CefValueImpl : public CefValue {
|
|||
};
|
||||
|
||||
private:
|
||||
void SetValueInternal(base::Value* value);
|
||||
void SetValueInternal(absl::optional<base::Value> value);
|
||||
|
||||
// Returns the controller for the current value, if any.
|
||||
CefValueController* GetValueController() const;
|
||||
|
@ -133,6 +138,10 @@ class CefBinaryValueImpl : public CefValueBase<CefBinaryValue, base::Value> {
|
|||
void* parent_value,
|
||||
CefValueController* controller);
|
||||
|
||||
// Take ownership of |value|. Do not pass in a value owned by something else
|
||||
// (use GetOrCreateRef or constructor variant with |will_delete| argument).
|
||||
explicit CefBinaryValueImpl(base::Value value);
|
||||
|
||||
// Reference an existing value (set |will_delete| to false) or take ownership
|
||||
// of an existing value (set |will_delete| to true). When referencing an
|
||||
// existing value you must explicitly call Detach(nullptr) when |value| is no
|
||||
|
@ -148,11 +157,11 @@ class CefBinaryValueImpl : public CefValueBase<CefBinaryValue, base::Value> {
|
|||
CefBinaryValueImpl& operator=(const CefBinaryValueImpl&) = delete;
|
||||
|
||||
// Return a copy of the value.
|
||||
[[nodiscard]] base::Value* CopyValue();
|
||||
[[nodiscard]] base::Value CopyValue();
|
||||
|
||||
// If this value is a reference then return a copy. Otherwise, detach and
|
||||
// transfer ownership of the value.
|
||||
[[nodiscard]] base::Value* CopyOrDetachValue(
|
||||
[[nodiscard]] std::unique_ptr<base::Value> CopyOrDetachValue(
|
||||
CefValueController* new_controller);
|
||||
|
||||
bool IsSameValue(const base::Value* that);
|
||||
|
@ -160,7 +169,7 @@ class CefBinaryValueImpl : public CefValueBase<CefBinaryValue, base::Value> {
|
|||
|
||||
// Returns the underlying value. Access must be protected by calling
|
||||
// lock/unlock on the controller.
|
||||
base::Value* GetValueUnsafe();
|
||||
base::Value* GetValueUnsafe() const;
|
||||
|
||||
// CefBinaryValue methods.
|
||||
bool IsValid() override;
|
||||
|
@ -182,42 +191,45 @@ class CefBinaryValueImpl : public CefValueBase<CefBinaryValue, base::Value> {
|
|||
|
||||
// CefDictionaryValue implementation
|
||||
class CefDictionaryValueImpl
|
||||
: public CefValueBase<CefDictionaryValue, base::DictionaryValue> {
|
||||
: public CefValueBase<CefDictionaryValue, base::Value> {
|
||||
public:
|
||||
// Get or create a reference value.
|
||||
static CefRefPtr<CefDictionaryValue> GetOrCreateRef(
|
||||
base::DictionaryValue* value,
|
||||
base::Value* value,
|
||||
void* parent_value,
|
||||
bool read_only,
|
||||
CefValueController* controller);
|
||||
|
||||
// Take ownership of |value|. Do not pass in a value owned by something else
|
||||
// (use GetOrCreateRef or constructor variant with |will_delete| argument).
|
||||
CefDictionaryValueImpl(base::Value value, bool read_only);
|
||||
CefDictionaryValueImpl(base::Value::Dict value, bool read_only);
|
||||
|
||||
// Reference an existing value (set |will_delete| to false) or take ownership
|
||||
// of an existing value (set |will_delete| to true). When referencing an
|
||||
// existing value you must explicitly call Detach(nullptr) when |value| is no
|
||||
// longer valid. Use GetOrCreateRef instead of this constructor if |value| is
|
||||
// owned by some other object and you do not plan to explicitly call
|
||||
// Detach(nullptr).
|
||||
CefDictionaryValueImpl(base::DictionaryValue* value,
|
||||
bool will_delete,
|
||||
bool read_only);
|
||||
CefDictionaryValueImpl(base::Value* value, bool will_delete, bool read_only);
|
||||
|
||||
CefDictionaryValueImpl(const CefDictionaryValueImpl&) = delete;
|
||||
CefDictionaryValueImpl& operator=(const CefDictionaryValueImpl&) = delete;
|
||||
|
||||
// Return a copy of the value.
|
||||
[[nodiscard]] base::DictionaryValue* CopyValue();
|
||||
[[nodiscard]] base::Value CopyValue();
|
||||
|
||||
// If this value is a reference then return a copy. Otherwise, detach and
|
||||
// transfer ownership of the value.
|
||||
[[nodiscard]] base::DictionaryValue* CopyOrDetachValue(
|
||||
[[nodiscard]] std::unique_ptr<base::Value> CopyOrDetachValue(
|
||||
CefValueController* new_controller);
|
||||
|
||||
bool IsSameValue(const base::DictionaryValue* that);
|
||||
bool IsEqualValue(const base::DictionaryValue* that);
|
||||
bool IsSameValue(const base::Value* that);
|
||||
bool IsEqualValue(const base::Value* that);
|
||||
|
||||
// Returns the underlying value. Access must be protected by calling
|
||||
// lock/unlock on the controller.
|
||||
base::DictionaryValue* GetValueUnsafe();
|
||||
base::Value* GetValueUnsafe() const;
|
||||
|
||||
// CefDictionaryValue methods.
|
||||
bool IsValid() override;
|
||||
|
@ -254,50 +266,56 @@ class CefDictionaryValueImpl
|
|||
|
||||
private:
|
||||
// See the CefValueBase constructor for usage.
|
||||
CefDictionaryValueImpl(base::DictionaryValue* value,
|
||||
CefDictionaryValueImpl(base::Value* value,
|
||||
void* parent_value,
|
||||
ValueMode value_mode,
|
||||
bool read_only,
|
||||
CefValueController* controller);
|
||||
|
||||
bool RemoveInternal(const CefString& key);
|
||||
base::Value* SetInternal(const CefString& key, base::Value* value);
|
||||
base::Value* SetInternal(const CefString& key,
|
||||
std::unique_ptr<base::Value> value);
|
||||
};
|
||||
|
||||
// CefListValue implementation
|
||||
class CefListValueImpl : public CefValueBase<CefListValue, base::ListValue> {
|
||||
class CefListValueImpl : public CefValueBase<CefListValue, base::Value> {
|
||||
public:
|
||||
// Get or create a reference value.
|
||||
static CefRefPtr<CefListValue> GetOrCreateRef(base::ListValue* value,
|
||||
static CefRefPtr<CefListValue> GetOrCreateRef(base::Value* value,
|
||||
void* parent_value,
|
||||
bool read_only,
|
||||
CefValueController* controller);
|
||||
|
||||
// Take ownership of |value|. Do not pass in a value owned by something else
|
||||
// (use GetOrCreateRef or constructor variant with |will_delete| argument).
|
||||
CefListValueImpl(base::Value value, bool read_only);
|
||||
CefListValueImpl(base::Value::List value, bool read_only);
|
||||
|
||||
// Reference an existing value (set |will_delete| to false) or take ownership
|
||||
// of an existing value (set |will_delete| to true). When referencing an
|
||||
// existing value you must explicitly call Detach(nullptr) when |value| is no
|
||||
// longer valid. Use GetOrCreateRef instead of this constructor if |value| is
|
||||
// owned by some other object and you do not plan to explicitly call
|
||||
// Detach(nullptr).
|
||||
CefListValueImpl(base::ListValue* value, bool will_delete, bool read_only);
|
||||
CefListValueImpl(base::Value* value, bool will_delete, bool read_only);
|
||||
|
||||
CefListValueImpl(const CefListValueImpl&) = delete;
|
||||
CefListValueImpl& operator=(const CefListValueImpl&) = delete;
|
||||
|
||||
// Return a copy of the value.
|
||||
[[nodiscard]] base::ListValue* CopyValue();
|
||||
[[nodiscard]] base::Value CopyValue();
|
||||
|
||||
// If this value is a reference then return a copy. Otherwise, detach and
|
||||
// transfer ownership of the value.
|
||||
[[nodiscard]] base::ListValue* CopyOrDetachValue(
|
||||
[[nodiscard]] std::unique_ptr<base::Value> CopyOrDetachValue(
|
||||
CefValueController* new_controller);
|
||||
|
||||
bool IsSameValue(const base::ListValue* that);
|
||||
bool IsEqualValue(const base::ListValue* that);
|
||||
bool IsSameValue(const base::Value* that);
|
||||
bool IsEqualValue(const base::Value* that);
|
||||
|
||||
// Returns the underlying value. Access must be protected by calling
|
||||
// lock/unlock on the controller.
|
||||
base::ListValue* GetValueUnsafe();
|
||||
base::Value* GetValueUnsafe() const;
|
||||
|
||||
// CefListValue methods.
|
||||
bool IsValid() override;
|
||||
|
@ -332,14 +350,14 @@ class CefListValueImpl : public CefValueBase<CefListValue, base::ListValue> {
|
|||
|
||||
private:
|
||||
// See the CefValueBase constructor for usage.
|
||||
CefListValueImpl(base::ListValue* value,
|
||||
CefListValueImpl(base::Value* value,
|
||||
void* parent_value,
|
||||
ValueMode value_mode,
|
||||
bool read_only,
|
||||
CefValueController* controller);
|
||||
|
||||
bool RemoveInternal(size_t index);
|
||||
base::Value* SetInternal(size_t index, base::Value* value);
|
||||
base::Value* SetInternal(size_t index, std::unique_ptr<base::Value> value);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_COMMON_VALUES_IMPL_H_
|
||||
|
|
|
@ -61,9 +61,9 @@ bool CefPrintRenderFrameHelperDelegate::OverridePrint(
|
|||
// instructs the PDF plugin to print. This is to make window.print() on a
|
||||
// PDF plugin document correctly print the PDF. See
|
||||
// https://crbug.com/448720.
|
||||
base::DictionaryValue message;
|
||||
message.SetString("type", "print");
|
||||
post_message_support->PostMessageFromValue(message);
|
||||
base::Value::Dict message;
|
||||
message.Set("type", "print");
|
||||
post_message_support->PostMessageFromValue(base::Value(std::move(message)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -290,7 +290,7 @@ void CefFrameImpl::SendProcessMessage(CefProcessId target_process,
|
|||
SendToBrowserFrame(
|
||||
__FUNCTION__,
|
||||
base::BindOnce(
|
||||
[](const CefString& name, base::ListValue argument_list,
|
||||
[](const CefString& name, base::Value::List argument_list,
|
||||
const BrowserFrameType& render_frame) {
|
||||
render_frame->SendMessage(name, std::move(argument_list));
|
||||
},
|
||||
|
@ -732,12 +732,12 @@ void CefFrameImpl::FrameDetached() {
|
|||
OnDisconnect(DisconnectReason::BROWSER_FRAME_DETACHED);
|
||||
}
|
||||
|
||||
void CefFrameImpl::SendMessage(const std::string& name, base::Value arguments) {
|
||||
void CefFrameImpl::SendMessage(const std::string& name,
|
||||
base::Value::List arguments) {
|
||||
if (auto app = CefAppManager::Get()->GetApplication()) {
|
||||
if (auto handler = app->GetRenderProcessHandler()) {
|
||||
auto& list_value = base::Value::AsListValue(arguments);
|
||||
CefRefPtr<CefProcessMessageImpl> message(new CefProcessMessageImpl(
|
||||
name, std::move(const_cast<base::ListValue&>(list_value)),
|
||||
CefRefPtr<CefProcessMessageImpl> message(
|
||||
new CefProcessMessageImpl(name, std::move(arguments),
|
||||
/*read_only=*/true));
|
||||
handler->OnProcessMessageReceived(browser_, this, PID_BROWSER,
|
||||
message.get());
|
||||
|
@ -835,10 +835,11 @@ void CefFrameImpl::DidStopLoading() {
|
|||
void CefFrameImpl::MoveOrResizeStarted() {
|
||||
if (frame_) {
|
||||
auto web_view = frame_->View();
|
||||
if (web_view)
|
||||
if (web_view) {
|
||||
web_view->CancelPagePopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefFrameImpl::ContextLifecycleStateChanged(
|
||||
blink::mojom::blink::FrameLifecycleState state) {
|
||||
|
|
|
@ -149,7 +149,8 @@ class CefFrameImpl
|
|||
// cef::mojom::RenderFrame methods:
|
||||
void FrameAttachedAck() override;
|
||||
void FrameDetached() override;
|
||||
void SendMessage(const std::string& name, base::Value arguments) override;
|
||||
void SendMessage(const std::string& name,
|
||||
base::Value::List arguments) override;
|
||||
void SendSharedMemoryRegion(const std::string& name,
|
||||
base::ReadOnlySharedMemoryRegion region) override;
|
||||
void SendCommand(const std::string& command) override;
|
||||
|
|
|
@ -350,15 +350,11 @@ CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
|
|||
if (handler.get()) {
|
||||
CefRefPtr<CefDictionaryValueImpl> dictValuePtr;
|
||||
if (params->extra_info) {
|
||||
auto& dict_value = base::Value::AsDictionaryValue(*params->extra_info);
|
||||
dictValuePtr = new CefDictionaryValueImpl(
|
||||
const_cast<base::DictionaryValue*>(&dict_value),
|
||||
/*will_delete=*/false, /*read_only=*/true);
|
||||
dictValuePtr =
|
||||
new CefDictionaryValueImpl(std::move(*params->extra_info),
|
||||
/*read_only=*/true);
|
||||
}
|
||||
handler->OnBrowserCreated(browser.get(), dictValuePtr.get());
|
||||
if (dictValuePtr) {
|
||||
std::ignore = dictValuePtr->Detach(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue