OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/devtools/devtools_ui_bindings.h" | 5 #include "chrome/browser/devtools/devtools_ui_bindings.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
37 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" | 37 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" |
38 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
39 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
40 #include "chrome/grit/generated_resources.h" | 40 #include "chrome/grit/generated_resources.h" |
41 #include "components/infobars/core/confirm_infobar_delegate.h" | 41 #include "components/infobars/core/confirm_infobar_delegate.h" |
42 #include "components/infobars/core/infobar.h" | 42 #include "components/infobars/core/infobar.h" |
43 #include "components/prefs/scoped_user_pref_update.h" | 43 #include "components/prefs/scoped_user_pref_update.h" |
44 #include "components/syncable_prefs/pref_service_syncable.h" | 44 #include "components/syncable_prefs/pref_service_syncable.h" |
45 #include "components/zoom/page_zoom.h" | 45 #include "components/zoom/page_zoom.h" |
| 46 #include "content/public/browser/child_process_security_policy.h" |
46 #include "content/public/browser/devtools_external_agent_proxy.h" | 47 #include "content/public/browser/devtools_external_agent_proxy.h" |
47 #include "content/public/browser/devtools_external_agent_proxy_delegate.h" | 48 #include "content/public/browser/devtools_external_agent_proxy_delegate.h" |
48 #include "content/public/browser/navigation_controller.h" | 49 #include "content/public/browser/navigation_controller.h" |
49 #include "content/public/browser/navigation_entry.h" | 50 #include "content/public/browser/navigation_entry.h" |
50 #include "content/public/browser/notification_source.h" | 51 #include "content/public/browser/notification_source.h" |
51 #include "content/public/browser/reload_type.h" | 52 #include "content/public/browser/reload_type.h" |
52 #include "content/public/browser/render_frame_host.h" | 53 #include "content/public/browser/render_frame_host.h" |
53 #include "content/public/browser/render_process_host.h" | 54 #include "content/public/browser/render_process_host.h" |
54 #include "content/public/browser/render_view_host.h" | 55 #include "content/public/browser/render_view_host.h" |
55 #include "content/public/browser/user_metrics.h" | 56 #include "content/public/browser/user_metrics.h" |
56 #include "content/public/browser/web_contents.h" | 57 #include "content/public/browser/web_contents.h" |
57 #include "content/public/browser/web_contents_observer.h" | 58 #include "content/public/browser/web_contents_observer.h" |
58 #include "content/public/common/renderer_preferences.h" | 59 #include "content/public/common/renderer_preferences.h" |
59 #include "content/public/common/url_constants.h" | 60 #include "content/public/common/url_constants.h" |
60 #include "extensions/browser/extension_registry.h" | 61 #include "extensions/browser/extension_registry.h" |
| 62 #include "extensions/common/constants.h" |
61 #include "extensions/common/permissions/permissions_data.h" | 63 #include "extensions/common/permissions/permissions_data.h" |
62 #include "ipc/ipc_channel.h" | 64 #include "ipc/ipc_channel.h" |
63 #include "net/base/io_buffer.h" | 65 #include "net/base/io_buffer.h" |
64 #include "net/base/net_errors.h" | 66 #include "net/base/net_errors.h" |
65 #include "net/cert/x509_certificate.h" | 67 #include "net/cert/x509_certificate.h" |
66 #include "net/http/http_response_headers.h" | 68 #include "net/http/http_response_headers.h" |
67 #include "net/url_request/url_fetcher.h" | 69 #include "net/url_request/url_fetcher.h" |
68 #include "net/url_request/url_fetcher_response_writer.h" | 70 #include "net/url_request/url_fetcher_response_writer.h" |
69 #include "ui/base/l10n/l10n_util.h" | 71 #include "ui/base/l10n/l10n_util.h" |
70 #include "ui/base/page_transition_types.h" | 72 #include "ui/base/page_transition_types.h" |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 "startPage", | 1065 "startPage", |
1064 new base::StringValue(extensions::chrome_manifest_urls::GetDevToolsPage( | 1066 new base::StringValue(extensions::chrome_manifest_urls::GetDevToolsPage( |
1065 extension.get()).spec())); | 1067 extension.get()).spec())); |
1066 extension_info->Set("name", new base::StringValue(extension->name())); | 1068 extension_info->Set("name", new base::StringValue(extension->name())); |
1067 extension_info->Set("exposeExperimentalAPIs", | 1069 extension_info->Set("exposeExperimentalAPIs", |
1068 new base::FundamentalValue( | 1070 new base::FundamentalValue( |
1069 extension->permissions_data()->HasAPIPermission( | 1071 extension->permissions_data()->HasAPIPermission( |
1070 extensions::APIPermission::kExperimental))); | 1072 extensions::APIPermission::kExperimental))); |
1071 results.Append(std::move(extension_info)); | 1073 results.Append(std::move(extension_info)); |
1072 } | 1074 } |
| 1075 if (!results.empty()) { |
| 1076 // At least one devtools extension exists; it will need to run in the |
| 1077 // devtools process. Grant it permission to load documents with |
| 1078 // chrome-extension:// origins. |
| 1079 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( |
| 1080 web_contents_->GetMainFrame()->GetProcess()->GetID(), |
| 1081 extensions::kExtensionScheme); |
| 1082 } |
| 1083 |
1073 CallClientFunction("DevToolsAPI.addExtensions", | 1084 CallClientFunction("DevToolsAPI.addExtensions", |
1074 &results, NULL, NULL); | 1085 &results, NULL, NULL); |
1075 } | 1086 } |
1076 | 1087 |
1077 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { | 1088 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { |
1078 delegate_.reset(delegate); | 1089 delegate_.reset(delegate); |
1079 } | 1090 } |
1080 | 1091 |
1081 void DevToolsUIBindings::AttachTo( | 1092 void DevToolsUIBindings::AttachTo( |
1082 const scoped_refptr<content::DevToolsAgentHost>& agent_host) { | 1093 const scoped_refptr<content::DevToolsAgentHost>& agent_host) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 void DevToolsUIBindings::FrontendLoaded() { | 1161 void DevToolsUIBindings::FrontendLoaded() { |
1151 if (frontend_loaded_) | 1162 if (frontend_loaded_) |
1152 return; | 1163 return; |
1153 frontend_loaded_ = true; | 1164 frontend_loaded_ = true; |
1154 | 1165 |
1155 // Call delegate first - it seeds importants bit of information. | 1166 // Call delegate first - it seeds importants bit of information. |
1156 delegate_->OnLoadCompleted(); | 1167 delegate_->OnLoadCompleted(); |
1157 | 1168 |
1158 AddDevToolsExtensionsToClient(); | 1169 AddDevToolsExtensionsToClient(); |
1159 } | 1170 } |
OLD | NEW |