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

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

Issue 2515903002: DevTools: webui receives document load message upon navigation, even for cross-domain navigations. … (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/scripts/chrome_debug_launcher/launch_chrome.js » ('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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 DevToolsUIBindingsList* instances = g_instances.Pointer(); 443 DevToolsUIBindingsList* instances = g_instances.Pointer();
444 DevToolsUIBindingsList::iterator it( 444 DevToolsUIBindingsList::iterator it(
445 std::find(instances->begin(), instances->end(), this)); 445 std::find(instances->begin(), instances->end(), this));
446 DCHECK(it != instances->end()); 446 DCHECK(it != instances->end());
447 instances->erase(it); 447 instances->erase(it);
448 } 448 }
449 449
450 // content::DevToolsFrontendHost::Delegate implementation --------------------- 450 // content::DevToolsFrontendHost::Delegate implementation ---------------------
451 void DevToolsUIBindings::HandleMessageFromDevToolsFrontend( 451 void DevToolsUIBindings::HandleMessageFromDevToolsFrontend(
452 const std::string& message) { 452 const std::string& message) {
453 if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme))
454 return;
453 std::string method; 455 std::string method;
454 base::ListValue empty_params; 456 base::ListValue empty_params;
455 base::ListValue* params = &empty_params; 457 base::ListValue* params = &empty_params;
456 458
457 base::DictionaryValue* dict = NULL; 459 base::DictionaryValue* dict = NULL;
458 std::unique_ptr<base::Value> parsed_message = base::JSONReader::Read(message); 460 std::unique_ptr<base::Value> parsed_message = base::JSONReader::Read(message);
459 if (!parsed_message || 461 if (!parsed_message ||
460 !parsed_message->GetAsDictionary(&dict) || 462 !parsed_message->GetAsDictionary(&dict) ||
461 !dict->GetString(kFrontendHostMethod, &method) || 463 !dict->GetString(kFrontendHostMethod, &method) ||
462 (dict->HasKey(kFrontendHostParams) && 464 (dict->HasKey(kFrontendHostParams) &&
463 !dict->GetList(kFrontendHostParams, &params))) { 465 !dict->GetList(kFrontendHostParams, &params))) {
464 LOG(ERROR) << "Invalid message was sent to embedder: " << message; 466 LOG(ERROR) << "Invalid message was sent to embedder: " << message;
465 return; 467 return;
466 } 468 }
467 int id = 0; 469 int id = 0;
468 dict->GetInteger(kFrontendHostId, &id); 470 dict->GetInteger(kFrontendHostId, &id);
469 embedder_message_dispatcher_->Dispatch( 471 embedder_message_dispatcher_->Dispatch(
470 base::Bind(&DevToolsUIBindings::SendMessageAck, 472 base::Bind(&DevToolsUIBindings::SendMessageAck,
471 weak_factory_.GetWeakPtr(), 473 weak_factory_.GetWeakPtr(),
472 id), 474 id),
473 method, 475 method,
474 params); 476 params);
475 } 477 }
476 478
477 // content::DevToolsAgentHostClient implementation -------------------------- 479 // content::DevToolsAgentHostClient implementation --------------------------
478 void DevToolsUIBindings::DispatchProtocolMessage( 480 void DevToolsUIBindings::DispatchProtocolMessage(
479 content::DevToolsAgentHost* agent_host, const std::string& message) { 481 content::DevToolsAgentHost* agent_host, const std::string& message) {
480 DCHECK(agent_host == agent_host_.get()); 482 DCHECK(agent_host == agent_host_.get());
483 if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme))
484 return;
481 485
482 if (message.length() < kMaxMessageChunkSize) { 486 if (message.length() < kMaxMessageChunkSize) {
483 std::string param; 487 std::string param;
484 base::EscapeJSONString(message, true, &param); 488 base::EscapeJSONString(message, true, &param);
485 base::string16 javascript = 489 base::string16 javascript =
486 base::UTF8ToUTF16("DevToolsAPI.dispatchMessage(" + param + ");"); 490 base::UTF8ToUTF16("DevToolsAPI.dispatchMessage(" + param + ");");
487 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); 491 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript);
488 return; 492 return;
489 } 493 }
490 494
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 } 1132 }
1129 1133
1130 bool DevToolsUIBindings::IsAttachedTo(content::DevToolsAgentHost* agent_host) { 1134 bool DevToolsUIBindings::IsAttachedTo(content::DevToolsAgentHost* agent_host) {
1131 return agent_host_.get() == agent_host; 1135 return agent_host_.get() == agent_host;
1132 } 1136 }
1133 1137
1134 void DevToolsUIBindings::CallClientFunction(const std::string& function_name, 1138 void DevToolsUIBindings::CallClientFunction(const std::string& function_name,
1135 const base::Value* arg1, 1139 const base::Value* arg1,
1136 const base::Value* arg2, 1140 const base::Value* arg2,
1137 const base::Value* arg3) { 1141 const base::Value* arg3) {
1142 if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme))
1143 return;
1138 std::string javascript = function_name + "("; 1144 std::string javascript = function_name + "(";
1139 if (arg1) { 1145 if (arg1) {
1140 std::string json; 1146 std::string json;
1141 base::JSONWriter::Write(*arg1, &json); 1147 base::JSONWriter::Write(*arg1, &json);
1142 javascript.append(json); 1148 javascript.append(json);
1143 if (arg2) { 1149 if (arg2) {
1144 base::JSONWriter::Write(*arg2, &json); 1150 base::JSONWriter::Write(*arg2, &json);
1145 javascript.append(", ").append(json); 1151 javascript.append(", ").append(json);
1146 if (arg3) { 1152 if (arg3) {
1147 base::JSONWriter::Write(*arg3, &json); 1153 base::JSONWriter::Write(*arg3, &json);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 void DevToolsUIBindings::FrontendLoaded() { 1186 void DevToolsUIBindings::FrontendLoaded() {
1181 if (frontend_loaded_) 1187 if (frontend_loaded_)
1182 return; 1188 return;
1183 frontend_loaded_ = true; 1189 frontend_loaded_ = true;
1184 1190
1185 // Call delegate first - it seeds importants bit of information. 1191 // Call delegate first - it seeds importants bit of information.
1186 delegate_->OnLoadCompleted(); 1192 delegate_->OnLoadCompleted();
1187 1193
1188 AddDevToolsExtensionsToClient(); 1194 AddDevToolsExtensionsToClient();
1189 } 1195 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/scripts/chrome_debug_launcher/launch_chrome.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698