| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/devtools/devtools_ui_bindings.h" | 5 #include "chrome/browser/devtools/devtools_ui_bindings.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 method, | 459 method, |
| 460 params); | 460 params); |
| 461 } | 461 } |
| 462 | 462 |
| 463 // content::DevToolsAgentHostClient implementation -------------------------- | 463 // content::DevToolsAgentHostClient implementation -------------------------- |
| 464 void DevToolsUIBindings::DispatchProtocolMessage( | 464 void DevToolsUIBindings::DispatchProtocolMessage( |
| 465 content::DevToolsAgentHost* agent_host, const std::string& message) { | 465 content::DevToolsAgentHost* agent_host, const std::string& message) { |
| 466 DCHECK(agent_host == agent_host_.get()); | 466 DCHECK(agent_host == agent_host_.get()); |
| 467 | 467 |
| 468 if (message.length() < kMaxMessageChunkSize) { | 468 if (message.length() < kMaxMessageChunkSize) { |
| 469 base::string16 javascript = base::UTF8ToUTF16( | 469 base::StringValue message_value(message); |
| 470 "DevToolsAPI.dispatchMessage(" + message + ");"); | 470 CallClientFunction("DevToolsAPI.dispatchMessage", &message_value, NULL, |
| 471 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); | 471 NULL); |
| 472 return; | 472 return; |
| 473 } | 473 } |
| 474 | 474 |
| 475 base::FundamentalValue total_size(static_cast<int>(message.length())); | 475 base::FundamentalValue total_size(static_cast<int>(message.length())); |
| 476 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { | 476 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { |
| 477 base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize)); | 477 base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize)); |
| 478 CallClientFunction("DevToolsAPI.dispatchMessageChunk", | 478 CallClientFunction("DevToolsAPI.dispatchMessageChunk", |
| 479 &message_value, pos ? NULL : &total_size, NULL); | 479 &message_value, pos ? NULL : &total_size, NULL); |
| 480 } | 480 } |
| 481 } | 481 } |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 void DevToolsUIBindings::FrontendLoaded() { | 1089 void DevToolsUIBindings::FrontendLoaded() { |
| 1090 if (frontend_loaded_) | 1090 if (frontend_loaded_) |
| 1091 return; | 1091 return; |
| 1092 frontend_loaded_ = true; | 1092 frontend_loaded_ = true; |
| 1093 | 1093 |
| 1094 // Call delegate first - it seeds importants bit of information. | 1094 // Call delegate first - it seeds importants bit of information. |
| 1095 delegate_->OnLoadCompleted(); | 1095 delegate_->OnLoadCompleted(); |
| 1096 | 1096 |
| 1097 AddDevToolsExtensionsToClient(); | 1097 AddDevToolsExtensionsToClient(); |
| 1098 } | 1098 } |
| OLD | NEW |