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 18 matching lines...) Expand all Loading... | |
29 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" | 29 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" |
30 #include "chrome/browser/devtools/global_confirm_info_bar.h" | 30 #include "chrome/browser/devtools/global_confirm_info_bar.h" |
31 #include "chrome/browser/extensions/api/debugger/debugger_api_constants.h" | 31 #include "chrome/browser/extensions/api/debugger/debugger_api_constants.h" |
32 #include "chrome/browser/extensions/extension_service.h" | 32 #include "chrome/browser/extensions/extension_service.h" |
33 #include "chrome/browser/extensions/extension_tab_util.h" | 33 #include "chrome/browser/extensions/extension_tab_util.h" |
34 #include "chrome/browser/infobars/infobar_service.h" | 34 #include "chrome/browser/infobars/infobar_service.h" |
35 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
36 #include "chrome/browser/ui/browser.h" | 36 #include "chrome/browser/ui/browser.h" |
37 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 37 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
38 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
39 #include "chrome/common/pref_names.h" | |
39 #include "chrome/grit/generated_resources.h" | 40 #include "chrome/grit/generated_resources.h" |
40 #include "components/infobars/core/confirm_infobar_delegate.h" | 41 #include "components/infobars/core/confirm_infobar_delegate.h" |
41 #include "components/infobars/core/infobar.h" | 42 #include "components/infobars/core/infobar.h" |
42 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
43 #include "content/public/browser/devtools_agent_host.h" | 44 #include "content/public/browser/devtools_agent_host.h" |
44 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
45 #include "content/public/browser/notification_source.h" | 46 #include "content/public/browser/notification_source.h" |
46 #include "content/public/browser/render_process_host.h" | 47 #include "content/public/browser/render_process_host.h" |
47 #include "content/public/browser/render_view_host.h" | 48 #include "content/public/browser/render_view_host.h" |
48 #include "content/public/browser/render_widget_host.h" | 49 #include "content/public/browser/render_widget_host.h" |
49 #include "content/public/browser/web_contents.h" | 50 #include "content/public/browser/web_contents.h" |
50 #include "content/public/common/content_client.h" | 51 #include "content/public/common/content_client.h" |
51 #include "content/public/common/url_utils.h" | 52 #include "content/public/common/url_utils.h" |
52 #include "extensions/browser/event_router.h" | 53 #include "extensions/browser/event_router.h" |
53 #include "extensions/browser/extension_host.h" | 54 #include "extensions/browser/extension_host.h" |
54 #include "extensions/browser/extension_registry.h" | 55 #include "extensions/browser/extension_registry.h" |
55 #include "extensions/browser/extension_registry_observer.h" | 56 #include "extensions/browser/extension_registry_observer.h" |
57 #include "extensions/browser/extension_system.h" | |
56 #include "extensions/common/constants.h" | 58 #include "extensions/common/constants.h" |
57 #include "extensions/common/error_utils.h" | 59 #include "extensions/common/error_utils.h" |
58 #include "extensions/common/extension.h" | 60 #include "extensions/common/extension.h" |
59 #include "extensions/common/manifest_constants.h" | 61 #include "extensions/common/manifest_constants.h" |
60 #include "extensions/common/permissions/permissions_data.h" | 62 #include "extensions/common/permissions/permissions_data.h" |
61 #include "extensions/common/switches.h" | 63 #include "extensions/common/switches.h" |
62 #include "ui/base/l10n/l10n_util.h" | 64 #include "ui/base/l10n/l10n_util.h" |
63 | 65 |
64 using content::DevToolsAgentHost; | 66 using content::DevToolsAgentHost; |
65 using content::RenderProcessHost; | 67 using content::RenderProcessHost; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 | 336 |
335 // RVH-based agents disconnect from their clients when the app is terminating | 337 // RVH-based agents disconnect from their clients when the app is terminating |
336 // but shared worker-based agents do not. | 338 // but shared worker-based agents do not. |
337 // Disconnect explicitly to make sure that |this| observer is not leaked. | 339 // Disconnect explicitly to make sure that |this| observer is not leaked. |
338 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 340 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
339 content::NotificationService::AllSources()); | 341 content::NotificationService::AllSources()); |
340 | 342 |
341 // Attach to debugger and tell it we are ready. | 343 // Attach to debugger and tell it we are ready. |
342 agent_host_->AttachClient(this); | 344 agent_host_->AttachClient(this); |
343 | 345 |
344 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 346 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
345 ::switches::kSilentDebuggerExtensionAPI)) { | 347 ::switches::kSilentDebuggerExtensionAPI)) { |
346 infobar_ = ExtensionDevToolsInfoBar::Create( | 348 return; |
347 extension_id, extension_name, this, | |
348 base::Bind(&ExtensionDevToolsClientHost::InfoBarDismissed, | |
349 base::Unretained(this))); | |
350 } | 349 } |
350 | |
351 if (profile->GetPrefs()->GetBoolean( | |
352 prefs::kDevToolsSilentManagedDebuggerAPIEnabled)) { | |
Andrew T Wilson (Slow)
2017/02/22 11:13:42
IMO, this new policy is unnecessary and we should
Devlin
2017/02/22 13:53:48
That was Pavel's original suggestion, but I pushed
pfeldman
2017/02/22 16:40:45
I don't have a strong opinion on this one, as Devl
| |
353 const Extension* extension = | |
354 ExtensionRegistry::Get(profile)->enabled_extensions().GetByID( | |
355 extension_id); | |
356 if (Manifest::IsPolicyLocation(extension->location())) | |
357 return; | |
358 } | |
359 | |
360 infobar_ = ExtensionDevToolsInfoBar::Create( | |
361 extension_id, extension_name, this, | |
362 base::Bind(&ExtensionDevToolsClientHost::InfoBarDismissed, | |
363 base::Unretained(this))); | |
351 } | 364 } |
352 | 365 |
353 ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { | 366 ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { |
354 if (infobar_) | 367 if (infobar_) |
355 infobar_->Remove(this); | 368 infobar_->Remove(this); |
356 g_attached_client_hosts.Get().erase(this); | 369 g_attached_client_hosts.Get().erase(this); |
357 } | 370 } |
358 | 371 |
359 // DevToolsAgentHostClient implementation. | 372 // DevToolsAgentHostClient implementation. |
360 void ExtensionDevToolsClientHost::AgentHostClosed( | 373 void ExtensionDevToolsClientHost::AgentHostClosed( |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 void DebuggerGetTargetsFunction::SendTargetList( | 742 void DebuggerGetTargetsFunction::SendTargetList( |
730 const content::DevToolsAgentHost::List& target_list) { | 743 const content::DevToolsAgentHost::List& target_list) { |
731 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 744 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
732 for (size_t i = 0; i < target_list.size(); ++i) | 745 for (size_t i = 0; i < target_list.size(); ++i) |
733 result->Append(SerializeTarget(target_list[i])); | 746 result->Append(SerializeTarget(target_list[i])); |
734 SetResult(std::move(result)); | 747 SetResult(std::move(result)); |
735 SendResponse(true); | 748 SendResponse(true); |
736 } | 749 } |
737 | 750 |
738 } // namespace extensions | 751 } // namespace extensions |
OLD | NEW |