summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/libxml_utils.cc16
-rw-r--r--chrome/common/libxml_utils.h4
-rw-r--r--chrome/test/ui/omnibox_uitest.cc2
3 files changed, 17 insertions, 5 deletions
diff --git a/chrome/common/libxml_utils.cc b/chrome/common/libxml_utils.cc
index 009f0d3..61d4237 100644
--- a/chrome/common/libxml_utils.cc
+++ b/chrome/common/libxml_utils.cc
@@ -5,8 +5,10 @@
#include "chrome/common/libxml_utils.h"
#include "base/compiler_specific.h"
+#include "base/file_path.h"
#include "base/logging.h"
#include "base/stringprintf.h"
+#include "base/utf_string_conversions.h"
#include "libxml/xmlreader.h"
@@ -49,11 +51,19 @@ bool XmlReader::Load(const std::string& input) {
return reader_ != NULL;
}
-bool XmlReader::LoadFile(const std::string& file_path) {
-
+bool XmlReader::LoadFile(const FilePath& file_path) {
const int kParseOptions = XML_PARSE_RECOVER | // recover on errors
XML_PARSE_NONET; // forbid network access
- reader_ = xmlReaderForFile(file_path.c_str(), NULL, kParseOptions);
+ reader_ = xmlReaderForFile(
+#if defined(OS_WIN)
+ // libxml takes UTF-8 paths on Windows; search the source for
+ // xmlWrapOpenUtf8 to see it converting UTF-8 back to wide
+ // characters.
+ WideToUTF8(file_path.value()).c_str(),
+#else
+ file_path.value().c_str(),
+#endif
+ NULL, kParseOptions);
return reader_ != NULL;
}
diff --git a/chrome/common/libxml_utils.h b/chrome/common/libxml_utils.h
index 55a935c..cf53341 100644
--- a/chrome/common/libxml_utils.h
+++ b/chrome/common/libxml_utils.h
@@ -11,6 +11,8 @@
#include "libxml/xmlreader.h"
#include "libxml/xmlwriter.h"
+class FilePath;
+
// Converts a libxml xmlChar* into a UTF-8 std::string.
// NULL inputs produce an empty string.
std::string XmlStringToStdString(const xmlChar* xmlstring);
@@ -47,7 +49,7 @@ class XmlReader {
bool Load(const std::string& input);
// Load a document into the reader from a file. Returns false on error.
- bool LoadFile(const std::string& file_path);
+ bool LoadFile(const FilePath& file_path);
// Wrappers around libxml functions -----------------------------------------
diff --git a/chrome/test/ui/omnibox_uitest.cc b/chrome/test/ui/omnibox_uitest.cc
index f4f24fa..b859312 100644
--- a/chrome/test/ui/omnibox_uitest.cc
+++ b/chrome/test/ui/omnibox_uitest.cc
@@ -148,7 +148,7 @@ TEST_F(OmniboxTest, Measure) {
omnibox_tests_path = omnibox_tests_path.AppendASCII("omnibox_tests.xml");
XmlReader reader;
- ASSERT_TRUE(reader.LoadFile(WideToASCII(omnibox_tests_path.ToWStringHack())));
+ ASSERT_TRUE(reader.LoadFile(omnibox_tests_path));
while (reader.SkipToElement()) {
ASSERT_EQ("omnibox_tests", reader.NodeName());
reader.Read();