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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 std::string json_args; | 378 std::string json_args; |
379 base::JSONWriter::Write(&protocol_request, &json_args); | 379 base::JSONWriter::Write(&protocol_request, &json_args); |
380 DevToolsManager::GetInstance()->DispatchOnInspectorBackend(this, json_args); | 380 DevToolsManager::GetInstance()->DispatchOnInspectorBackend(this, json_args); |
381 } | 381 } |
382 | 382 |
383 void ExtensionDevToolsClientHost::MarkAsDismissed() { | 383 void ExtensionDevToolsClientHost::MarkAsDismissed() { |
384 detach_reason_ = OnDetach::REASON_CANCELED_BY_USER; | 384 detach_reason_ = OnDetach::REASON_CANCELED_BY_USER; |
385 } | 385 } |
386 | 386 |
387 void ExtensionDevToolsClientHost::SendDetachedEvent() { | 387 void ExtensionDevToolsClientHost::SendDetachedEvent() { |
388 if (!extensions::ExtensionSystem::Get(profile_)->event_router()) | 388 if (!extensions::EventRouter::Get(profile_)) |
389 return; | 389 return; |
390 | 390 |
391 scoped_ptr<base::ListValue> args(OnDetach::Create(debuggee_, | 391 scoped_ptr<base::ListValue> args(OnDetach::Create(debuggee_, |
392 detach_reason_)); | 392 detach_reason_)); |
393 scoped_ptr<extensions::Event> event(new extensions::Event( | 393 scoped_ptr<extensions::Event> event(new extensions::Event( |
394 OnDetach::kEventName, args.Pass())); | 394 OnDetach::kEventName, args.Pass())); |
395 event->restrict_to_browser_context = profile_; | 395 event->restrict_to_browser_context = profile_; |
396 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 396 extensions::EventRouter::Get(profile_) |
397 DispatchEventToExtension(extension_id_, event.Pass()); | 397 ->DispatchEventToExtension(extension_id_, event.Pass()); |
398 } | 398 } |
399 | 399 |
400 void ExtensionDevToolsClientHost::Observe( | 400 void ExtensionDevToolsClientHost::Observe( |
401 int type, | 401 int type, |
402 const content::NotificationSource& source, | 402 const content::NotificationSource& source, |
403 const content::NotificationDetails& details) { | 403 const content::NotificationDetails& details) { |
404 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) { | 404 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) { |
405 if (content::Details<extensions::UnloadedExtensionInfo>(details)-> | 405 if (content::Details<extensions::UnloadedExtensionInfo>(details)-> |
406 extension->id() == extension_id_) | 406 extension->id() == extension_id_) |
407 Close(); | 407 Close(); |
408 } else if (type == chrome::NOTIFICATION_APP_TERMINATING) { | 408 } else if (type == chrome::NOTIFICATION_APP_TERMINATING) { |
409 Close(); | 409 Close(); |
410 } else { | 410 } else { |
411 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); | 411 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); |
412 if (content::Details<InfoBar::RemovedDetails>(details)->first == infobar_) { | 412 if (content::Details<InfoBar::RemovedDetails>(details)->first == infobar_) { |
413 infobar_ = NULL; | 413 infobar_ = NULL; |
414 SendDetachedEvent(); | 414 SendDetachedEvent(); |
415 Close(); | 415 Close(); |
416 } | 416 } |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
420 void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( | 420 void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( |
421 const std::string& message) { | 421 const std::string& message) { |
422 if (!extensions::ExtensionSystem::Get(profile_)->event_router()) | 422 if (!extensions::EventRouter::Get(profile_)) |
423 return; | 423 return; |
424 | 424 |
425 scoped_ptr<base::Value> result(base::JSONReader::Read(message)); | 425 scoped_ptr<base::Value> result(base::JSONReader::Read(message)); |
426 if (!result->IsType(base::Value::TYPE_DICTIONARY)) | 426 if (!result->IsType(base::Value::TYPE_DICTIONARY)) |
427 return; | 427 return; |
428 base::DictionaryValue* dictionary = | 428 base::DictionaryValue* dictionary = |
429 static_cast<base::DictionaryValue*>(result.get()); | 429 static_cast<base::DictionaryValue*>(result.get()); |
430 | 430 |
431 int id; | 431 int id; |
432 if (!dictionary->GetInteger("id", &id)) { | 432 if (!dictionary->GetInteger("id", &id)) { |
433 std::string method_name; | 433 std::string method_name; |
434 if (!dictionary->GetString("method", &method_name)) | 434 if (!dictionary->GetString("method", &method_name)) |
435 return; | 435 return; |
436 | 436 |
437 OnEvent::Params params; | 437 OnEvent::Params params; |
438 base::DictionaryValue* params_value; | 438 base::DictionaryValue* params_value; |
439 if (dictionary->GetDictionary("params", ¶ms_value)) | 439 if (dictionary->GetDictionary("params", ¶ms_value)) |
440 params.additional_properties.Swap(params_value); | 440 params.additional_properties.Swap(params_value); |
441 | 441 |
442 scoped_ptr<base::ListValue> args( | 442 scoped_ptr<base::ListValue> args( |
443 OnEvent::Create(debuggee_, method_name, params)); | 443 OnEvent::Create(debuggee_, method_name, params)); |
444 scoped_ptr<extensions::Event> event(new extensions::Event( | 444 scoped_ptr<extensions::Event> event(new extensions::Event( |
445 OnEvent::kEventName, args.Pass())); | 445 OnEvent::kEventName, args.Pass())); |
446 event->restrict_to_browser_context = profile_; | 446 event->restrict_to_browser_context = profile_; |
447 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 447 extensions::EventRouter::Get(profile_) |
448 DispatchEventToExtension(extension_id_, event.Pass()); | 448 ->DispatchEventToExtension(extension_id_, event.Pass()); |
449 } else { | 449 } else { |
450 DebuggerSendCommandFunction* function = pending_requests_[id].get(); | 450 DebuggerSendCommandFunction* function = pending_requests_[id].get(); |
451 if (!function) | 451 if (!function) |
452 return; | 452 return; |
453 | 453 |
454 function->SendResponseBody(dictionary); | 454 function->SendResponseBody(dictionary); |
455 pending_requests_.erase(id); | 455 pending_requests_.erase(id); |
456 } | 456 } |
457 } | 457 } |
458 | 458 |
(...skipping 252 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 |