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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 Close(); | 414 Close(); |
415 } | 415 } |
416 } | 416 } |
417 } | 417 } |
418 | 418 |
419 void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( | 419 void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( |
420 const std::string& message) { | 420 const std::string& message) { |
421 if (!extensions::ExtensionSystem::Get(profile_)->event_router()) | 421 if (!extensions::ExtensionSystem::Get(profile_)->event_router()) |
422 return; | 422 return; |
423 | 423 |
424 scoped_ptr<Value> result(base::JSONReader::Read(message)); | 424 scoped_ptr<base::Value> result(base::JSONReader::Read(message)); |
425 if (!result->IsType(Value::TYPE_DICTIONARY)) | 425 if (!result->IsType(base::Value::TYPE_DICTIONARY)) |
426 return; | 426 return; |
427 base::DictionaryValue* dictionary = | 427 base::DictionaryValue* dictionary = |
428 static_cast<base::DictionaryValue*>(result.get()); | 428 static_cast<base::DictionaryValue*>(result.get()); |
429 | 429 |
430 int id; | 430 int id; |
431 if (!dictionary->GetInteger("id", &id)) { | 431 if (!dictionary->GetInteger("id", &id)) { |
432 std::string method_name; | 432 std::string method_name; |
433 if (!dictionary->GetString("method", &method_name)) | 433 if (!dictionary->GetString("method", &method_name)) |
434 return; | 434 return; |
435 | 435 |
436 OnEvent::Params params; | 436 OnEvent::Params params; |
437 base::DictionaryValue* params_value; | 437 base::DictionaryValue* params_value; |
438 if (dictionary->GetDictionary("params", ¶ms_value)) | 438 if (dictionary->GetDictionary("params", ¶ms_value)) |
439 params.additional_properties.Swap(params_value); | 439 params.additional_properties.Swap(params_value); |
440 | 440 |
441 scoped_ptr<ListValue> args(OnEvent::Create(debuggee_, method_name, params)); | 441 scoped_ptr<base::ListValue> args( |
| 442 OnEvent::Create(debuggee_, method_name, params)); |
442 scoped_ptr<extensions::Event> event(new extensions::Event( | 443 scoped_ptr<extensions::Event> event(new extensions::Event( |
443 OnEvent::kEventName, args.Pass())); | 444 OnEvent::kEventName, args.Pass())); |
444 event->restrict_to_browser_context = profile_; | 445 event->restrict_to_browser_context = profile_; |
445 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 446 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
446 DispatchEventToExtension(extension_id_, event.Pass()); | 447 DispatchEventToExtension(extension_id_, event.Pass()); |
447 } else { | 448 } else { |
448 DebuggerSendCommandFunction* function = pending_requests_[id].get(); | 449 DebuggerSendCommandFunction* function = pending_requests_[id].get(); |
449 if (!function) | 450 if (!function) |
450 return; | 451 return; |
451 | 452 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 if (!InitClientHost()) | 628 if (!InitClientHost()) |
628 return false; | 629 return false; |
629 | 630 |
630 client_host_->SendMessageToBackend(this, params->method, | 631 client_host_->SendMessageToBackend(this, params->method, |
631 params->command_params.get()); | 632 params->command_params.get()); |
632 return true; | 633 return true; |
633 } | 634 } |
634 | 635 |
635 void DebuggerSendCommandFunction::SendResponseBody( | 636 void DebuggerSendCommandFunction::SendResponseBody( |
636 base::DictionaryValue* response) { | 637 base::DictionaryValue* response) { |
637 Value* error_body; | 638 base::Value* error_body; |
638 if (response->Get("error", &error_body)) { | 639 if (response->Get("error", &error_body)) { |
639 base::JSONWriter::Write(error_body, &error_); | 640 base::JSONWriter::Write(error_body, &error_); |
640 SendResponse(false); | 641 SendResponse(false); |
641 return; | 642 return; |
642 } | 643 } |
643 | 644 |
644 base::DictionaryValue* result_body; | 645 base::DictionaryValue* result_body; |
645 SendCommand::Results::Result result; | 646 SendCommand::Results::Result result; |
646 if (response->GetDictionary("result", &result_body)) | 647 if (response->GetDictionary("result", &result_body)) |
647 result.additional_properties.Swap(result_body); | 648 result.additional_properties.Swap(result_body); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 | 711 |
711 void DebuggerGetTargetsFunction::SendTargetList( | 712 void DebuggerGetTargetsFunction::SendTargetList( |
712 const std::vector<DevToolsTargetImpl*>& target_list) { | 713 const std::vector<DevToolsTargetImpl*>& target_list) { |
713 scoped_ptr<base::ListValue> result(new base::ListValue()); | 714 scoped_ptr<base::ListValue> result(new base::ListValue()); |
714 for (size_t i = 0; i < target_list.size(); ++i) | 715 for (size_t i = 0; i < target_list.size(); ++i) |
715 result->Append(SerializeTarget(*target_list[i])); | 716 result->Append(SerializeTarget(*target_list[i])); |
716 STLDeleteContainerPointers(target_list.begin(), target_list.end()); | 717 STLDeleteContainerPointers(target_list.begin(), target_list.end()); |
717 SetResult(result.release()); | 718 SetResult(result.release()); |
718 SendResponse(true); | 719 SendResponse(true); |
719 } | 720 } |
OLD | NEW |