| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 agent_host_(agent_host), | 300 agent_host_(agent_host), |
| 301 extension_id_(extension_id), | 301 extension_id_(extension_id), |
| 302 last_request_id_(0), | 302 last_request_id_(0), |
| 303 infobar_(infobar), | 303 infobar_(infobar), |
| 304 detach_reason_(OnDetach::REASON_TARGET_CLOSED) { | 304 detach_reason_(OnDetach::REASON_TARGET_CLOSED) { |
| 305 CopyDebuggee(&debuggee_, debuggee); | 305 CopyDebuggee(&debuggee_, debuggee); |
| 306 | 306 |
| 307 AttachedClientHosts::GetInstance()->Add(this); | 307 AttachedClientHosts::GetInstance()->Add(this); |
| 308 | 308 |
| 309 // Detach from debugger when extension unloads. | 309 // Detach from debugger when extension unloads. |
| 310 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 310 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 311 content::Source<Profile>(profile_)); | 311 content::Source<Profile>(profile_)); |
| 312 | 312 |
| 313 // RVH-based agents disconnect from their clients when the app is terminating | 313 // RVH-based agents disconnect from their clients when the app is terminating |
| 314 // but shared worker-based agents do not. | 314 // but shared worker-based agents do not. |
| 315 // Disconnect explicitly to make sure that |this| observer is not leaked. | 315 // Disconnect explicitly to make sure that |this| observer is not leaked. |
| 316 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 316 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
| 317 content::NotificationService::AllSources()); | 317 content::NotificationService::AllSources()); |
| 318 | 318 |
| 319 // Attach to debugger and tell it we are ready. | 319 // Attach to debugger and tell it we are ready. |
| 320 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( | 320 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 OnDetach::kEventName, args.Pass())); | 393 OnDetach::kEventName, args.Pass())); |
| 394 event->restrict_to_browser_context = profile_; | 394 event->restrict_to_browser_context = profile_; |
| 395 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 395 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
| 396 DispatchEventToExtension(extension_id_, event.Pass()); | 396 DispatchEventToExtension(extension_id_, event.Pass()); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void ExtensionDevToolsClientHost::Observe( | 399 void ExtensionDevToolsClientHost::Observe( |
| 400 int type, | 400 int type, |
| 401 const content::NotificationSource& source, | 401 const content::NotificationSource& source, |
| 402 const content::NotificationDetails& details) { | 402 const content::NotificationDetails& details) { |
| 403 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { | 403 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) { |
| 404 if (content::Details<extensions::UnloadedExtensionInfo>(details)-> | 404 if (content::Details<extensions::UnloadedExtensionInfo>(details)-> |
| 405 extension->id() == extension_id_) | 405 extension->id() == extension_id_) |
| 406 Close(); | 406 Close(); |
| 407 } else if (type == chrome::NOTIFICATION_APP_TERMINATING) { | 407 } else if (type == chrome::NOTIFICATION_APP_TERMINATING) { |
| 408 Close(); | 408 Close(); |
| 409 } else { | 409 } else { |
| 410 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); | 410 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); |
| 411 if (content::Details<InfoBar::RemovedDetails>(details)->first == infobar_) { | 411 if (content::Details<InfoBar::RemovedDetails>(details)->first == infobar_) { |
| 412 infobar_ = NULL; | 412 infobar_ = NULL; |
| 413 SendDetachedEvent(); | 413 SendDetachedEvent(); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 | 711 |
| 712 void DebuggerGetTargetsFunction::SendTargetList( | 712 void DebuggerGetTargetsFunction::SendTargetList( |
| 713 const std::vector<DevToolsTargetImpl*>& target_list) { | 713 const std::vector<DevToolsTargetImpl*>& target_list) { |
| 714 scoped_ptr<base::ListValue> result(new base::ListValue()); | 714 scoped_ptr<base::ListValue> result(new base::ListValue()); |
| 715 for (size_t i = 0; i < target_list.size(); ++i) | 715 for (size_t i = 0; i < target_list.size(); ++i) |
| 716 result->Append(SerializeTarget(*target_list[i])); | 716 result->Append(SerializeTarget(*target_list[i])); |
| 717 STLDeleteContainerPointers(target_list.begin(), target_list.end()); | 717 STLDeleteContainerPointers(target_list.begin(), target_list.end()); |
| 718 SetResult(result.release()); | 718 SetResult(result.release()); |
| 719 SendResponse(true); | 719 SendResponse(true); |
| 720 } | 720 } |
| OLD | NEW |