OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Implements the Chrome Extensions Debugger API. | 5 // Implements the Chrome Extensions Debugger API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/debugger/debugger_api.h" | 7 #include "chrome/browser/extensions/api/debugger/debugger_api.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 447 |
448 void ExtensionDevToolsClientHost::Close() { | 448 void ExtensionDevToolsClientHost::Close() { |
449 DevToolsManager::GetInstance()->ClientHostClosing(this); | 449 DevToolsManager::GetInstance()->ClientHostClosing(this); |
450 delete this; | 450 delete this; |
451 } | 451 } |
452 | 452 |
453 void ExtensionDevToolsClientHost::SendMessageToBackend( | 453 void ExtensionDevToolsClientHost::SendMessageToBackend( |
454 DebuggerSendCommandFunction* function, | 454 DebuggerSendCommandFunction* function, |
455 const std::string& method, | 455 const std::string& method, |
456 SendCommand::Params::CommandParams* command_params) { | 456 SendCommand::Params::CommandParams* command_params) { |
457 DictionaryValue protocol_request; | 457 base::DictionaryValue protocol_request; |
458 int request_id = ++last_request_id_; | 458 int request_id = ++last_request_id_; |
459 pending_requests_[request_id] = function; | 459 pending_requests_[request_id] = function; |
460 protocol_request.SetInteger("id", request_id); | 460 protocol_request.SetInteger("id", request_id); |
461 protocol_request.SetString("method", method); | 461 protocol_request.SetString("method", method); |
462 if (command_params) { | 462 if (command_params) { |
463 protocol_request.Set("params", | 463 protocol_request.Set("params", |
464 command_params->additional_properties.DeepCopy()); | 464 command_params->additional_properties.DeepCopy()); |
465 } | 465 } |
466 | 466 |
467 std::string json_args; | 467 std::string json_args; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 } | 510 } |
511 | 511 |
512 void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( | 512 void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( |
513 const std::string& message) { | 513 const std::string& message) { |
514 if (!extensions::ExtensionSystem::Get(profile_)->event_router()) | 514 if (!extensions::ExtensionSystem::Get(profile_)->event_router()) |
515 return; | 515 return; |
516 | 516 |
517 scoped_ptr<Value> result(base::JSONReader::Read(message)); | 517 scoped_ptr<Value> result(base::JSONReader::Read(message)); |
518 if (!result->IsType(Value::TYPE_DICTIONARY)) | 518 if (!result->IsType(Value::TYPE_DICTIONARY)) |
519 return; | 519 return; |
520 DictionaryValue* dictionary = static_cast<DictionaryValue*>(result.get()); | 520 base::DictionaryValue* dictionary = |
| 521 static_cast<base::DictionaryValue*>(result.get()); |
521 | 522 |
522 int id; | 523 int id; |
523 if (!dictionary->GetInteger("id", &id)) { | 524 if (!dictionary->GetInteger("id", &id)) { |
524 std::string method_name; | 525 std::string method_name; |
525 if (!dictionary->GetString("method", &method_name)) | 526 if (!dictionary->GetString("method", &method_name)) |
526 return; | 527 return; |
527 | 528 |
528 OnEvent::Params params; | 529 OnEvent::Params params; |
529 DictionaryValue* params_value; | 530 base::DictionaryValue* params_value; |
530 if (dictionary->GetDictionary("params", ¶ms_value)) | 531 if (dictionary->GetDictionary("params", ¶ms_value)) |
531 params.additional_properties.Swap(params_value); | 532 params.additional_properties.Swap(params_value); |
532 | 533 |
533 scoped_ptr<ListValue> args(OnEvent::Create(debuggee_, method_name, params)); | 534 scoped_ptr<ListValue> args(OnEvent::Create(debuggee_, method_name, params)); |
534 scoped_ptr<extensions::Event> event(new extensions::Event( | 535 scoped_ptr<extensions::Event> event(new extensions::Event( |
535 keys::kOnEvent, args.Pass())); | 536 keys::kOnEvent, args.Pass())); |
536 event->restrict_to_profile = profile_; | 537 event->restrict_to_profile = profile_; |
537 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 538 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
538 DispatchEventToExtension(extension_id_, event.Pass()); | 539 DispatchEventToExtension(extension_id_, event.Pass()); |
539 } else { | 540 } else { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 CopyDebuggee(debuggee_, params->target); | 709 CopyDebuggee(debuggee_, params->target); |
709 if (!InitClientHost()) | 710 if (!InitClientHost()) |
710 return false; | 711 return false; |
711 | 712 |
712 client_host_->SendMessageToBackend(this, params->method, | 713 client_host_->SendMessageToBackend(this, params->method, |
713 params->command_params.get()); | 714 params->command_params.get()); |
714 return true; | 715 return true; |
715 } | 716 } |
716 | 717 |
717 void DebuggerSendCommandFunction::SendResponseBody( | 718 void DebuggerSendCommandFunction::SendResponseBody( |
718 DictionaryValue* response) { | 719 base::DictionaryValue* response) { |
719 Value* error_body; | 720 Value* error_body; |
720 if (response->Get("error", &error_body)) { | 721 if (response->Get("error", &error_body)) { |
721 base::JSONWriter::Write(error_body, &error_); | 722 base::JSONWriter::Write(error_body, &error_); |
722 SendResponse(false); | 723 SendResponse(false); |
723 return; | 724 return; |
724 } | 725 } |
725 | 726 |
726 DictionaryValue* result_body; | 727 base::DictionaryValue* result_body; |
727 SendCommand::Results::Result result; | 728 SendCommand::Results::Result result; |
728 if (response->GetDictionary("result", &result_body)) | 729 if (response->GetDictionary("result", &result_body)) |
729 result.additional_properties.Swap(result_body); | 730 result.additional_properties.Swap(result_body); |
730 | 731 |
731 results_ = SendCommand::Results::Create(result); | 732 results_ = SendCommand::Results::Create(result); |
732 SendResponse(true); | 733 SendResponse(true); |
733 } | 734 } |
734 | 735 |
735 | 736 |
736 // DebuggerGetTargetsFunction ------------------------------------------------- | 737 // DebuggerGetTargetsFunction ------------------------------------------------- |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 WorkerService::GetInstance()->GetWorkers(); | 769 WorkerService::GetInstance()->GetWorkers(); |
769 | 770 |
770 for (size_t i = 0; i < worker_info.size(); ++i) | 771 for (size_t i = 0; i < worker_info.size(); ++i) |
771 list->Append(SerializeWorkerInfo(worker_info[i])); | 772 list->Append(SerializeWorkerInfo(worker_info[i])); |
772 } | 773 } |
773 | 774 |
774 void DebuggerGetTargetsFunction::SendTargetList(base::ListValue* list) { | 775 void DebuggerGetTargetsFunction::SendTargetList(base::ListValue* list) { |
775 SetResult(list); | 776 SetResult(list); |
776 SendResponse(true); | 777 SendResponse(true); |
777 } | 778 } |
OLD | NEW |