diff options
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/src/process_policy_test.cc | 6 | ||||
-rw-r--r-- | sandbox/src/sandbox_utils.cc | 17 | ||||
-rw-r--r-- | sandbox/src/sandbox_utils.h | 14 | ||||
-rw-r--r-- | sandbox/tests/common/controller.cc | 3 |
4 files changed, 6 insertions, 34 deletions
diff --git a/sandbox/src/process_policy_test.cc b/sandbox/src/process_policy_test.cc index 8681671..1bcfa88 100644 --- a/sandbox/src/process_policy_test.cc +++ b/sandbox/src/process_policy_test.cc @@ -5,11 +5,11 @@ #include <memory> #include <string> +#include "base/sys_string_conversions.h" #include "base/win/scoped_handle.h" #include "sandbox/src/sandbox.h" #include "sandbox/src/sandbox_policy.h" #include "sandbox/src/sandbox_factory.h" -#include "sandbox/src/sandbox_utils.h" #include "sandbox/tests/common/controller.h" #include "testing/gtest/include/gtest/gtest.h" @@ -67,9 +67,9 @@ sandbox::SboxTestResult CreateProcessHelper(const std::wstring &exe, std::string narrow_cmd_line; if (cmd_line) - narrow_cmd_line = sandbox::WideToMultiByte(cmd_line); + narrow_cmd_line = base::SysWideToMultiByte(cmd_line, CP_UTF8); if (!::CreateProcessA( - exe_name ? sandbox::WideToMultiByte(exe_name).c_str() : NULL, + exe_name ? base::SysWideToMultiByte(exe_name, CP_UTF8).c_str() : NULL, cmd_line ? const_cast<char*>(narrow_cmd_line.c_str()) : NULL, NULL, NULL, FALSE, 0, NULL, NULL, &sia, &pi)) { DWORD last_error = GetLastError(); diff --git a/sandbox/src/sandbox_utils.cc b/sandbox/src/sandbox_utils.cc index b93434c..3bfa696 100644 --- a/sandbox/src/sandbox_utils.cc +++ b/sandbox/src/sandbox_utils.cc @@ -76,21 +76,4 @@ void InitObjectAttribs(const std::wstring& name, ULONG attributes, HANDLE root, InitializeObjectAttributes(obj_attr, uni_name, attributes, root, NULL); } -std::string WideToMultiByte(const std::wstring& wide) { - if (wide.length() == 0) - return std::string(); - - // compute the length of the buffer we'll need - int charcount = WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, - NULL, 0, NULL, NULL); - if (charcount == 0) - return std::string(); - - std::string mb; - WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, - WriteInto(&mb, charcount), charcount, NULL, NULL); - - return mb; -} - }; // namespace sandbox diff --git a/sandbox/src/sandbox_utils.h b/sandbox/src/sandbox_utils.h index e6cac5d..314330f 100644 --- a/sandbox/src/sandbox_utils.h +++ b/sandbox/src/sandbox_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -33,18 +33,6 @@ bool IsXPSP2OrLater(); void InitObjectAttribs(const std::wstring& name, ULONG attributes, HANDLE root, OBJECT_ATTRIBUTES* obj_attr, UNICODE_STRING* uni_name); -// The next 2 functions are copied from base\string_util.h and have been -// slighty modified because we don't want to depend on ICU. -template <class string_type> -inline typename string_type::value_type* WriteInto(string_type* str, - size_t length_with_null) { - str->reserve(length_with_null); - str->resize(length_with_null - 1); - return &((*str)[0]); -} - -std::string WideToMultiByte(const std::wstring& wide); - }; // namespace sandbox #endif // SANDBOX_SRC_SANDBOX_UTILS_H__ diff --git a/sandbox/tests/common/controller.cc b/sandbox/tests/common/controller.cc index b618069..a221ee1 100644 --- a/sandbox/tests/common/controller.cc +++ b/sandbox/tests/common/controller.cc @@ -6,6 +6,7 @@ #include <string> +#include "base/sys_string_conversions.h" #include "base/win/windows_version.h" #include "sandbox/src/sandbox_factory.h" #include "sandbox/src/sandbox_utils.h" @@ -261,7 +262,7 @@ int DispatchCall(int argc, wchar_t **argv) { &module)) return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; - std::string command_name = WideToMultiByte(argv[3]); + std::string command_name = base::SysWideToMultiByte(argv[3], CP_UTF8); CommandFunction command = reinterpret_cast<CommandFunction>( ::GetProcAddress(module, command_name.c_str())); if (!command) |