| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell_devtools_frontend.h" | 5 #include "content/shell/browser/shell_devtools_frontend.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 delete this; | 179 delete this; |
| 180 } | 180 } |
| 181 | 181 |
| 182 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend( | 182 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend( |
| 183 const std::string& message) { | 183 const std::string& message) { |
| 184 if (!agent_host_) | 184 if (!agent_host_) |
| 185 return; | 185 return; |
| 186 std::string method; | 186 std::string method; |
| 187 base::ListValue* params = NULL; | 187 base::ListValue* params = NULL; |
| 188 base::DictionaryValue* dict = NULL; | 188 base::DictionaryValue* dict = NULL; |
| 189 scoped_ptr<base::Value> parsed_message = base::JSONReader::Read(message); | 189 std::unique_ptr<base::Value> parsed_message = base::JSONReader::Read(message); |
| 190 if (!parsed_message || | 190 if (!parsed_message || |
| 191 !parsed_message->GetAsDictionary(&dict) || | 191 !parsed_message->GetAsDictionary(&dict) || |
| 192 !dict->GetString("method", &method)) { | 192 !dict->GetString("method", &method)) { |
| 193 return; | 193 return; |
| 194 } | 194 } |
| 195 int request_id = 0; | 195 int request_id = 0; |
| 196 dict->GetInteger("id", &request_id); | 196 dict->GetInteger("id", &request_id); |
| 197 dict->GetList("params", ¶ms); | 197 dict->GetList("params", ¶ms); |
| 198 | 198 |
| 199 if (method == "dispatchProtocolMessage" && params && params->GetSize() == 1) { | 199 if (method == "dispatchProtocolMessage" && params && params->GetSize() == 1) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 223 SendMessageAck(request_id, &response); | 223 SendMessageAck(request_id, &response); |
| 224 return; | 224 return; |
| 225 } | 225 } |
| 226 | 226 |
| 227 net::URLFetcher* fetcher = | 227 net::URLFetcher* fetcher = |
| 228 net::URLFetcher::Create(gurl, net::URLFetcher::GET, this).release(); | 228 net::URLFetcher::Create(gurl, net::URLFetcher::GET, this).release(); |
| 229 pending_requests_[fetcher] = request_id; | 229 pending_requests_[fetcher] = request_id; |
| 230 fetcher->SetRequestContext(web_contents()->GetBrowserContext()-> | 230 fetcher->SetRequestContext(web_contents()->GetBrowserContext()-> |
| 231 GetRequestContext()); | 231 GetRequestContext()); |
| 232 fetcher->SetExtraRequestHeaders(headers); | 232 fetcher->SetExtraRequestHeaders(headers); |
| 233 fetcher->SaveResponseWithWriter(scoped_ptr<net::URLFetcherResponseWriter>( | 233 fetcher->SaveResponseWithWriter( |
| 234 new ResponseWriter(weak_factory_.GetWeakPtr(), stream_id))); | 234 std::unique_ptr<net::URLFetcherResponseWriter>( |
| 235 new ResponseWriter(weak_factory_.GetWeakPtr(), stream_id))); |
| 235 fetcher->Start(); | 236 fetcher->Start(); |
| 236 return; | 237 return; |
| 237 } else if (method == "getPreferences") { | 238 } else if (method == "getPreferences") { |
| 238 SendMessageAck(request_id, &preferences_); | 239 SendMessageAck(request_id, &preferences_); |
| 239 return; | 240 return; |
| 240 } else if (method == "setPreference") { | 241 } else if (method == "setPreference") { |
| 241 std::string name; | 242 std::string name; |
| 242 std::string value; | 243 std::string value; |
| 243 if (!params->GetString(0, &name) || | 244 if (!params->GetString(0, &name) || |
| 244 !params->GetString(1, &value)) { | 245 !params->GetString(1, &value)) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 CallClientFunction("DevToolsAPI.embedderMessageAck", | 337 CallClientFunction("DevToolsAPI.embedderMessageAck", |
| 337 &id_value, arg, nullptr); | 338 &id_value, arg, nullptr); |
| 338 } | 339 } |
| 339 | 340 |
| 340 void ShellDevToolsFrontend::AgentHostClosed( | 341 void ShellDevToolsFrontend::AgentHostClosed( |
| 341 DevToolsAgentHost* agent_host, bool replaced) { | 342 DevToolsAgentHost* agent_host, bool replaced) { |
| 342 frontend_shell_->Close(); | 343 frontend_shell_->Close(); |
| 343 } | 344 } |
| 344 | 345 |
| 345 } // namespace content | 346 } // namespace content |
| OLD | NEW |