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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 400 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
401 content::Source<Profile>(profile_)); | 401 content::Source<Profile>(profile_)); |
402 | 402 |
403 // RVH-based agents disconnect from their clients when the app is terminating | 403 // RVH-based agents disconnect from their clients when the app is terminating |
404 // but shared worker-based agents do not. | 404 // but shared worker-based agents do not. |
405 // Disconnect explicitly to make sure that |this| observer is not leaked. | 405 // Disconnect explicitly to make sure that |this| observer is not leaked. |
406 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 406 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
407 content::NotificationService::AllSources()); | 407 content::NotificationService::AllSources()); |
408 | 408 |
409 // Attach to debugger and tell it we are ready. | 409 // Attach to debugger and tell it we are ready. |
410 DevToolsManager::GetInstance()-> | 410 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
411 RegisterDevToolsClientHostFor(agent_host_, this); | 411 agent_host_.get(), this); |
412 | 412 |
413 if (infobar_delegate_) { | 413 if (infobar_delegate_) { |
414 infobar_delegate_->AttachClientHost(this); | 414 infobar_delegate_->AttachClientHost(this); |
415 registrar_.Add( | 415 registrar_.Add( |
416 this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 416 this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
417 content::Source<InfoBarService>(InfoBarService::FromWebContents( | 417 content::Source<InfoBarService>(InfoBarService::FromWebContents( |
418 WebContents::FromRenderViewHost( | 418 WebContents::FromRenderViewHost( |
419 agent_host_->GetRenderViewHost())))); | 419 agent_host_->GetRenderViewHost())))); |
420 } | 420 } |
421 } | 421 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 if (dictionary->GetDictionary("params", ¶ms_value)) | 530 if (dictionary->GetDictionary("params", ¶ms_value)) |
531 params.additional_properties.Swap(params_value); | 531 params.additional_properties.Swap(params_value); |
532 | 532 |
533 scoped_ptr<ListValue> args(OnEvent::Create(debuggee_, method_name, params)); | 533 scoped_ptr<ListValue> args(OnEvent::Create(debuggee_, method_name, params)); |
534 scoped_ptr<extensions::Event> event(new extensions::Event( | 534 scoped_ptr<extensions::Event> event(new extensions::Event( |
535 keys::kOnEvent, args.Pass())); | 535 keys::kOnEvent, args.Pass())); |
536 event->restrict_to_profile = profile_; | 536 event->restrict_to_profile = profile_; |
537 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 537 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
538 DispatchEventToExtension(extension_id_, event.Pass()); | 538 DispatchEventToExtension(extension_id_, event.Pass()); |
539 } else { | 539 } else { |
540 DebuggerSendCommandFunction* function = pending_requests_[id]; | 540 DebuggerSendCommandFunction* function = pending_requests_[id].get(); |
541 if (!function) | 541 if (!function) |
542 return; | 542 return; |
543 | 543 |
544 function->SendResponseBody(dictionary); | 544 function->SendResponseBody(dictionary); |
545 pending_requests_.erase(id); | 545 pending_requests_.erase(id); |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 | 549 |
550 // DebuggerFunction ----------------------------------------------------------- | 550 // DebuggerFunction ----------------------------------------------------------- |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 agent_host_ = DevToolsAgentHost::GetOrCreateFor( | 592 agent_host_ = DevToolsAgentHost::GetOrCreateFor( |
593 extension_host->render_view_host()); | 593 extension_host->render_view_host()); |
594 } | 594 } |
595 } else if (debuggee_.target_id) { | 595 } else if (debuggee_.target_id) { |
596 agent_host_ = DevToolsAgentHost::GetForId(*debuggee_.target_id); | 596 agent_host_ = DevToolsAgentHost::GetForId(*debuggee_.target_id); |
597 } else { | 597 } else { |
598 error_ = keys::kInvalidTargetError; | 598 error_ = keys::kInvalidTargetError; |
599 return false; | 599 return false; |
600 } | 600 } |
601 | 601 |
602 if (!agent_host_) { | 602 if (!agent_host_.get()) { |
603 FormatErrorMessage(keys::kNoTargetError); | 603 FormatErrorMessage(keys::kNoTargetError); |
604 return false; | 604 return false; |
605 } | 605 } |
606 return true; | 606 return true; |
607 } | 607 } |
608 | 608 |
609 bool DebuggerFunction::InitClientHost() { | 609 bool DebuggerFunction::InitClientHost() { |
610 if (!InitAgentHost()) | 610 if (!InitAgentHost()) |
611 return false; | 611 return false; |
612 | 612 |
613 client_host_ = AttachedClientHosts::GetInstance()-> | 613 client_host_ = AttachedClientHosts::GetInstance()->Lookup( |
614 Lookup(agent_host_, GetExtension()->id()); | 614 agent_host_.get(), GetExtension()->id()); |
615 | 615 |
616 if (!client_host_) { | 616 if (!client_host_) { |
617 FormatErrorMessage(keys::kNotAttachedError); | 617 FormatErrorMessage(keys::kNotAttachedError); |
618 return false; | 618 return false; |
619 } | 619 } |
620 return true; | 620 return true; |
621 } | 621 } |
622 | 622 |
623 | 623 |
624 // DebuggerAttachFunction ----------------------------------------------------- | 624 // DebuggerAttachFunction ----------------------------------------------------- |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 agent_host_->GetRenderViewHost(), GetExtension()->name()); | 658 agent_host_->GetRenderViewHost(), GetExtension()->name()); |
659 if (!infobar_delegate) { | 659 if (!infobar_delegate) { |
660 error_ = ErrorUtils::FormatErrorMessage( | 660 error_ = ErrorUtils::FormatErrorMessage( |
661 keys::kSilentDebuggingRequired, | 661 keys::kSilentDebuggingRequired, |
662 switches::kSilentDebuggerExtensionAPI); | 662 switches::kSilentDebuggerExtensionAPI); |
663 return false; | 663 return false; |
664 } | 664 } |
665 } | 665 } |
666 | 666 |
667 new ExtensionDevToolsClientHost(profile(), | 667 new ExtensionDevToolsClientHost(profile(), |
668 agent_host_, | 668 agent_host_.get(), |
669 GetExtension()->id(), | 669 GetExtension()->id(), |
670 GetExtension()->name(), | 670 GetExtension()->name(), |
671 debuggee_, | 671 debuggee_, |
672 infobar_delegate); | 672 infobar_delegate); |
673 SendResponse(true); | 673 SendResponse(true); |
674 return true; | 674 return true; |
675 } | 675 } |
676 | 676 |
677 | 677 |
678 // DebuggerDetachFunction ----------------------------------------------------- | 678 // DebuggerDetachFunction ----------------------------------------------------- |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 WorkerService::GetInstance()->GetWorkers(); | 768 WorkerService::GetInstance()->GetWorkers(); |
769 | 769 |
770 for (size_t i = 0; i < worker_info.size(); ++i) | 770 for (size_t i = 0; i < worker_info.size(); ++i) |
771 list->Append(SerializeWorkerInfo(worker_info[i])); | 771 list->Append(SerializeWorkerInfo(worker_info[i])); |
772 } | 772 } |
773 | 773 |
774 void DebuggerGetTargetsFunction::SendTargetList(base::ListValue* list) { | 774 void DebuggerGetTargetsFunction::SendTargetList(base::ListValue* list) { |
775 SetResult(list); | 775 SetResult(list); |
776 SendResponse(true); | 776 SendResponse(true); |
777 } | 777 } |
OLD | NEW |