Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: chrome/browser/devtools/devtools_ui_bindings.cc

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 int ResponseWriter::Write(net::IOBuffer* buffer, 275 int ResponseWriter::Write(net::IOBuffer* buffer,
276 int num_bytes, 276 int num_bytes,
277 const net::CompletionCallback& callback) { 277 const net::CompletionCallback& callback) {
278 std::string chunk = std::string(buffer->data(), num_bytes); 278 std::string chunk = std::string(buffer->data(), num_bytes);
279 bool encoded = false; 279 bool encoded = false;
280 if (!base::IsStringUTF8(chunk)) { 280 if (!base::IsStringUTF8(chunk)) {
281 encoded = true; 281 encoded = true;
282 base::Base64Encode(chunk, &chunk); 282 base::Base64Encode(chunk, &chunk);
283 } 283 }
284 284
285 base::FundamentalValue* id = new base::FundamentalValue(stream_id_); 285 base::Value* id = new base::Value(stream_id_);
286 base::StringValue* chunkValue = new base::StringValue(chunk); 286 base::StringValue* chunkValue = new base::StringValue(chunk);
287 base::FundamentalValue* encodedValue = new base::FundamentalValue(encoded); 287 base::Value* encodedValue = new base::Value(encoded);
288 288
289 content::BrowserThread::PostTask( 289 content::BrowserThread::PostTask(
290 content::BrowserThread::UI, FROM_HERE, 290 content::BrowserThread::UI, FROM_HERE,
291 base::Bind(&DevToolsUIBindings::CallClientFunction, bindings_, 291 base::Bind(&DevToolsUIBindings::CallClientFunction, bindings_,
292 "DevToolsAPI.streamWrite", base::Owned(id), 292 "DevToolsAPI.streamWrite", base::Owned(id),
293 base::Owned(chunkValue), base::Owned(encodedValue))); 293 base::Owned(chunkValue), base::Owned(encodedValue)));
294 return num_bytes; 294 return num_bytes;
295 } 295 }
296 296
297 int ResponseWriter::Finish(int net_error, 297 int ResponseWriter::Finish(int net_error,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 485
486 if (message.length() < kMaxMessageChunkSize) { 486 if (message.length() < kMaxMessageChunkSize) {
487 std::string param; 487 std::string param;
488 base::EscapeJSONString(message, true, &param); 488 base::EscapeJSONString(message, true, &param);
489 base::string16 javascript = 489 base::string16 javascript =
490 base::UTF8ToUTF16("DevToolsAPI.dispatchMessage(" + param + ");"); 490 base::UTF8ToUTF16("DevToolsAPI.dispatchMessage(" + param + ");");
491 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); 491 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript);
492 return; 492 return;
493 } 493 }
494 494
495 base::FundamentalValue total_size(static_cast<int>(message.length())); 495 base::Value total_size(static_cast<int>(message.length()));
496 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { 496 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
497 base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize)); 497 base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize));
498 CallClientFunction("DevToolsAPI.dispatchMessageChunk", 498 CallClientFunction("DevToolsAPI.dispatchMessageChunk",
499 &message_value, pos ? NULL : &total_size, NULL); 499 &message_value, pos ? NULL : &total_size, NULL);
500 } 500 }
501 } 501 }
502 502
503 void DevToolsUIBindings::AgentHostClosed( 503 void DevToolsUIBindings::AgentHostClosed(
504 content::DevToolsAgentHost* agent_host, 504 content::DevToolsAgentHost* agent_host,
505 bool replaced_with_another_client) { 505 bool replaced_with_another_client) {
506 DCHECK(agent_host == agent_host_.get()); 506 DCHECK(agent_host == agent_host_.get());
507 agent_host_ = NULL; 507 agent_host_ = NULL;
508 delegate_->InspectedContentsClosing(); 508 delegate_->InspectedContentsClosing();
509 } 509 }
510 510
511 void DevToolsUIBindings::SendMessageAck(int request_id, 511 void DevToolsUIBindings::SendMessageAck(int request_id,
512 const base::Value* arg) { 512 const base::Value* arg) {
513 base::FundamentalValue id_value(request_id); 513 base::Value id_value(request_id);
514 CallClientFunction("DevToolsAPI.embedderMessageAck", 514 CallClientFunction("DevToolsAPI.embedderMessageAck",
515 &id_value, arg, nullptr); 515 &id_value, arg, nullptr);
516 } 516 }
517 517
518 // DevToolsEmbedderMessageDispatcher::Delegate implementation ----------------- 518 // DevToolsEmbedderMessageDispatcher::Delegate implementation -----------------
519 519
520 void DevToolsUIBindings::ActivateWindow() { 520 void DevToolsUIBindings::ActivateWindow() {
521 delegate_->ActivateWindow(); 521 delegate_->ActivateWindow();
522 } 522 }
523 523
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 std::string value; 939 std::string value;
940 while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value)) 940 while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value))
941 headers->SetString(name, value); 941 headers->SetString(name, value);
942 942
943 it->second.Run(&response); 943 it->second.Run(&response);
944 pending_requests_.erase(it); 944 pending_requests_.erase(it);
945 delete source; 945 delete source;
946 } 946 }
947 947
948 void DevToolsUIBindings::DeviceCountChanged(int count) { 948 void DevToolsUIBindings::DeviceCountChanged(int count) {
949 base::FundamentalValue value(count); 949 base::Value value(count);
950 CallClientFunction("DevToolsAPI.deviceCountUpdated", &value, NULL, 950 CallClientFunction("DevToolsAPI.deviceCountUpdated", &value, NULL,
951 NULL); 951 NULL);
952 } 952 }
953 953
954 void DevToolsUIBindings::DevicesUpdated( 954 void DevToolsUIBindings::DevicesUpdated(
955 const std::string& source, 955 const std::string& source,
956 const base::ListValue& targets) { 956 const base::ListValue& targets) {
957 CallClientFunction("DevToolsAPI.devicesUpdated", &targets, NULL, 957 CallClientFunction("DevToolsAPI.devicesUpdated", &targets, NULL,
958 NULL); 958 NULL);
959 } 959 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 1004
1005 CallClientFunction("DevToolsAPI.fileSystemFilesChanged", 1005 CallClientFunction("DevToolsAPI.fileSystemFilesChanged",
1006 &list, NULL, NULL); 1006 &list, NULL, NULL);
1007 } 1007 }
1008 1008
1009 void DevToolsUIBindings::IndexingTotalWorkCalculated( 1009 void DevToolsUIBindings::IndexingTotalWorkCalculated(
1010 int request_id, 1010 int request_id,
1011 const std::string& file_system_path, 1011 const std::string& file_system_path,
1012 int total_work) { 1012 int total_work) {
1013 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1013 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1014 base::FundamentalValue request_id_value(request_id); 1014 base::Value request_id_value(request_id);
1015 base::StringValue file_system_path_value(file_system_path); 1015 base::StringValue file_system_path_value(file_system_path);
1016 base::FundamentalValue total_work_value(total_work); 1016 base::Value total_work_value(total_work);
1017 CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated", 1017 CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated",
1018 &request_id_value, &file_system_path_value, 1018 &request_id_value, &file_system_path_value,
1019 &total_work_value); 1019 &total_work_value);
1020 } 1020 }
1021 1021
1022 void DevToolsUIBindings::IndexingWorked(int request_id, 1022 void DevToolsUIBindings::IndexingWorked(int request_id,
1023 const std::string& file_system_path, 1023 const std::string& file_system_path,
1024 int worked) { 1024 int worked) {
1025 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1025 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1026 base::FundamentalValue request_id_value(request_id); 1026 base::Value request_id_value(request_id);
1027 base::StringValue file_system_path_value(file_system_path); 1027 base::StringValue file_system_path_value(file_system_path);
1028 base::FundamentalValue worked_value(worked); 1028 base::Value worked_value(worked);
1029 CallClientFunction("DevToolsAPI.indexingWorked", &request_id_value, 1029 CallClientFunction("DevToolsAPI.indexingWorked", &request_id_value,
1030 &file_system_path_value, &worked_value); 1030 &file_system_path_value, &worked_value);
1031 } 1031 }
1032 1032
1033 void DevToolsUIBindings::IndexingDone(int request_id, 1033 void DevToolsUIBindings::IndexingDone(int request_id,
1034 const std::string& file_system_path) { 1034 const std::string& file_system_path) {
1035 indexing_jobs_.erase(request_id); 1035 indexing_jobs_.erase(request_id);
1036 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1036 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1037 base::FundamentalValue request_id_value(request_id); 1037 base::Value request_id_value(request_id);
1038 base::StringValue file_system_path_value(file_system_path); 1038 base::StringValue file_system_path_value(file_system_path);
1039 CallClientFunction("DevToolsAPI.indexingDone", &request_id_value, 1039 CallClientFunction("DevToolsAPI.indexingDone", &request_id_value,
1040 &file_system_path_value, NULL); 1040 &file_system_path_value, NULL);
1041 } 1041 }
1042 1042
1043 void DevToolsUIBindings::SearchCompleted( 1043 void DevToolsUIBindings::SearchCompleted(
1044 int request_id, 1044 int request_id,
1045 const std::string& file_system_path, 1045 const std::string& file_system_path,
1046 const std::vector<std::string>& file_paths) { 1046 const std::vector<std::string>& file_paths) {
1047 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1047 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1048 base::ListValue file_paths_value; 1048 base::ListValue file_paths_value;
1049 for (std::vector<std::string>::const_iterator it(file_paths.begin()); 1049 for (std::vector<std::string>::const_iterator it(file_paths.begin());
1050 it != file_paths.end(); ++it) { 1050 it != file_paths.end(); ++it) {
1051 file_paths_value.AppendString(*it); 1051 file_paths_value.AppendString(*it);
1052 } 1052 }
1053 base::FundamentalValue request_id_value(request_id); 1053 base::Value request_id_value(request_id);
1054 base::StringValue file_system_path_value(file_system_path); 1054 base::StringValue file_system_path_value(file_system_path);
1055 CallClientFunction("DevToolsAPI.searchCompleted", &request_id_value, 1055 CallClientFunction("DevToolsAPI.searchCompleted", &request_id_value,
1056 &file_system_path_value, &file_paths_value); 1056 &file_system_path_value, &file_paths_value);
1057 } 1057 }
1058 1058
1059 void DevToolsUIBindings::ShowDevToolsConfirmInfoBar( 1059 void DevToolsUIBindings::ShowDevToolsConfirmInfoBar(
1060 const base::string16& message, 1060 const base::string16& message,
1061 const InfoBarCallback& callback) { 1061 const InfoBarCallback& callback) {
1062 if (!delegate_->GetInfoBarService()) { 1062 if (!delegate_->GetInfoBarService()) {
1063 callback.Run(false); 1063 callback.Run(false);
(...skipping 17 matching lines...) Expand all
1081 .is_empty()) 1081 .is_empty())
1082 continue; 1082 continue;
1083 std::unique_ptr<base::DictionaryValue> extension_info( 1083 std::unique_ptr<base::DictionaryValue> extension_info(
1084 new base::DictionaryValue()); 1084 new base::DictionaryValue());
1085 extension_info->Set( 1085 extension_info->Set(
1086 "startPage", 1086 "startPage",
1087 new base::StringValue(extensions::chrome_manifest_urls::GetDevToolsPage( 1087 new base::StringValue(extensions::chrome_manifest_urls::GetDevToolsPage(
1088 extension.get()).spec())); 1088 extension.get()).spec()));
1089 extension_info->Set("name", new base::StringValue(extension->name())); 1089 extension_info->Set("name", new base::StringValue(extension->name()));
1090 extension_info->Set("exposeExperimentalAPIs", 1090 extension_info->Set("exposeExperimentalAPIs",
1091 new base::FundamentalValue( 1091 new base::Value(
1092 extension->permissions_data()->HasAPIPermission( 1092 extension->permissions_data()->HasAPIPermission(
1093 extensions::APIPermission::kExperimental))); 1093 extensions::APIPermission::kExperimental)));
1094 results.Append(std::move(extension_info)); 1094 results.Append(std::move(extension_info));
1095 } 1095 }
1096 if (!results.empty()) { 1096 if (!results.empty()) {
1097 // At least one devtools extension exists; it will need to run in the 1097 // At least one devtools extension exists; it will need to run in the
1098 // devtools process. Grant it permission to load documents with 1098 // devtools process. Grant it permission to load documents with
1099 // chrome-extension:// origins. 1099 // chrome-extension:// origins.
1100 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( 1100 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(
1101 web_contents_->GetMainFrame()->GetProcess()->GetID(), 1101 web_contents_->GetMainFrame()->GetProcess()->GetID(),
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 void DevToolsUIBindings::FrontendLoaded() { 1186 void DevToolsUIBindings::FrontendLoaded() {
1187 if (frontend_loaded_) 1187 if (frontend_loaded_)
1188 return; 1188 return;
1189 frontend_loaded_ = true; 1189 frontend_loaded_ = true;
1190 1190
1191 // Call delegate first - it seeds importants bit of information. 1191 // Call delegate first - it seeds importants bit of information.
1192 delegate_->OnLoadCompleted(); 1192 delegate_->OnLoadCompleted();
1193 1193
1194 AddDevToolsExtensionsToClient(); 1194 AddDevToolsExtensionsToClient();
1195 } 1195 }
OLDNEW
« no previous file with comments | « chrome/browser/custom_handlers/protocol_handler_registry.cc ('k') | chrome/browser/devtools/devtools_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698