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 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 extensions::ExtensionRegistry::Get(profile_->GetOriginalProfile()); | 1255 extensions::ExtensionRegistry::Get(profile_->GetOriginalProfile()); |
1256 if (!registry) | 1256 if (!registry) |
1257 return; | 1257 return; |
1258 | 1258 |
1259 base::ListValue results; | 1259 base::ListValue results; |
1260 for (const scoped_refptr<const extensions::Extension>& extension : | 1260 for (const scoped_refptr<const extensions::Extension>& extension : |
1261 registry->enabled_extensions()) { | 1261 registry->enabled_extensions()) { |
1262 if (extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) | 1262 if (extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) |
1263 .is_empty()) | 1263 .is_empty()) |
1264 continue; | 1264 continue; |
| 1265 |
| 1266 // Each devtools extension will need to be able to run in the devtools |
| 1267 // process. Grant each specific extension's origin permission to load |
| 1268 // documents. |
| 1269 content::ChildProcessSecurityPolicy::GetInstance()->GrantOrigin( |
| 1270 web_contents_->GetMainFrame()->GetProcess()->GetID(), |
| 1271 url::Origin(extension->url())); |
| 1272 |
1265 std::unique_ptr<base::DictionaryValue> extension_info( | 1273 std::unique_ptr<base::DictionaryValue> extension_info( |
1266 new base::DictionaryValue()); | 1274 new base::DictionaryValue()); |
1267 extension_info->Set( | 1275 extension_info->Set( |
1268 "startPage", | 1276 "startPage", |
1269 new base::StringValue(extensions::chrome_manifest_urls::GetDevToolsPage( | 1277 new base::StringValue(extensions::chrome_manifest_urls::GetDevToolsPage( |
1270 extension.get()).spec())); | 1278 extension.get()).spec())); |
1271 extension_info->Set("name", new base::StringValue(extension->name())); | 1279 extension_info->Set("name", new base::StringValue(extension->name())); |
1272 extension_info->Set("exposeExperimentalAPIs", | 1280 extension_info->Set("exposeExperimentalAPIs", |
1273 new base::FundamentalValue( | 1281 new base::FundamentalValue( |
1274 extension->permissions_data()->HasAPIPermission( | 1282 extension->permissions_data()->HasAPIPermission( |
1275 extensions::APIPermission::kExperimental))); | 1283 extensions::APIPermission::kExperimental))); |
1276 results.Append(std::move(extension_info)); | 1284 results.Append(std::move(extension_info)); |
1277 } | 1285 } |
1278 if (!results.empty()) { | |
1279 // At least one devtools extension exists; it will need to run in the | |
1280 // devtools process. Grant it permission to load documents with | |
1281 // chrome-extension:// origins. | |
1282 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | |
1283 web_contents_->GetMainFrame()->GetProcess()->GetID(), | |
1284 extensions::kExtensionScheme); | |
1285 } | |
1286 | 1286 |
1287 CallClientFunction("DevToolsAPI.addExtensions", | 1287 CallClientFunction("DevToolsAPI.addExtensions", |
1288 &results, NULL, NULL); | 1288 &results, NULL, NULL); |
1289 } | 1289 } |
1290 | 1290 |
1291 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { | 1291 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { |
1292 delegate_.reset(delegate); | 1292 delegate_.reset(delegate); |
1293 } | 1293 } |
1294 | 1294 |
1295 void DevToolsUIBindings::AttachTo( | 1295 void DevToolsUIBindings::AttachTo( |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 void DevToolsUIBindings::FrontendLoaded() { | 1369 void DevToolsUIBindings::FrontendLoaded() { |
1370 if (frontend_loaded_) | 1370 if (frontend_loaded_) |
1371 return; | 1371 return; |
1372 frontend_loaded_ = true; | 1372 frontend_loaded_ = true; |
1373 | 1373 |
1374 // Call delegate first - it seeds importants bit of information. | 1374 // Call delegate first - it seeds importants bit of information. |
1375 delegate_->OnLoadCompleted(); | 1375 delegate_->OnLoadCompleted(); |
1376 | 1376 |
1377 AddDevToolsExtensionsToClient(); | 1377 AddDevToolsExtensionsToClient(); |
1378 } | 1378 } |
OLD | NEW |