Chromium Code Reviews| 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 base::DictionaryValue* headers = new base::DictionaryValue(); | 1102 auto headers = base::MakeUnique<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); | |
| 1106 | 1105 |
| 1107 size_t iterator = 0; | 1106 size_t iterator = 0; |
| 1108 std::string name; | 1107 std::string name; |
| 1109 std::string value; | 1108 std::string value; |
| 1110 while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value)) | 1109 while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value)) |
| 1111 headers->SetString(name, value); | 1110 headers->SetString(name, value); |
| 1112 | 1111 |
| 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->Set( | 1274 extension_info->Set( |
|
dgozman
2017/04/06 15:43:47
nit: let's use SetString here to avoid MakeUnique
vabr (Chromium)
2017/04/07 20:40:39
Done.
| |
| 1275 "startPage", | 1275 "startPage", |
| 1276 new base::Value( | 1276 base::MakeUnique<base::Value>( |
| 1277 extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) | 1277 extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) |
| 1278 .spec())); | 1278 .spec())); |
| 1279 extension_info->Set("name", new base::Value(extension->name())); | 1279 extension_info->Set("name", |
|
dgozman
2017/04/06 15:43:47
ditto
vabr (Chromium)
2017/04/07 20:40:39
Done.
| |
| 1280 extension_info->Set( | 1280 base::MakeUnique<base::Value>(extension->name())); |
| 1281 "exposeExperimentalAPIs", | 1281 extension_info->Set("exposeExperimentalAPIs", |
|
dgozman
2017/04/06 15:43:47
And SetBoolean here.
vabr (Chromium)
2017/04/07 20:40:39
Done.
| |
| 1282 new base::Value(extension->permissions_data()->HasAPIPermission( | 1282 base::MakeUnique<base::Value>( |
| 1283 extensions::APIPermission::kExperimental))); | 1283 extension->permissions_data()->HasAPIPermission( |
| 1284 extensions::APIPermission::kExperimental))); | |
| 1284 results.Append(std::move(extension_info)); | 1285 results.Append(std::move(extension_info)); |
| 1285 } | 1286 } |
| 1286 | 1287 |
| 1287 CallClientFunction("DevToolsAPI.addExtensions", | 1288 CallClientFunction("DevToolsAPI.addExtensions", |
| 1288 &results, NULL, NULL); | 1289 &results, NULL, NULL); |
| 1289 } | 1290 } |
| 1290 | 1291 |
| 1291 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { | 1292 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { |
| 1292 delegate_.reset(delegate); | 1293 delegate_.reset(delegate); |
| 1293 } | 1294 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1369 void DevToolsUIBindings::FrontendLoaded() { | 1370 void DevToolsUIBindings::FrontendLoaded() { |
| 1370 if (frontend_loaded_) | 1371 if (frontend_loaded_) |
| 1371 return; | 1372 return; |
| 1372 frontend_loaded_ = true; | 1373 frontend_loaded_ = true; |
| 1373 | 1374 |
| 1374 // Call delegate first - it seeds importants bit of information. | 1375 // Call delegate first - it seeds importants bit of information. |
| 1375 delegate_->OnLoadCompleted(); | 1376 delegate_->OnLoadCompleted(); |
| 1376 | 1377 |
| 1377 AddDevToolsExtensionsToClient(); | 1378 AddDevToolsExtensionsToClient(); |
| 1378 } | 1379 } |
| OLD | NEW |