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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 343 |
344 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 344 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
345 ::switches::kSilentDebuggerExtensionAPI)) { | 345 ::switches::kSilentDebuggerExtensionAPI)) { |
346 infobar_ = ExtensionDevToolsInfoBar::Create( | 346 return; |
347 extension_id, extension_name, this, | |
348 base::Bind(&ExtensionDevToolsClientHost::InfoBarDismissed, | |
349 base::Unretained(this))); | |
350 } | 347 } |
| 348 |
| 349 // We allow policy-installed extensions to circumvent the normal |
| 350 // infobar warning. See crbug.com/693621. |
| 351 const Extension* extension = |
| 352 ExtensionRegistry::Get(profile)->enabled_extensions().GetByID( |
| 353 extension_id); |
| 354 if (extension && Manifest::IsPolicyLocation(extension->location())) |
| 355 return; |
| 356 |
| 357 infobar_ = ExtensionDevToolsInfoBar::Create( |
| 358 extension_id, extension_name, this, |
| 359 base::Bind(&ExtensionDevToolsClientHost::InfoBarDismissed, |
| 360 base::Unretained(this))); |
351 } | 361 } |
352 | 362 |
353 ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { | 363 ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { |
354 if (infobar_) | 364 if (infobar_) |
355 infobar_->Remove(this); | 365 infobar_->Remove(this); |
356 g_attached_client_hosts.Get().erase(this); | 366 g_attached_client_hosts.Get().erase(this); |
357 } | 367 } |
358 | 368 |
359 // DevToolsAgentHostClient implementation. | 369 // DevToolsAgentHostClient implementation. |
360 void ExtensionDevToolsClientHost::AgentHostClosed( | 370 void ExtensionDevToolsClientHost::AgentHostClosed( |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 void DebuggerGetTargetsFunction::SendTargetList( | 739 void DebuggerGetTargetsFunction::SendTargetList( |
730 const content::DevToolsAgentHost::List& target_list) { | 740 const content::DevToolsAgentHost::List& target_list) { |
731 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 741 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
732 for (size_t i = 0; i < target_list.size(); ++i) | 742 for (size_t i = 0; i < target_list.size(); ++i) |
733 result->Append(SerializeTarget(target_list[i])); | 743 result->Append(SerializeTarget(target_list[i])); |
734 SetResult(std::move(result)); | 744 SetResult(std::move(result)); |
735 SendResponse(true); | 745 SendResponse(true); |
736 } | 746 } |
737 | 747 |
738 } // namespace extensions | 748 } // namespace extensions |
OLD | NEW |