Chromium Code Reviews| Index: chrome/browser/safe_browsing/local_safebrowsing_test_server.cc |
| diff --git a/chrome/browser/safe_browsing/local_safebrowsing_test_server.cc b/chrome/browser/safe_browsing/local_safebrowsing_test_server.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8067f032791878bd59886c698252b8e200ee30c7 |
| --- /dev/null |
| +++ b/chrome/browser/safe_browsing/local_safebrowsing_test_server.cc |
| @@ -0,0 +1,60 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/safe_browsing/local_safebrowsing_test_server.h" |
| + |
| +#include "base/command_line.h" |
| +#include "base/path_service.h" |
| +#include "base/string_number_conversions.h" |
| +#include "base/values.h" |
| +#include "net/test/python_utils.h" |
| +#include "net/test/test_server.h" |
| + |
| +LocalSafeBrowsingTestServer::LocalSafeBrowsingTestServer( |
| + const FilePath& data_file) |
| + : net::LocalTestServer(net::TestServer::TYPE_HTTP, |
| + net::TestServer::kLocalhost, |
| + FilePath()), |
| + data_file_(data_file) {} |
|
Ryan Sleevi
2012/08/31 21:48:39
nit: {
}
Per http://google-styleguide.googlecode.
mattm
2012/09/01 01:44:54
Done.
|
| + |
| +LocalSafeBrowsingTestServer::~LocalSafeBrowsingTestServer() {} |
| + |
| +bool LocalSafeBrowsingTestServer::GetTestServerPath( |
| + FilePath* testserver_path) const { |
| + FilePath testserver_dir; |
| + if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_dir)) { |
| + LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; |
| + return false; |
| + } |
| + |
| + testserver_dir = testserver_dir |
| + .Append(FILE_PATH_LITERAL("chrome")) |
| + .Append(FILE_PATH_LITERAL("browser")) |
| + .Append(FILE_PATH_LITERAL("safe_browsing")); |
| + |
| + *testserver_path = testserver_dir.Append(FILE_PATH_LITERAL( |
| + "safe_browsing_testserver.py")); |
| + return true; |
| +} |
| + |
| +bool LocalSafeBrowsingTestServer::SetPythonPath() const { |
| + if (!net::LocalTestServer::SetPythonPath()) |
| + return false; |
| + |
| + // Locate the Python code generated by the protocol buffers compiler. |
| + FilePath pyproto_dir; |
| + if (!GetPyProtoPath(&pyproto_dir)) { |
| + LOG(ERROR) << "Cannot find pyproto dir for generated code."; |
| + return false; |
| + } |
| + |
| + AppendToPythonPath(pyproto_dir.AppendASCII("google")); |
| + return true; |
| +} |
| + |
| +bool LocalSafeBrowsingTestServer::GenerateAdditionalArguments( |
| + base::DictionaryValue* arguments) const { |
| + arguments->SetString("data-file", data_file_.value()); |
| + return true; |
| +} |