Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / content / browser / devtools / protocol / dom_handler.cc
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
3 // found in the LICENSE file.
4
5 #include "content/browser/devtools/protocol/dom_handler.h"
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
11 namespace content {
12 namespace devtools {
13 namespace dom {
14
15 typedef DevToolsProtocolClient::Response Response;
16
17 DOMHandler::DOMHandler() : host_(nullptr) {
18 }
19
20 DOMHandler::~DOMHandler() {
21 }
22
23 void DOMHandler::SetRenderViewHost(RenderViewHostImpl* host) {
24   host_ = host;
25 }
26
27 Response DOMHandler::SetFileInputFiles(NodeId node_id,
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   }
42   return Response::FallThrough();
43 }
44
45 }  // namespace dom
46 }  // namespace devtools
47 }  // namespace content