Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: base/value_conversions.cc

Issue 8402008: Add FilePath::FromUTF8Unsafe() and FilePath::AsUTF8Unsafe(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_path_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/value_conversions.cc
diff --git a/base/value_conversions.cc b/base/value_conversions.cc
index 64513d070dc9fa14a1a3e983e47e089584df8b5e..f4957a4610c8316245dd1a6df7511417b513f879 100644
--- a/base/value_conversions.cc
+++ b/base/value_conversions.cc
@@ -5,39 +5,14 @@
#include "base/value_conversions.h"
#include "base/file_path.h"
-#include "base/sys_string_conversions.h"
-#include "base/utf_string_conversions.h"
#include "base/values.h"
namespace base {
-namespace {
-
// |Value| internally stores strings in UTF-8, so we have to convert from the
// system native code to UTF-8 and back.
-
-std::string FilePathToUTF8(const FilePath& file_path) {
-#if defined(OS_POSIX)
- return WideToUTF8(SysNativeMBToWide(file_path.value()));
-#else
- return UTF16ToUTF8(file_path.value());
-#endif
-}
-
-FilePath UTF8ToFilePath(const std::string& str) {
- FilePath::StringType result;
-#if defined(OS_POSIX)
- result = SysWideToNativeMB(UTF8ToWide(str));
-#elif defined(OS_WIN)
- result = UTF8ToUTF16(str);
-#endif
- return FilePath(result);
-}
-
-} // namespace
-
StringValue* CreateFilePathValue(const FilePath& in_value) {
- return new StringValue(FilePathToUTF8(in_value));
+ return new StringValue(in_value.AsUTF8Unsafe());
}
bool GetValueAsFilePath(const Value& value, FilePath* file_path) {
@@ -45,7 +20,7 @@ bool GetValueAsFilePath(const Value& value, FilePath* file_path) {
if (!value.GetAsString(&str))
return false;
if (file_path)
- *file_path = UTF8ToFilePath(str);
+ *file_path = FilePath::FromUTF8Unsafe(str);
return true;
}
« no previous file with comments | « base/file_path_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698