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 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 base::Value message_value(message); | 1092 base::Value message_value(message); |
1093 callback.Run(&message_value); | 1093 callback.Run(&message_value); |
1094 } | 1094 } |
1095 | 1095 |
1096 void DevToolsUIBindings::OnURLFetchComplete(const net::URLFetcher* source) { | 1096 void DevToolsUIBindings::OnURLFetchComplete(const net::URLFetcher* source) { |
1097 DCHECK(source); | 1097 DCHECK(source); |
1098 PendingRequestsMap::iterator it = pending_requests_.find(source); | 1098 PendingRequestsMap::iterator it = pending_requests_.find(source); |
1099 DCHECK(it != pending_requests_.end()); | 1099 DCHECK(it != pending_requests_.end()); |
1100 | 1100 |
1101 base::DictionaryValue response; | 1101 base::DictionaryValue response; |
1102 auto headers = base::MakeUnique<base::DictionaryValue>(); | 1102 base::DictionaryValue* headers = new base::DictionaryValue(); |
1103 net::HttpResponseHeaders* rh = source->GetResponseHeaders(); | 1103 net::HttpResponseHeaders* rh = source->GetResponseHeaders(); |
1104 response.SetInteger("statusCode", rh ? rh->response_code() : 200); | 1104 response.SetInteger("statusCode", rh ? rh->response_code() : 200); |
| 1105 response.Set("headers", headers); |
1105 | 1106 |
1106 size_t iterator = 0; | 1107 size_t iterator = 0; |
1107 std::string name; | 1108 std::string name; |
1108 std::string value; | 1109 std::string value; |
1109 while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value)) | 1110 while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value)) |
1110 headers->SetString(name, value); | 1111 headers->SetString(name, value); |
1111 | 1112 |
1112 response.Set("headers", std::move(headers)); | |
1113 it->second.Run(&response); | 1113 it->second.Run(&response); |
1114 pending_requests_.erase(it); | 1114 pending_requests_.erase(it); |
1115 delete source; | 1115 delete source; |
1116 } | 1116 } |
1117 | 1117 |
1118 void DevToolsUIBindings::DeviceCountChanged(int count) { | 1118 void DevToolsUIBindings::DeviceCountChanged(int count) { |
1119 base::Value value(count); | 1119 base::Value value(count); |
1120 CallClientFunction("DevToolsAPI.deviceCountUpdated", &value, NULL, | 1120 CallClientFunction("DevToolsAPI.deviceCountUpdated", &value, NULL, |
1121 NULL); | 1121 NULL); |
1122 } | 1122 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 | 1264 |
1265 // Each devtools extension will need to be able to run in the devtools | 1265 // Each devtools extension will need to be able to run in the devtools |
1266 // process. Grant each specific extension's origin permission to load | 1266 // process. Grant each specific extension's origin permission to load |
1267 // documents. | 1267 // documents. |
1268 content::ChildProcessSecurityPolicy::GetInstance()->GrantOrigin( | 1268 content::ChildProcessSecurityPolicy::GetInstance()->GrantOrigin( |
1269 web_contents_->GetMainFrame()->GetProcess()->GetID(), | 1269 web_contents_->GetMainFrame()->GetProcess()->GetID(), |
1270 url::Origin(extension->url())); | 1270 url::Origin(extension->url())); |
1271 | 1271 |
1272 std::unique_ptr<base::DictionaryValue> extension_info( | 1272 std::unique_ptr<base::DictionaryValue> extension_info( |
1273 new base::DictionaryValue()); | 1273 new base::DictionaryValue()); |
1274 extension_info->SetString( | 1274 extension_info->Set( |
1275 "startPage", | 1275 "startPage", |
1276 extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) | 1276 new base::Value( |
1277 .spec()); | 1277 extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) |
1278 extension_info->SetString("name", extension->name()); | 1278 .spec())); |
1279 extension_info->SetBoolean("exposeExperimentalAPIs", | 1279 extension_info->Set("name", new base::Value(extension->name())); |
1280 extension->permissions_data()->HasAPIPermission( | 1280 extension_info->Set( |
1281 extensions::APIPermission::kExperimental)); | 1281 "exposeExperimentalAPIs", |
| 1282 new base::Value(extension->permissions_data()->HasAPIPermission( |
| 1283 extensions::APIPermission::kExperimental))); |
1282 results.Append(std::move(extension_info)); | 1284 results.Append(std::move(extension_info)); |
1283 } | 1285 } |
1284 | 1286 |
1285 CallClientFunction("DevToolsAPI.addExtensions", | 1287 CallClientFunction("DevToolsAPI.addExtensions", |
1286 &results, NULL, NULL); | 1288 &results, NULL, NULL); |
1287 } | 1289 } |
1288 | 1290 |
1289 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { | 1291 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { |
1290 delegate_.reset(delegate); | 1292 delegate_.reset(delegate); |
1291 } | 1293 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 void DevToolsUIBindings::FrontendLoaded() { | 1369 void DevToolsUIBindings::FrontendLoaded() { |
1368 if (frontend_loaded_) | 1370 if (frontend_loaded_) |
1369 return; | 1371 return; |
1370 frontend_loaded_ = true; | 1372 frontend_loaded_ = true; |
1371 | 1373 |
1372 // Call delegate first - it seeds importants bit of information. | 1374 // Call delegate first - it seeds importants bit of information. |
1373 delegate_->OnLoadCompleted(); | 1375 delegate_->OnLoadCompleted(); |
1374 | 1376 |
1375 AddDevToolsExtensionsToClient(); | 1377 AddDevToolsExtensionsToClient(); |
1376 } | 1378 } |
OLD | NEW |