Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: chrome/browser/devtools/devtools_ui_bindings.cc

Issue 418243003: [DevTools] Move DispatchOnDevToolsFrontend to embedder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/devtools/devtools_frontend_host_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 402
403 void DevToolsUIBindings::HandleMessageFromDevToolsFrontendToBackend( 403 void DevToolsUIBindings::HandleMessageFromDevToolsFrontendToBackend(
404 const std::string& message) { 404 const std::string& message) {
405 content::DevToolsManager::GetInstance()->DispatchOnInspectorBackend( 405 content::DevToolsManager::GetInstance()->DispatchOnInspectorBackend(
406 this, message); 406 this, message);
407 } 407 }
408 408
409 // content::DevToolsClientHost implementation --------------------------------- 409 // content::DevToolsClientHost implementation ---------------------------------
410 void DevToolsUIBindings::DispatchOnInspectorFrontend( 410 void DevToolsUIBindings::DispatchOnInspectorFrontend(
411 const std::string& message) { 411 const std::string& message) {
412 if (frontend_host_) 412 base::StringValue message_value(message);
413 frontend_host_->DispatchOnDevToolsFrontend(message); 413 CallClientFunction("InspectorFrontendAPI.dispatchMessage",
414 &message_value, NULL, NULL);
414 } 415 }
415 416
416 void DevToolsUIBindings::InspectedContentsClosing() { 417 void DevToolsUIBindings::InspectedContentsClosing() {
417 delegate_->InspectedContentsClosing(); 418 delegate_->InspectedContentsClosing();
418 } 419 }
419 420
420 void DevToolsUIBindings::ReplacedWithAnotherClient() { 421 void DevToolsUIBindings::ReplacedWithAnotherClient() {
421 } 422 }
422 423
423 // DevToolsEmbedderMessageDispatcher::Delegate implementation ----------------- 424 // DevToolsEmbedderMessageDispatcher::Delegate implementation -----------------
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 params.append(json); 790 params.append(json);
790 if (arg2) { 791 if (arg2) {
791 base::JSONWriter::Write(arg2, &json); 792 base::JSONWriter::Write(arg2, &json);
792 params.append(", " + json); 793 params.append(", " + json);
793 if (arg3) { 794 if (arg3) {
794 base::JSONWriter::Write(arg3, &json); 795 base::JSONWriter::Write(arg3, &json);
795 params.append(", " + json); 796 params.append(", " + json);
796 } 797 }
797 } 798 }
798 } 799 }
799 base::string16 javascript = 800
800 base::UTF8ToUTF16(function_name + "(" + params + ");"); 801 std::string code = function_name + "(" + params + ");";
802 #if defined(DEBUG_DEVTOOLS)
803 // To debug DevTools itself, we should postpone incoming messages while
804 // paused in debugger. To achieve this, we wrap all calls in setTimeout
805 // and rely on the fact that timers are suspended when debugging.
806 code = "(function() {"
807 " 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.
808 ""
809 " function executeCall() {" + code + "}"
810 ""
811 " function onTimeout() {"
812 " while (window.__callClientFunction.length) {"
813 " window.__callClientFunction.shift()();"
814 " }"
815 " }"
816 ""
817 " window.__callClientFunction.push(executeCall);"
818 " if (window.__callClientFunction.length == 1)"
819 " window.setTimeout(onTimeout, 0);"
820 "})();";
821 #endif // defined(DEBUG_DEVTOOLS)
822
823 base::string16 javascript = base::UTF8ToUTF16(code);
801 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); 824 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript);
802 } 825 }
803 826
804 void DevToolsUIBindings::DocumentOnLoadCompletedInMainFrame() { 827 void DevToolsUIBindings::DocumentOnLoadCompletedInMainFrame() {
805 // Call delegate first - it seeds importants bit of information. 828 // Call delegate first - it seeds importants bit of information.
806 delegate_->OnLoadCompleted(); 829 delegate_->OnLoadCompleted();
807 830
808 UpdateTheme(); 831 UpdateTheme();
809 AddDevToolsExtensionsToClient(); 832 AddDevToolsExtensionsToClient();
810 } 833 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/devtools/devtools_frontend_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698