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 | 10 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 333 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
334 | 334 |
335 // RVH-based agents disconnect from their clients when the app is terminating | 335 // RVH-based agents disconnect from their clients when the app is terminating |
336 // but shared worker-based agents do not. | 336 // but shared worker-based agents do not. |
337 // Disconnect explicitly to make sure that |this| observer is not leaked. | 337 // Disconnect explicitly to make sure that |this| observer is not leaked. |
338 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 338 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
339 content::NotificationService::AllSources()); | 339 content::NotificationService::AllSources()); |
340 | 340 |
341 // Attach to debugger and tell it we are ready. | 341 // Attach to debugger and tell it we are ready. |
342 agent_host_->AttachClient(this); | 342 agent_host_->AttachClient(this); |
343 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
344 ::switches::kSilentDebuggerExtensionAPI)) { | |
345 return; | |
346 } | |
343 | 347 |
344 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 348 const Extension* extension = |
345 ::switches::kSilentDebuggerExtensionAPI)) { | 349 ExtensionRegistry::Get(profile)->enabled_extensions().GetByID( |
346 infobar_ = ExtensionDevToolsInfoBar::Create( | 350 extension_id); |
347 extension_id, extension_name, this, | 351 if (Manifest::IsPolicyLocation(extension->location())) |
Devlin
2017/02/23 21:46:40
nit: Can we add a comment here like:
// We allow p
| |
348 base::Bind(&ExtensionDevToolsClientHost::InfoBarDismissed, | 352 return; |
349 base::Unretained(this))); | 353 infobar_ = ExtensionDevToolsInfoBar::Create( |
350 } | 354 extension_id, extension_name, this, |
355 base::Bind(&ExtensionDevToolsClientHost::InfoBarDismissed, | |
356 base::Unretained(this))); | |
351 } | 357 } |
352 | 358 |
353 ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { | 359 ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { |
354 if (infobar_) | 360 if (infobar_) |
355 infobar_->Remove(this); | 361 infobar_->Remove(this); |
356 g_attached_client_hosts.Get().erase(this); | 362 g_attached_client_hosts.Get().erase(this); |
357 } | 363 } |
358 | 364 |
359 // DevToolsAgentHostClient implementation. | 365 // DevToolsAgentHostClient implementation. |
360 void ExtensionDevToolsClientHost::AgentHostClosed( | 366 void ExtensionDevToolsClientHost::AgentHostClosed( |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 void DebuggerGetTargetsFunction::SendTargetList( | 735 void DebuggerGetTargetsFunction::SendTargetList( |
730 const content::DevToolsAgentHost::List& target_list) { | 736 const content::DevToolsAgentHost::List& target_list) { |
731 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 737 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
732 for (size_t i = 0; i < target_list.size(); ++i) | 738 for (size_t i = 0; i < target_list.size(); ++i) |
733 result->Append(SerializeTarget(target_list[i])); | 739 result->Append(SerializeTarget(target_list[i])); |
734 SetResult(std::move(result)); | 740 SetResult(std::move(result)); |
735 SendResponse(true); | 741 SendResponse(true); |
736 } | 742 } |
737 | 743 |
738 } // namespace extensions | 744 } // namespace extensions |
OLD | NEW |