Chromium Code Reviews| Index: chrome/browser/devtools/devtools_ui_bindings.cc |
| diff --git a/chrome/browser/devtools/devtools_ui_bindings.cc b/chrome/browser/devtools/devtools_ui_bindings.cc |
| index e87b70a0f5533e5693e52b41b5467d94cfb46224..7441341915dcd449e82ca902afdac6ddc63a1b5b 100644 |
| --- a/chrome/browser/devtools/devtools_ui_bindings.cc |
| +++ b/chrome/browser/devtools/devtools_ui_bindings.cc |
| @@ -409,8 +409,9 @@ void DevToolsUIBindings::HandleMessageFromDevToolsFrontendToBackend( |
| // content::DevToolsClientHost implementation --------------------------------- |
| void DevToolsUIBindings::DispatchOnInspectorFrontend( |
| const std::string& message) { |
| - if (frontend_host_) |
| - frontend_host_->DispatchOnDevToolsFrontend(message); |
| + base::StringValue message_value(message); |
| + CallClientFunction("InspectorFrontendAPI.dispatchMessage", |
| + &message_value, NULL, NULL); |
| } |
| void DevToolsUIBindings::InspectedContentsClosing() { |
| @@ -796,8 +797,30 @@ void DevToolsUIBindings::CallClientFunction(const std::string& function_name, |
| } |
| } |
| } |
| - base::string16 javascript = |
| - base::UTF8ToUTF16(function_name + "(" + params + ");"); |
| + |
| + std::string code = function_name + "(" + params + ");"; |
| +#if defined(DEBUG_DEVTOOLS) |
| + // To debug DevTools itself, we should postpone incoming messages while |
| + // paused in debugger. To achieve this, we wrap all calls in setTimeout |
| + // and rely on the fact that timers are suspended when debugging. |
| + code = "(function() {" |
| + " if (!window.__callClientFunction) window.__callClientFunction = [];" |
|
pfeldman
2014/07/31 14:25:08
Should we do this on the front-end side instead?
dgozman
2014/07/31 15:09:32
Done.
|
| + "" |
| + " function executeCall() {" + code + "}" |
| + "" |
| + " function onTimeout() {" |
| + " while (window.__callClientFunction.length) {" |
| + " window.__callClientFunction.shift()();" |
| + " }" |
| + " }" |
| + "" |
| + " window.__callClientFunction.push(executeCall);" |
| + " if (window.__callClientFunction.length == 1)" |
| + " window.setTimeout(onTimeout, 0);" |
| + "})();"; |
| +#endif // defined(DEBUG_DEVTOOLS) |
| + |
| + base::string16 javascript = base::UTF8ToUTF16(code); |
| web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); |
| } |