diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-30 23:56:18 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-30 23:56:18 +0000 |
commit | b969648e443de8c767d7e2f6b34861b4a1ee3eec (patch) | |
tree | b41dea85b620d7664038e2583614745bc4be6fae /chrome | |
parent | f0a94b593178cfe95dd16424cca6a0144de0d440 (diff) | |
download | chromium_src-b969648e443de8c767d7e2f6b34861b4a1ee3eec.zip chromium_src-b969648e443de8c767d7e2f6b34861b4a1ee3eec.tar.gz chromium_src-b969648e443de8c767d7e2f6b34861b4a1ee3eec.tar.bz2 |
windows: remove PathService::Get() that uses wstrings
This just required fixing the remaining callers.
BUG=24672
Review URL: http://codereview.chromium.org/5356008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67783 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_main_win.cc | 5 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run_win.cc | 27 | ||||
-rw-r--r-- | chrome/browser/google/google_update.cc | 12 | ||||
-rw-r--r-- | chrome/browser/jumplist_win.cc | 13 | ||||
-rw-r--r-- | chrome/browser/process_singleton_win.cc | 4 | ||||
-rw-r--r-- | chrome/browser/shell_integration_win.cc | 9 | ||||
-rw-r--r-- | chrome/common/sandbox_policy.cc | 22 | ||||
-rw-r--r-- | chrome/default_plugin/plugin_database_handler.cc | 5 | ||||
-rw-r--r-- | chrome/tools/crash_service/crash_service.cc | 21 | ||||
-rw-r--r-- | chrome/tools/crash_service/crash_service.h | 7 |
10 files changed, 62 insertions, 63 deletions
diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc index f4f9a59..e4b52da 100644 --- a/chrome/browser/browser_main_win.cc +++ b/chrome/browser/browser_main_win.cc @@ -178,8 +178,9 @@ int HandleIconsCommands(const CommandLine &parsed_command_line) { bool CheckMachineLevelInstall() { scoped_ptr<installer::Version> version(InstallUtil::GetChromeVersion(true)); if (version.get()) { - std::wstring exe; - PathService::Get(base::DIR_EXE, &exe); + FilePath exe_path; + PathService::Get(base::DIR_EXE, &exe_path); + std::wstring exe = exe_path.value(); std::transform(exe.begin(), exe.end(), exe.begin(), tolower); std::wstring user_exe_path = installer::GetChromeInstallPath(false); std::transform(user_exe_path.begin(), user_exe_path.end(), diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc index 35037d5..bffded1 100644 --- a/chrome/browser/first_run/first_run_win.cc +++ b/chrome/browser/first_run/first_run_win.cc @@ -68,13 +68,6 @@ bool GetNewerChromeFile(FilePath* path) { return true; } -bool GetBackupChromeFile(std::wstring* path) { - if (!PathService::Get(base::DIR_EXE, path)) - return false; - file_util::AppendToPath(path, installer_util::kChromeOldExe); - return true; -} - bool InvokeGoogleUpdateForRename() { ScopedComPtr<IProcessLauncher> ipl; if (!FAILED(ipl.CreateInstance(__uuidof(ProcessLauncherClass)))) { @@ -225,30 +218,31 @@ void FirstRun::DoDelayedInstallExtensions() { CommandLine* Upgrade::new_command_line_ = NULL; bool FirstRun::CreateChromeDesktopShortcut() { - std::wstring chrome_exe; + FilePath chrome_exe; if (!PathService::Get(base::FILE_EXE, &chrome_exe)) return false; BrowserDistribution *dist = BrowserDistribution::GetDistribution(); if (!dist) return false; - return ShellUtil::CreateChromeDesktopShortcut(chrome_exe, + return ShellUtil::CreateChromeDesktopShortcut(chrome_exe.value(), dist->GetAppDescription(), ShellUtil::CURRENT_USER, false, true); // create if doesn't exist. } bool FirstRun::CreateChromeQuickLaunchShortcut() { - std::wstring chrome_exe; + FilePath chrome_exe; if (!PathService::Get(base::FILE_EXE, &chrome_exe)) return false; - return ShellUtil::CreateChromeQuickLaunchShortcut(chrome_exe, + return ShellUtil::CreateChromeQuickLaunchShortcut(chrome_exe.value(), ShellUtil::CURRENT_USER, // create only for current user. true); // create if doesn't exist. } bool Upgrade::IsBrowserAlreadyRunning() { static HANDLE handle = NULL; - std::wstring exe; - PathService::Get(base::FILE_EXE, &exe); + FilePath exe_path; + PathService::Get(base::FILE_EXE, &exe_path); + std::wstring exe = exe_path.value(); std::replace(exe.begin(), exe.end(), '\\', '!'); std::transform(exe.begin(), exe.end(), exe.begin(), tolower); exe = L"Global\\" + exe; @@ -273,12 +267,13 @@ bool Upgrade::SwapNewChromeExeIfPresent() { return false; if (!file_util::PathExists(new_chrome_exe)) return false; - std::wstring curr_chrome_exe; - if (!PathService::Get(base::FILE_EXE, &curr_chrome_exe)) + FilePath cur_chrome_exe; + if (!PathService::Get(base::FILE_EXE, &cur_chrome_exe)) return false; // First try to rename exe by launching rename command ourselves. - bool user_install = InstallUtil::IsPerUserInstall(curr_chrome_exe.c_str()); + bool user_install = + InstallUtil::IsPerUserInstall(cur_chrome_exe.value().c_str()); HKEY reg_root = user_install ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; BrowserDistribution *dist = BrowserDistribution::GetDistribution(); base::win::RegKey key; diff --git a/chrome/browser/google/google_update.cc b/chrome/browser/google/google_update.cc index cb68832..c373b59 100644 --- a/chrome/browser/google/google_update.cc +++ b/chrome/browser/google/google_update.cc @@ -7,6 +7,7 @@ #include <atlbase.h> #include <atlcom.h> +#include "base/file_path.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/scoped_comptr_win.h" @@ -226,16 +227,17 @@ bool GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer, Window* window, MessageLoop* main_loop) { - std::wstring chrome_exe_path; + FilePath chrome_exe_path; if (!PathService::Get(base::DIR_EXE, &chrome_exe_path)) { NOTREACHED(); return false; } + std::wstring chrome_exe = chrome_exe_path.value(); - std::transform(chrome_exe_path.begin(), chrome_exe_path.end(), - chrome_exe_path.begin(), tolower); + std::transform(chrome_exe.begin(), chrome_exe.end(), + chrome_exe.begin(), tolower); - if (!CanUpdateCurrentChrome(chrome_exe_path)) { + if (!CanUpdateCurrentChrome(chrome_exe)) { main_loop->PostTask(FROM_HERE, NewRunnableMethod(this, &GoogleUpdate::ReportResults, UPGRADE_ERROR, CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY)); @@ -254,7 +256,7 @@ bool GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer, ScopedComPtr<IGoogleUpdate> on_demand; - if (InstallUtil::IsPerUserInstall(chrome_exe_path.c_str())) { + if (InstallUtil::IsPerUserInstall(chrome_exe.c_str())) { hr = on_demand.CreateInstance(CLSID_OnDemandUserAppsClass); } else { // The Update operation needs Admin privileges for writing diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc index ddea51c..083dc80 100644 --- a/chrome/browser/jumplist_win.cc +++ b/chrome/browser/jumplist_win.cc @@ -416,7 +416,7 @@ bool UpdateJumpList(const wchar_t* app_id, return false; // Retrieve the absolute path to "chrome.exe". - std::wstring chrome_path; + FilePath chrome_path; if (!PathService::Get(base::FILE_EXE, &chrome_path)) return false; @@ -447,20 +447,21 @@ bool UpdateJumpList(const wchar_t* app_id, // This update request is applied into the JumpList when we commit this // transaction. result = UpdateCategory(destination_list, IDS_NEW_TAB_MOST_VISITED, - chrome_path, chrome_switches, most_visited_pages, - most_visited_items); + chrome_path.value(), chrome_switches, + most_visited_pages, most_visited_items); if (FAILED(result)) return false; // Update the "Recently Closed" category of the JumpList. result = UpdateCategory(destination_list, IDS_NEW_TAB_RECENTLY_CLOSED, - chrome_path, chrome_switches, recently_closed_pages, - recently_closed_items); + chrome_path.value(), chrome_switches, + recently_closed_pages, recently_closed_items); if (FAILED(result)) return false; // Update the "Tasks" category of the JumpList. - result = UpdateTaskCategory(destination_list, chrome_path, chrome_switches); + result = UpdateTaskCategory(destination_list, chrome_path.value(), + chrome_switches); if (FAILED(result)) return false; diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc index 875c6c2..35d7a0c 100644 --- a/chrome/browser/process_singleton_win.cc +++ b/chrome/browser/process_singleton_win.cc @@ -91,10 +91,10 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() { // Found another window, send our command line to it // format is "START\0<<<current directory>>>\0<<<commandline>>>". std::wstring to_send(L"START\0", 6); // want the NULL in the string. - std::wstring cur_dir; + FilePath cur_dir; if (!PathService::Get(base::DIR_CURRENT, &cur_dir)) return PROCESS_NONE; - to_send.append(cur_dir); + to_send.append(cur_dir.value()); to_send.append(L"\0", 1); // Null separator. to_send.append(GetCommandLineW()); to_send.append(L"\0", 1); // Null separator. diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index f358ffd..044a787 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -265,7 +265,7 @@ bool MigrateChromiumShortcutsTask::GetShortcutAppId( }; bool ShellIntegration::SetAsDefaultBrowser() { - std::wstring chrome_exe; + FilePath chrome_exe; if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { LOG(ERROR) << "Error getting app exe path"; return false; @@ -273,7 +273,7 @@ bool ShellIntegration::SetAsDefaultBrowser() { // From UI currently we only allow setting default browser for current user. if (!ShellUtil::MakeChromeDefault(ShellUtil::CURRENT_USER, - chrome_exe, true)) { + chrome_exe.value(), true)) { LOG(ERROR) << "Chrome could not be set as default browser."; return false; } @@ -285,7 +285,7 @@ bool ShellIntegration::SetAsDefaultBrowser() { ShellIntegration::DefaultBrowserState ShellIntegration::IsDefaultBrowser() { // First determine the app path. If we can't determine what that is, we have // bigger fish to fry... - std::wstring app_path; + FilePath app_path; if (!PathService::Get(base::FILE_EXE, &app_path)) { LOG(ERROR) << "Error getting app exe path"; return UNKNOWN_DEFAULT_BROWSER; @@ -330,7 +330,8 @@ ShellIntegration::DefaultBrowserState ShellIntegration::IsDefaultBrowser() { pAAR->Release(); } else { std::wstring short_app_path; - GetShortPathName(app_path.c_str(), WriteInto(&short_app_path, MAX_PATH), + GetShortPathName(app_path.value().c_str(), + WriteInto(&short_app_path, MAX_PATH), MAX_PATH); // open command for protocol associations diff --git a/chrome/common/sandbox_policy.cc b/chrome/common/sandbox_policy.cc index 7adf2b9..2b932d0 100644 --- a/chrome/common/sandbox_policy.cc +++ b/chrome/common/sandbox_policy.cc @@ -116,29 +116,28 @@ PluginPolicyCategory GetPolicyCategoryForPlugin( bool AddDirectory(int path, const wchar_t* sub_dir, bool children, sandbox::TargetPolicy::Semantics access, sandbox::TargetPolicy* policy) { - std::wstring directory; + FilePath directory; if (!PathService::Get(path, &directory)) return false; if (sub_dir) { - file_util::AppendToPath(&directory, sub_dir); + directory = directory.Append(sub_dir); file_util::AbsolutePath(&directory); } sandbox::ResultCode result; result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, access, - directory.c_str()); + directory.value().c_str()); if (result != sandbox::SBOX_ALL_OK) return false; + std::wstring directory_str = directory.value() + L"\\"; if (children) - file_util::AppendToPath(&directory, L"*"); - else - // Add the version of the path that ends with a separator. - file_util::AppendToPath(&directory, L""); + directory_str += L"*"; + // Otherwise, add the version of the path that ends with a separator. result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, access, - directory.c_str()); + directory_str.c_str()); if (result != sandbox::SBOX_ALL_OK) return false; @@ -198,10 +197,11 @@ bool AddGenericPolicy(sandbox::TargetPolicy* policy) { // Add the policy for debug message only in debug #ifndef NDEBUG - std::wstring debug_message; - if (!PathService::Get(chrome::DIR_APP, &debug_message)) + FilePath app_dir; + if (!PathService::Get(chrome::DIR_APP, &app_dir)) return false; - if (!win_util::ConvertToLongPath(debug_message, &debug_message)) + std::wstring debug_message; + if (!win_util::ConvertToLongPath(app_dir.value(), &debug_message)) return false; file_util::AppendToPath(&debug_message, L"debug_message.exe"); result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_PROCESS, diff --git a/chrome/default_plugin/plugin_database_handler.cc b/chrome/default_plugin/plugin_database_handler.cc index a7c520e..bc2220a 100644 --- a/chrome/default_plugin/plugin_database_handler.cc +++ b/chrome/default_plugin/plugin_database_handler.cc @@ -43,8 +43,9 @@ bool PluginDatabaseHandler::DownloadPluginsFileIfNeeded( plugin_finder_url_ = plugin_finder_url; - PathService::Get(base::DIR_MODULE, &plugins_file_); - plugins_file_ += L"\\chrome_plugins_file.xml"; + FilePath module_path; + PathService::Get(base::DIR_MODULE, &module_path); + plugins_file_ = module_path.Append(L"chrome_plugins_file.xml").value(); bool initiate_download = false; if (!file_util::PathExists(FilePath::FromWStringHack(plugins_file_))) { diff --git a/chrome/tools/crash_service/crash_service.cc b/chrome/tools/crash_service/crash_service.cc index 16cee48..4697e92 100644 --- a/chrome/tools/crash_service/crash_service.cc +++ b/chrome/tools/crash_service/crash_service.cc @@ -173,22 +173,23 @@ bool CrashService::Initialize(const std::wstring& command_line) { using google_breakpad::CrashGenerationServer; const wchar_t* pipe_name = kTestPipeName; - std::wstring dumps_path; int max_reports = -1; // The checkpoint file allows CrashReportSender to enforce the the maximum // reports per day quota. Does not seem to serve any other purpose. - std::wstring checkpoint_path = report_path_; - file_util::AppendToPath(&checkpoint_path, kCheckPointFile); + FilePath checkpoint_path = report_path_.Append(kCheckPointFile); // The dumps path is typically : '<user profile>\Local settings\ // Application data\Goggle\Chrome\Crash Reports' and the report path is // Application data\Google\Chrome\Reported Crashes.txt - if (!PathService::Get(chrome::DIR_USER_DATA, &report_path_)) { + FilePath user_data_dir; + if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { LOG(ERROR) << "could not get DIR_USER_DATA"; return false; } - file_util::AppendToPath(&report_path_, chrome::kCrashReportLog); + report_path_ = user_data_dir.Append(chrome::kCrashReportLog); + + FilePath dumps_path; if (!PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path)) { LOG(ERROR) << "could not get DIR_CRASH_DUMPS"; return false; @@ -202,7 +203,7 @@ bool CrashService::Initialize(const std::wstring& command_line) { if (max_reports > 0) { // Create the http sender object. - sender_ = new CrashReportSender(checkpoint_path); + sender_ = new CrashReportSender(checkpoint_path.value()); if (!sender_) { LOG(ERROR) << "could not create sender"; return false; @@ -231,7 +232,7 @@ bool CrashService::Initialize(const std::wstring& command_line) { &CrashService::OnClientConnected, this, &CrashService::OnClientDumpRequest, this, &CrashService::OnClientExited, this, - true, &dumps_path); + true, &dumps_path.value()); if (!dumper_) { LOG(ERROR) << "could not create dumper"; @@ -254,11 +255,11 @@ bool CrashService::Initialize(const std::wstring& command_line) { // Log basic information. VLOG(1) << "pipe name is " << pipe_name - << "\ndumps at " << dumps_path - << "\nreports at " << report_path_; + << "\ndumps at " << dumps_path.value() + << "\nreports at " << report_path_.value(); if (sender_) { - VLOG(1) << "checkpoint is " << checkpoint_path + VLOG(1) << "checkpoint is " << checkpoint_path.value() << "\nserver is " << kCrashReportURL << "\nmaximum " << sender_->max_reports_per_day() << " reports/day" << "\nreporter is " << reporter_tag_; diff --git a/chrome/tools/crash_service/crash_service.h b/chrome/tools/crash_service/crash_service.h index f9526f0..2d4c472 100644 --- a/chrome/tools/crash_service/crash_service.h +++ b/chrome/tools/crash_service/crash_service.h @@ -9,6 +9,7 @@ #include <string> #include "base/basictypes.h" +#include "base/file_path.h" #include "base/lock.h" namespace google_breakpad { @@ -56,10 +57,6 @@ class CrashService { // The default tag if not specified is 'crash svc'. static const char kReporterTag[]; - // Returns the actual report path. - std::wstring report_path() const { - return report_path_; - } // Returns number of crash dumps handled. int requests_handled() const { return requests_handled_; @@ -103,7 +100,7 @@ class CrashService { google_breakpad::CrashReportSender* sender_; // the path to dumps and logs directory. - std::wstring report_path_; + FilePath report_path_; // the extra tag sent to the server with each dump. std::wstring reporter_tag_; |