summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-09 01:20:14 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-09 01:20:14 +0000
commit216296c358dcd02d94b29eded46e3bb052a9751d (patch)
tree99574237af8d85175ccc7c00a55e7146df22d365
parentb0a5bf2c9aa8a248c0ca44eec4d0c6ed92ca563b (diff)
downloadchromium_src-216296c358dcd02d94b29eded46e3bb052a9751d.zip
chromium_src-216296c358dcd02d94b29eded46e3bb052a9751d.tar.gz
chromium_src-216296c358dcd02d94b29eded46e3bb052a9751d.tar.bz2
Launching Chrome with a user-data-dir command line switch containing a non ASCII character in the
path like "Test Chrome G�ldine" would cause a DCHECK to fire in the BrowserRenderProcessHost::AppendRendererCommandLine function while retrieving the user-data-dir switch value from the browser's command line and setting it back to the renderer's command line. This was because we would retrieve the value as ASCII which would not work because of the presence of a non ASCII character in the value. The end result is that a CHECK fires in the renderer when it tries to validate the existence of the user-data-dir path. Fix is to use the CommandLine::GetSwitchValuePath function instead which returns a FilePath which does the right thing. Test=Covered by a ui test. Fixes bug http://code.google.com/p/chromium/issues/detail?id=29245 Bug=29245 Review URL: http://codereview.chromium.org/671027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40981 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_uitest.cc42
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc8
2 files changed, 47 insertions, 3 deletions
diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc
index 5ceb55f..fdde99d 100644
--- a/chrome/browser/browser_uitest.cc
+++ b/chrome/browser/browser_uitest.cc
@@ -4,8 +4,10 @@
#include "app/gfx/native_widget_types.h"
#include "base/file_path.h"
+#include "base/file_util.h"
#include "base/string_util.h"
#include "base/sys_info.h"
+#include "base/test/test_file_util.h"
#include "base/values.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/common/chrome_switches.h"
@@ -305,4 +307,44 @@ TEST_F(KioskModeTest, EnableKioskModeTest) {
}
#endif
+#if defined(OS_WIN)
+// This test verifies that Chrome can be launched with a user-data-dir path
+// which contains non ASCII characters.
+class LaunchBrowserWithNonAsciiUserDatadir : public UITest {
+public:
+ void SetUp() {
+ PathService::Get(base::DIR_TEMP, &tmp_profile_);
+ tmp_profile_ = tmp_profile_.AppendASCII("tmp_profile");
+ tmp_profile_ = tmp_profile_.Append(L"Test Chrome Géraldine");
+
+ // Create a fresh, empty copy of this directory.
+ file_util::Delete(tmp_profile_, true);
+ file_util::CreateDirectory(tmp_profile_);
+
+ launch_arguments_.AppendSwitchWithValue(switches::kUserDataDir,
+ tmp_profile_.ToWStringHack());
+ }
+
+ bool LaunchAppWithProfile() {
+ UITest::SetUp();
+ return true;
+ }
+
+ void TearDown() {
+ UITest::TearDown();
+ EXPECT_TRUE(file_util::DieFileDie(tmp_profile_, true));
+ }
+
+public:
+ FilePath tmp_profile_;
+};
+
+TEST_F(LaunchBrowserWithNonAsciiUserDatadir, TestNonAsciiUserDataDir) {
+ ASSERT_TRUE(LaunchAppWithProfile());
+ // Verify that the window is present.
+ scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
+}
+#endif
+
} // namespace
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 3d70253..02849ae 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -470,10 +470,12 @@ void BrowserRenderProcessHost::AppendRendererCommandLine(
ChildProcessHost::SetCrashReporterCommandLine(command_line);
- const std::string user_data_dir =
- browser_command_line.GetSwitchValueASCII(switches::kUserDataDir);
+ FilePath user_data_dir =
+ browser_command_line.GetSwitchValuePath(switches::kUserDataDir);
+
if (!user_data_dir.empty())
- command_line->AppendSwitchWithValue(switches::kUserDataDir, user_data_dir);
+ command_line->AppendSwitchWithValue(switches::kUserDataDir,
+ user_data_dir.value());
#if defined(OS_CHROMEOS)
const std::string& profile =
browser_command_line.GetSwitchValueASCII(switches::kProfile);