https_forwarder.cc revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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 "chrome/browser/chromeos/login/test/https_forwarder.h" 6 7#include "base/base_paths.h" 8#include "base/files/file_path.h" 9#include "base/path_service.h" 10#include "base/values.h" 11#include "net/test/python_utils.h" 12 13namespace chromeos { 14 15HTTPSForwarder::HTTPSForwarder(const GURL& forward_target) 16 : net::LocalTestServer(net::LocalTestServer::TYPE_HTTPS, 17 net::LocalTestServer::kLocalhost, 18 base::FilePath()), 19 forward_target_(forward_target) { 20} 21 22HTTPSForwarder::~HTTPSForwarder() { 23} 24 25bool HTTPSForwarder::SetPythonPath() const { 26 if (!net::LocalTestServer::SetPythonPath()) 27 return false; 28 29 base::FilePath net_testserver_path; 30 if (!LocalTestServer::GetTestServerPath(&net_testserver_path)) 31 return false; 32 AppendToPythonPath(net_testserver_path.DirName()); 33 34 return true; 35} 36 37bool HTTPSForwarder::GetTestServerPath(base::FilePath* testserver_path) const { 38 base::FilePath source_root_dir; 39 if (!PathService::Get(base::DIR_SOURCE_ROOT, &source_root_dir)) 40 return false; 41 42 *testserver_path = source_root_dir.Append("chrome") 43 .Append("browser") 44 .Append("chromeos") 45 .Append("login") 46 .Append("test") 47 .Append("https_forwarder.py"); 48 return true; 49} 50 51bool HTTPSForwarder::GenerateAdditionalArguments( 52 base::DictionaryValue* arguments) const { 53 base::FilePath source_root_dir; 54 if (!net::LocalTestServer::GenerateAdditionalArguments(arguments) || 55 !PathService::Get(base::DIR_SOURCE_ROOT, &source_root_dir)) 56 return false; 57 58 arguments->SetString("forward-target", forward_target_.spec()); 59 return true; 60} 61 62} // namespace chromeos 63