mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update to Chromium revision 318e6f54 (#400326)
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/json/json_reader.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/json/string_escape.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
@@ -158,7 +159,7 @@ void CefDevToolsFrontend::Close() {
|
||||
void CefDevToolsFrontend::DisconnectFromTarget() {
|
||||
if (!agent_host_)
|
||||
return;
|
||||
agent_host_->DetachClient();
|
||||
agent_host_->DetachClient(this);
|
||||
agent_host_ = NULL;
|
||||
}
|
||||
|
||||
@@ -206,7 +207,7 @@ void CefDevToolsFrontend::DocumentAvailableInMainFrame() {
|
||||
|
||||
void CefDevToolsFrontend::WebContentsDestroyed() {
|
||||
if (agent_host_)
|
||||
agent_host_->DetachClient();
|
||||
agent_host_->DetachClient(this);
|
||||
delete this;
|
||||
}
|
||||
|
||||
@@ -228,11 +229,12 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
dict->GetList("params", ¶ms);
|
||||
|
||||
if (method == "dispatchProtocolMessage" && params && params->GetSize() == 1) {
|
||||
if (!agent_host_ || !agent_host_->IsAttached())
|
||||
return;
|
||||
std::string protocol_message;
|
||||
if (!params->GetString(0, &protocol_message))
|
||||
return;
|
||||
if (agent_host_)
|
||||
agent_host_->DispatchProtocolMessage(protocol_message);
|
||||
agent_host_->DispatchProtocolMessage(this, protocol_message);
|
||||
} else if (method == "loadCompleted") {
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
|
||||
base::ASCIIToUTF16("DevToolsAPI.setUseSoftMenu(true);"));
|
||||
@@ -298,18 +300,21 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
|
||||
content::DevToolsAgentHost* agent_host,
|
||||
const std::string& message) {
|
||||
if (message.length() < kMaxMessageChunkSize) {
|
||||
base::string16 javascript = base::UTF8ToUTF16(
|
||||
"DevToolsAPI.dispatchMessage(" + message + ");");
|
||||
std::string param;
|
||||
base::EscapeJSONString(message, true, ¶m);
|
||||
std::string code = "DevToolsAPI.dispatchMessage(" + param + ");";
|
||||
base::string16 javascript = base::UTF8ToUTF16(code);
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
|
||||
return;
|
||||
}
|
||||
|
||||
base::FundamentalValue total_size(static_cast<int>(message.length()));
|
||||
size_t total_size = message.length();
|
||||
for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
|
||||
std::string param;
|
||||
base::JSONWriter::Write(
|
||||
base::StringValue(message.substr(pos, kMaxMessageChunkSize)), ¶m);
|
||||
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");";
|
||||
base::EscapeJSONString(message.substr(pos, kMaxMessageChunkSize), true,
|
||||
¶m);
|
||||
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + "," +
|
||||
std::to_string(pos ? 0 : total_size) + ");";
|
||||
base::string16 javascript = base::UTF8ToUTF16(code);
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
|
||||
}
|
||||
|
Reference in New Issue
Block a user