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 "content/browser/devtools/protocol/dom_handler.h" | 5 #include "content/browser/devtools/protocol/dom_handler.h" |
6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/browser/child_process_security_policy_impl.h" |
| 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 10 |
7 namespace content { | 11 namespace content { |
8 namespace devtools { | 12 namespace devtools { |
9 namespace dom { | 13 namespace dom { |
10 | 14 |
11 typedef DevToolsProtocolClient::Response Response; | 15 typedef DevToolsProtocolClient::Response Response; |
12 | 16 |
13 DOMHandler::DOMHandler() { | 17 DOMHandler::DOMHandler() : host_(nullptr) { |
14 } | 18 } |
15 | 19 |
16 DOMHandler::~DOMHandler() { | 20 DOMHandler::~DOMHandler() { |
17 } | 21 } |
18 | 22 |
| 23 void DOMHandler::SetRenderViewHost(RenderViewHostImpl* host) { |
| 24 host_ = host; |
| 25 } |
| 26 |
19 Response DOMHandler::SetFileInputFiles(NodeId node_id, | 27 Response DOMHandler::SetFileInputFiles(NodeId node_id, |
20 const std::vector<std::string>& files) { | 28 const std::vector<std::string>& files) { |
| 29 if (host_) { |
| 30 for (const auto& file : files) { |
| 31 #if defined(OS_WIN) |
| 32 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
| 33 host_->GetProcess()->GetID(), |
| 34 base::FilePath(base::UTF8ToUTF16(file))); |
| 35 #else |
| 36 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
| 37 host_->GetProcess()->GetID(), |
| 38 base::FilePath(file)); |
| 39 #endif // OS_WIN |
| 40 } |
| 41 } |
21 return Response::FallThrough(); | 42 return Response::FallThrough(); |
22 } | 43 } |
23 | 44 |
24 } // namespace dom | 45 } // namespace dom |
25 } // namespace devtools | 46 } // namespace devtools |
26 } // namespace content | 47 } // namespace content |
OLD | NEW |