Update to Chromium revision 318e6f54 (#400326)

This commit is contained in:
Marshall Greenblatt
2016-06-20 18:59:23 -04:00
parent 66425def4a
commit 05ee60b7b4
78 changed files with 679 additions and 442 deletions

View File

@@ -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", &params);
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, &param);
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)), &param);
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");";
base::EscapeJSONString(message.substr(pos, kMaxMessageChunkSize), true,
&param);
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + "," +
std::to_string(pos ? 0 : total_size) + ");";
base::string16 javascript = base::UTF8ToUTF16(code);
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
}