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 <stddef.h> | 9 #include <stddef.h> |
10 | |
11 #include <map> | 10 #include <map> |
12 #include <set> | 11 #include <set> |
| 12 #include <utility> |
13 | 13 |
14 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/json/json_reader.h" | 16 #include "base/json/json_reader.h" |
17 #include "base/json/json_writer.h" | 17 #include "base/json/json_writer.h" |
18 #include "base/lazy_instance.h" | 18 #include "base/lazy_instance.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
21 #include "base/memory/singleton.h" | 21 #include "base/memory/singleton.h" |
22 #include "base/scoped_observer.h" | 22 #include "base/scoped_observer.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 const std::string& extension_name) | 204 const std::string& extension_name) |
205 : extension_id_(extension_id) { | 205 : extension_id_(extension_id) { |
206 g_extension_info_bars.Get()[extension_id] = this; | 206 g_extension_info_bars.Get()[extension_id] = this; |
207 | 207 |
208 // This class closes the |infobar_|, so it's safe to pass Unretained(this). | 208 // This class closes the |infobar_|, so it's safe to pass Unretained(this). |
209 scoped_ptr<ExtensionDevToolsInfoBarDelegate> delegate( | 209 scoped_ptr<ExtensionDevToolsInfoBarDelegate> delegate( |
210 new ExtensionDevToolsInfoBarDelegate( | 210 new ExtensionDevToolsInfoBarDelegate( |
211 base::Bind(&ExtensionDevToolsInfoBar::InfoBarDismissed, | 211 base::Bind(&ExtensionDevToolsInfoBar::InfoBarDismissed, |
212 base::Unretained(this)), | 212 base::Unretained(this)), |
213 extension_name)); | 213 extension_name)); |
214 infobar_ = GlobalConfirmInfoBar::Show(delegate.Pass()); | 214 infobar_ = GlobalConfirmInfoBar::Show(std::move(delegate)); |
215 } | 215 } |
216 | 216 |
217 ExtensionDevToolsInfoBar::~ExtensionDevToolsInfoBar() { | 217 ExtensionDevToolsInfoBar::~ExtensionDevToolsInfoBar() { |
218 g_extension_info_bars.Get().erase(extension_id_); | 218 g_extension_info_bars.Get().erase(extension_id_); |
219 if (infobar_) | 219 if (infobar_) |
220 infobar_->Close(); | 220 infobar_->Close(); |
221 } | 221 } |
222 | 222 |
223 void ExtensionDevToolsInfoBar::Remove( | 223 void ExtensionDevToolsInfoBar::Remove( |
224 ExtensionDevToolsClientHost* client_host) { | 224 ExtensionDevToolsClientHost* client_host) { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 SendDetachedEvent(); | 388 SendDetachedEvent(); |
389 Close(); | 389 Close(); |
390 } | 390 } |
391 | 391 |
392 void ExtensionDevToolsClientHost::SendDetachedEvent() { | 392 void ExtensionDevToolsClientHost::SendDetachedEvent() { |
393 if (!EventRouter::Get(profile_)) | 393 if (!EventRouter::Get(profile_)) |
394 return; | 394 return; |
395 | 395 |
396 scoped_ptr<base::ListValue> args(OnDetach::Create(debuggee_, | 396 scoped_ptr<base::ListValue> args(OnDetach::Create(debuggee_, |
397 detach_reason_)); | 397 detach_reason_)); |
398 scoped_ptr<Event> event( | 398 scoped_ptr<Event> event(new Event(events::DEBUGGER_ON_DETACH, |
399 new Event(events::DEBUGGER_ON_DETACH, OnDetach::kEventName, args.Pass())); | 399 OnDetach::kEventName, std::move(args))); |
400 event->restrict_to_browser_context = profile_; | 400 event->restrict_to_browser_context = profile_; |
401 EventRouter::Get(profile_) | 401 EventRouter::Get(profile_) |
402 ->DispatchEventToExtension(extension_id_, event.Pass()); | 402 ->DispatchEventToExtension(extension_id_, std::move(event)); |
403 } | 403 } |
404 | 404 |
405 void ExtensionDevToolsClientHost::OnExtensionUnloaded( | 405 void ExtensionDevToolsClientHost::OnExtensionUnloaded( |
406 content::BrowserContext* browser_context, | 406 content::BrowserContext* browser_context, |
407 const Extension* extension, | 407 const Extension* extension, |
408 UnloadedExtensionInfo::Reason reason) { | 408 UnloadedExtensionInfo::Reason reason) { |
409 if (extension->id() == extension_id_) | 409 if (extension->id() == extension_id_) |
410 Close(); | 410 Close(); |
411 } | 411 } |
412 | 412 |
(...skipping 23 matching lines...) Expand all Loading... |
436 if (!dictionary->GetString("method", &method_name)) | 436 if (!dictionary->GetString("method", &method_name)) |
437 return; | 437 return; |
438 | 438 |
439 OnEvent::Params params; | 439 OnEvent::Params params; |
440 base::DictionaryValue* params_value; | 440 base::DictionaryValue* params_value; |
441 if (dictionary->GetDictionary("params", ¶ms_value)) | 441 if (dictionary->GetDictionary("params", ¶ms_value)) |
442 params.additional_properties.Swap(params_value); | 442 params.additional_properties.Swap(params_value); |
443 | 443 |
444 scoped_ptr<base::ListValue> args( | 444 scoped_ptr<base::ListValue> args( |
445 OnEvent::Create(debuggee_, method_name, params)); | 445 OnEvent::Create(debuggee_, method_name, params)); |
446 scoped_ptr<Event> event( | 446 scoped_ptr<Event> event(new Event(events::DEBUGGER_ON_EVENT, |
447 new Event(events::DEBUGGER_ON_EVENT, OnEvent::kEventName, args.Pass())); | 447 OnEvent::kEventName, std::move(args))); |
448 event->restrict_to_browser_context = profile_; | 448 event->restrict_to_browser_context = profile_; |
449 EventRouter::Get(profile_) | 449 EventRouter::Get(profile_) |
450 ->DispatchEventToExtension(extension_id_, event.Pass()); | 450 ->DispatchEventToExtension(extension_id_, std::move(event)); |
451 } else { | 451 } else { |
452 DebuggerSendCommandFunction* function = pending_requests_[id].get(); | 452 DebuggerSendCommandFunction* function = pending_requests_[id].get(); |
453 if (!function) | 453 if (!function) |
454 return; | 454 return; |
455 | 455 |
456 function->SendResponseBody(dictionary); | 456 function->SendResponseBody(dictionary); |
457 pending_requests_.erase(id); | 457 pending_requests_.erase(id); |
458 } | 458 } |
459 } | 459 } |
460 | 460 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 const std::vector<DevToolsTargetImpl*>& target_list) { | 719 const std::vector<DevToolsTargetImpl*>& target_list) { |
720 scoped_ptr<base::ListValue> result(new base::ListValue()); | 720 scoped_ptr<base::ListValue> result(new base::ListValue()); |
721 for (size_t i = 0; i < target_list.size(); ++i) | 721 for (size_t i = 0; i < target_list.size(); ++i) |
722 result->Append(SerializeTarget(*target_list[i])); | 722 result->Append(SerializeTarget(*target_list[i])); |
723 STLDeleteContainerPointers(target_list.begin(), target_list.end()); | 723 STLDeleteContainerPointers(target_list.begin(), target_list.end()); |
724 SetResult(result.release()); | 724 SetResult(result.release()); |
725 SendResponse(true); | 725 SendResponse(true); |
726 } | 726 } |
727 | 727 |
728 } // namespace extensions | 728 } // namespace extensions |
OLD | NEW |