2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/common/process_message_impl.h"
|
2021-05-20 18:26:36 +02:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/logging.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/common/values_impl.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
// static
|
|
|
|
CefRefPtr<CefProcessMessage> CefProcessMessage::Create(const CefString& name) {
|
|
|
|
return new CefProcessMessageImpl(name, CefListValue::Create());
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
CefProcessMessageImpl::CefProcessMessageImpl(const CefString& name,
|
|
|
|
CefRefPtr<CefListValue> arguments)
|
|
|
|
: name_(name), arguments_(arguments) {
|
|
|
|
DCHECK(!name_.empty());
|
2021-05-20 18:26:36 +02:00
|
|
|
DCHECK(arguments_ && arguments_->IsValid());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
CefProcessMessageImpl::CefProcessMessageImpl(const CefString& name,
|
2023-01-30 22:42:40 +01:00
|
|
|
base::Value::List arguments,
|
2021-05-14 18:58:55 +02:00
|
|
|
bool read_only)
|
2021-05-20 18:26:36 +02:00
|
|
|
: name_(name) {
|
2021-05-14 18:58:55 +02:00
|
|
|
DCHECK(!name_.empty());
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2023-01-30 22:42:40 +01:00
|
|
|
arguments_ = new CefListValueImpl(std::move(arguments), read_only);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2021-05-20 18:26:36 +02:00
|
|
|
CefProcessMessageImpl::~CefProcessMessageImpl() = default;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2023-01-30 22:42:40 +01:00
|
|
|
base::Value::List CefProcessMessageImpl::TakeArgumentList() {
|
2021-05-14 18:58:55 +02:00
|
|
|
DCHECK(IsValid());
|
|
|
|
CefListValueImpl* value_impl =
|
|
|
|
static_cast<CefListValueImpl*>(arguments_.get());
|
2023-01-30 22:42:40 +01:00
|
|
|
auto value = value_impl->CopyOrDetachValue(nullptr);
|
|
|
|
return std::move(value->GetList());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefProcessMessageImpl::IsValid() {
|
2021-05-14 18:58:55 +02:00
|
|
|
return arguments_->IsValid();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefProcessMessageImpl::IsReadOnly() {
|
2021-05-14 18:58:55 +02:00
|
|
|
return arguments_->IsReadOnly();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefProcessMessage> CefProcessMessageImpl::Copy() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!IsValid()) {
|
2021-05-14 18:58:55 +02:00
|
|
|
return nullptr;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2021-05-14 18:58:55 +02:00
|
|
|
return new CefProcessMessageImpl(name_, arguments_->Copy());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefString CefProcessMessageImpl::GetName() {
|
2021-05-14 18:58:55 +02:00
|
|
|
return name_;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefListValue> CefProcessMessageImpl::GetArgumentList() {
|
2021-05-14 18:58:55 +02:00
|
|
|
return arguments_;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|