summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 22:47:10 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 22:47:10 +0000
commitf805fe8d565caf479ea438adfd1cd9a0f58b52ab (patch)
treea61a57f2dfde431a618aaf91517fa49842490278 /chrome
parent7bbb2fcc93f8231f1a1e744bd1b57adf4df9a518 (diff)
downloadchromium_src-f805fe8d565caf479ea438adfd1cd9a0f58b52ab.zip
chromium_src-f805fe8d565caf479ea438adfd1cd9a0f58b52ab.tar.gz
chromium_src-f805fe8d565caf479ea438adfd1cd9a0f58b52ab.tar.bz2
Make BrowserInit use FilePath instead of wstring for current directory.
(A.k.a. shaving a yak to get rid of a FromWStringHack().) BUG=24672 TEST=builds Review URL: http://codereview.chromium.org/3064032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54830 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/app_controller_mac.mm3
-rw-r--r--chrome/browser/browser_browsertest.cc2
-rw-r--r--chrome/browser/browser_init.cc24
-rw-r--r--chrome/browser/browser_init.h49
-rw-r--r--chrome/browser/browser_init_browsertest.cc7
-rw-r--r--chrome/browser/browser_main.cc3
-rw-r--r--chrome/browser/process_singleton_linux.cc3
-rw-r--r--chrome/browser/process_singleton_win.cc7
8 files changed, 51 insertions, 47 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 96aca15..029d095 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -8,6 +8,7 @@
#include "app/l10n_util_mac.h"
#include "base/auto_reset.h"
#include "base/command_line.h"
+#include "base/file_path.h"
#include "base/mac_util.h"
#include "base/message_loop.h"
#include "base/string_number_conversions.h"
@@ -903,7 +904,7 @@ void RecordLastRunAppBundlePath() {
}
CommandLine dummy(CommandLine::ARGUMENTS_ONLY);
- BrowserInit::LaunchWithProfile launch(std::wstring(), dummy);
+ BrowserInit::LaunchWithProfile launch(FilePath(), dummy);
launch.OpenURLsInBrowser(browser, false, urls);
}
diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc
index bafdfbd..cd7d495 100644
--- a/chrome/browser/browser_browsertest.cc
+++ b/chrome/browser/browser_browsertest.cc
@@ -578,7 +578,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) {
// Simulate launching again.
CommandLine dummy(CommandLine::ARGUMENTS_ONLY);
- BrowserInit::LaunchWithProfile launch(std::wstring(), dummy);
+ BrowserInit::LaunchWithProfile launch(FilePath(), dummy);
launch.profile_ = browser()->profile();
launch.ProcessStartupURLs(std::vector<GURL>());
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index cf9f3a2..2e499b6 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -10,6 +10,7 @@
#include "app/resource_bundle.h"
#include "base/environment.h"
#include "base/event_recorder.h"
+#include "base/file_path.h"
#include "base/histogram.h"
#include "base/path_service.h"
#include "base/scoped_ptr.h"
@@ -375,10 +376,11 @@ bool BrowserInit::InProcessStartup() {
return in_startup;
}
-bool BrowserInit::LaunchBrowser(
- const CommandLine& command_line, Profile* profile,
- const std::wstring& cur_dir, bool process_startup,
- int* return_code) {
+bool BrowserInit::LaunchBrowser(const CommandLine& command_line,
+ Profile* profile,
+ const FilePath& cur_dir,
+ bool process_startup,
+ int* return_code) {
in_startup = process_startup;
DCHECK(profile);
@@ -467,7 +469,7 @@ bool BrowserInit::LaunchBrowser(
// LaunchWithProfile ----------------------------------------------------------
BrowserInit::LaunchWithProfile::LaunchWithProfile(
- const std::wstring& cur_dir,
+ const FilePath& cur_dir,
const CommandLine& command_line)
: cur_dir_(cur_dir),
command_line_(command_line),
@@ -476,7 +478,7 @@ BrowserInit::LaunchWithProfile::LaunchWithProfile(
}
BrowserInit::LaunchWithProfile::LaunchWithProfile(
- const std::wstring& cur_dir,
+ const FilePath& cur_dir,
const CommandLine& command_line,
BrowserInit* browser_init)
: cur_dir_(cur_dir),
@@ -485,6 +487,9 @@ BrowserInit::LaunchWithProfile::LaunchWithProfile(
browser_init_(browser_init) {
}
+BrowserInit::LaunchWithProfile::~LaunchWithProfile() {
+}
+
bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
bool process_startup) {
DCHECK(profile);
@@ -829,7 +834,6 @@ void BrowserInit::LaunchWithProfile::AddBadFlagsInfoBarIfNecessary(
std::vector<GURL> BrowserInit::LaunchWithProfile::GetURLsFromCommandLine(
Profile* profile) {
std::vector<GURL> urls;
- FilePath cur_dir = FilePath::FromWStringHack(cur_dir_);
const std::vector<CommandLine::StringType>& params = command_line_.args();
for (size_t i = 0; i < params.size(); ++i) {
@@ -840,7 +844,7 @@ std::vector<GURL> BrowserInit::LaunchWithProfile::GetURLsFromCommandLine(
profile->GetTemplateURLModel()->GetDefaultSearchProvider();
if (!default_provider || !default_provider->url()) {
// No search provider available. Just treat this as regular URL.
- urls.push_back(URLFixerUpper::FixupRelativeFile(cur_dir, param));
+ urls.push_back(URLFixerUpper::FixupRelativeFile(cur_dir_, param));
continue;
}
const TemplateURLRef* search_url = default_provider->url();
@@ -851,7 +855,7 @@ std::vector<GURL> BrowserInit::LaunchWithProfile::GetURLsFromCommandLine(
TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())));
} else {
// This will create a file URL or a regular URL.
- GURL url(URLFixerUpper::FixupRelativeFile(cur_dir, param));
+ GURL url(URLFixerUpper::FixupRelativeFile(cur_dir_, param));
// Exclude dangerous schemes.
if (url.is_valid()) {
ChildProcessSecurityPolicy *policy =
@@ -920,7 +924,7 @@ void BrowserInit::LaunchWithProfile::CheckDefaultBrowser(Profile* profile) {
}
bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
- const std::wstring& cur_dir,
+ const FilePath& cur_dir,
bool process_startup,
Profile* profile,
int* return_code,
diff --git a/chrome/browser/browser_init.h b/chrome/browser/browser_init.h
index 496d2e1..c633c97 100644
--- a/chrome/browser/browser_init.h
+++ b/chrome/browser/browser_init.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -10,6 +10,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/file_path.h"
#include "base/gtest_prod_util.h"
#include "googleurl/src/gurl.h"
@@ -40,22 +41,21 @@ class BrowserInit {
// This function is equivalent to ProcessCommandLine but should only be
// called during actual process startup.
- bool Start(const CommandLine& cmd_line, const std::wstring& cur_dir,
+ bool Start(const CommandLine& cmd_line, const FilePath& cur_dir,
Profile* profile, int* return_code) {
return ProcessCmdLineImpl(cmd_line, cur_dir, true, profile, return_code,
this);
}
- // This function performs command-line handling and is invoked when
- // process starts as well as when we get a start request from another
- // process (via the WM_COPYDATA message). |command_line| holds the command
- // line we need to process - either from this process or from some other one
- // (if |process_startup| is true and we are being called from
- // ProcessSingleton::OnCopyData).
+ // This function performs command-line handling and is invoked when process
+ // starts as well as when we get a start request from another process (via the
+ // WM_COPYDATA message). |command_line| holds the command line we need to
+ // process - either from this process or from some other one (if
+ // |process_startup| is true and we are being called from
+ // ProcessSingleton::OnCopyData).
static bool ProcessCommandLine(const CommandLine& cmd_line,
- const std::wstring& cur_dir,
- bool process_startup, Profile* profile,
- int* return_code) {
+ const FilePath& cur_dir, bool process_startup,
+ Profile* profile, int* return_code) {
return ProcessCmdLineImpl(cmd_line, cur_dir, process_startup, profile,
return_code, NULL);
}
@@ -68,13 +68,12 @@ class BrowserInit {
// Returns true if the browser is coming up.
static bool InProcessStartup();
- // Launches a browser window associated with |profile|. |command_line|
- // should be the command line passed to this process. |cur_dir| can be
- // the null string, which implies that the directory of the executable.
- // should be used. |process_startup| indicates whether this is the
- // first browser.
+ // Launches a browser window associated with |profile|. |command_line| should
+ // be the command line passed to this process. |cur_dir| can be empty, which
+ // implies that the directory of the executable should be used.
+ // |process_startup| indicates whether this is the first browser.
bool LaunchBrowser(const CommandLine& command_line, Profile* profile,
- const std::wstring& cur_dir, bool process_startup,
+ const FilePath& cur_dir, bool process_startup,
int* return_code);
// LaunchWithProfile ---------------------------------------------------------
@@ -106,12 +105,10 @@ class BrowserInit {
// and thus no access to distribution-specific first-run behaviors. The
// second one is always called when the browser starts even if it is not
// the first run.
- LaunchWithProfile(const std::wstring& cur_dir,
- const CommandLine& command_line);
- LaunchWithProfile(const std::wstring& cur_dir,
- const CommandLine& command_line,
+ LaunchWithProfile(const FilePath& cur_dir, const CommandLine& command_line);
+ LaunchWithProfile(const FilePath& cur_dir, const CommandLine& command_line,
BrowserInit* browser_init);
- ~LaunchWithProfile() { }
+ ~LaunchWithProfile();
// Creates the necessary windows for startup. Returns true on success,
// false on failure. process_startup is true if Chrome is just
@@ -187,7 +184,7 @@ class BrowserInit {
// previously instructed not to do so) and warns the user if it is not.
void CheckDefaultBrowser(Profile* profile);
- std::wstring cur_dir_;
+ const FilePath cur_dir_;
const CommandLine& command_line_;
Profile* profile_;
BrowserInit* browser_init_;
@@ -196,9 +193,9 @@ class BrowserInit {
private:
static bool ProcessCmdLineImpl(const CommandLine& command_line,
- const std::wstring& cur_dir,
- bool process_startup, Profile* profile,
- int* return_code, BrowserInit* browser_init);
+ const FilePath& cur_dir, bool process_startup,
+ Profile* profile, int* return_code,
+ BrowserInit* browser_init);
// Additional tabs to open during first run.
std::vector<GURL> first_run_tabs_;
diff --git a/chrome/browser/browser_init_browsertest.cc b/chrome/browser/browser_init_browsertest.cc
index eb357a8..d1ad7b7 100644
--- a/chrome/browser/browser_init_browsertest.cc
+++ b/chrome/browser/browser_init_browsertest.cc
@@ -1,8 +1,9 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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 "base/command_line.h"
+#include "base/file_path.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_init.h"
#include "chrome/browser/browser_list.h"
@@ -50,7 +51,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, FLAKY_OpenURLsPopup) {
ASSERT_EQ(popup, observer.added_browser_);
CommandLine dummy(CommandLine::ARGUMENTS_ONLY);
- BrowserInit::LaunchWithProfile launch(std::wstring(), dummy);
+ BrowserInit::LaunchWithProfile launch(FilePath(), dummy);
// This should create a new window, but re-use the profile from |popup|. If
// it used a NULL or invalid profile, it would crash.
launch.OpenURLsInBrowser(popup, false, urls);
@@ -73,7 +74,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, FLAKY_BlockBadURLs) {
cmdline.AppendLooseValue(std::wstring(L"view-source:http://localhost/"));
// This will pick up the current browser instance.
- BrowserInit::LaunchWithProfile launch(std::wstring(), cmdline);
+ BrowserInit::LaunchWithProfile launch(FilePath(), cmdline);
launch.Launch(browser()->profile(), false);
// Give the browser a chance to start first. FIXME(jschuh)
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index f570903..591d0f9 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -14,6 +14,7 @@
#include "app/system_monitor.h"
#include "base/command_line.h"
#include "base/field_trial.h"
+#include "base/file_path.h"
#include "base/file_util.h"
#include "base/histogram.h"
#include "base/scoped_nsautorelease_pool.h"
@@ -1266,7 +1267,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
} else {
// We are in regular browser boot sequence. Open initial stabs and enter
// the main message loop.
- if (browser_init.Start(parsed_command_line, std::wstring(), profile,
+ if (browser_init.Start(parsed_command_line, FilePath(), profile,
&result_code)) {
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
// Initialize autoupdate timer. Timer callback costs basically nothing
diff --git a/chrome/browser/process_singleton_linux.cc b/chrome/browser/process_singleton_linux.cc
index b4f8a04..8a30e3e 100644
--- a/chrome/browser/process_singleton_linux.cc
+++ b/chrome/browser/process_singleton_linux.cc
@@ -548,8 +548,7 @@ void ProcessSingleton::LinuxWatcher::HandleMessage(
// Run the browser startup sequence again, with the command line of the
// signalling process.
FilePath current_dir_file_path(current_dir);
- BrowserInit::ProcessCommandLine(parsed_command_line,
- current_dir_file_path.ToWStringHack(),
+ BrowserInit::ProcessCommandLine(parsed_command_line, current_dir_file_path,
false, profile, NULL);
}
diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc
index 90fcf20..52c7a96 100644
--- a/chrome/browser/process_singleton_win.cc
+++ b/chrome/browser/process_singleton_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -8,6 +8,7 @@
#include "app/win_util.h"
#include "base/base_paths.h"
#include "base/command_line.h"
+#include "base/file_path.h"
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/scoped_handle.h"
@@ -251,8 +252,8 @@ LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) {
}
// Get current directory.
- const std::wstring cur_dir =
- msg.substr(first_null + 1, second_null - first_null);
+ const FilePath cur_dir(msg.substr(first_null + 1,
+ second_null - first_null));
const std::wstring::size_type third_null =
msg.find_first_of(L'\0', second_null + 1);