diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-26 04:43:36 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-26 04:43:36 +0000 |
commit | 38233e6c082d748aac5f55cc38ca0d2e581755a6 (patch) | |
tree | a2172efa91d6d0d8a4de69a40dc4f445bd01d2ed /chrome/browser/user_data_manager.cc | |
parent | 20ae4824364a0a871bae34322b030424f0f78653 (diff) | |
download | chromium_src-38233e6c082d748aac5f55cc38ca0d2e581755a6.zip chromium_src-38233e6c082d748aac5f55cc38ca0d2e581755a6.tar.gz chromium_src-38233e6c082d748aac5f55cc38ca0d2e581755a6.tar.bz2 |
Get rid of more calls to FromWStringHack.
BUG=24672
TEST=compiles
Patch from Thiago Farina <thiago.farina@gmail.com>
Review URL: http://codereview.chromium.org/1750013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45568 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/user_data_manager.cc')
-rw-r--r-- | chrome/browser/user_data_manager.cc | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/chrome/browser/user_data_manager.cc b/chrome/browser/user_data_manager.cc index 7d9c98a..25bd366 100644 --- a/chrome/browser/user_data_manager.cc +++ b/chrome/browser/user_data_manager.cc @@ -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. @@ -31,15 +31,6 @@ namespace { -// TODO: don't use wstrings in all this code. :( -// But I'm not fixing it right now since this code is reported to be going -// away. -void DeprecatedPathServiceGet(int key, std::wstring* str) { - FilePath path; - PathService::Get(key, &path); - *str = path.ToWStringHack(); -} - // Helper to start chrome for a given profile index. The helper takes care of // enumerating profiles on the file thread and then it launches Chrome for the // appropriate profile on the original thread. @@ -144,9 +135,9 @@ UserDataManager* UserDataManager::instance_ = NULL; // static UserDataManager* UserDataManager::Create() { DCHECK(!instance_); - std::wstring user_data; - DeprecatedPathServiceGet(chrome::DIR_USER_DATA, &user_data); - instance_ = new UserDataManager(user_data); + FilePath user_path; + PathService::Get(chrome::DIR_USER_DATA, &user_path); + instance_ = new UserDataManager(user_path); return instance_; } @@ -156,10 +147,10 @@ UserDataManager* UserDataManager::Get() { return instance_; } -UserDataManager::UserDataManager(const std::wstring& user_data_root) +UserDataManager::UserDataManager(const FilePath& user_data_root) : user_data_root_(user_data_root) { // Determine current profile name and current folder name. - current_folder_name_ = file_util::GetFilenameFromPath(user_data_root); + current_folder_name_ = user_data_root.BaseName().ToWStringHack(); bool success = GetProfileNameFromFolderName(current_folder_name_, ¤t_profile_name_); // The current profile is a default profile if the current user data folder @@ -171,7 +162,7 @@ UserDataManager::UserDataManager(const std::wstring& user_data_root) // (TODO:munjal) Fix issue 5070: // http://code.google.com/p/chromium/issues/detail?id=5070 - file_util::UpOneDirectory(&user_data_root_); + user_data_root_ = user_data_root_.DirName(); } UserDataManager::~UserDataManager() { @@ -221,9 +212,8 @@ std::wstring UserDataManager::GetFolderNameFromProfileName( std::wstring UserDataManager::GetUserDataFolderForProfile( const std::wstring& profile_name) const { std::wstring folder_name = GetFolderNameFromProfileName(profile_name); - FilePath folder_path = - FilePath::FromWStringHack(user_data_root_) - .Append(FilePath::FromWStringHack(folder_name)); + FilePath folder_path = user_data_root_.Append( + FilePath::FromWStringHack(folder_name)); return folder_path.ToWStringHack(); } @@ -236,10 +226,10 @@ void UserDataManager::LaunchChromeForProfile( command_line.AppendSwitch(switches::kEnableUserDataDirProfiles); command_line.AppendSwitchWithValue(switches::kUserDataDir, user_data_dir); - std::wstring local_state_path; - DeprecatedPathServiceGet(chrome::FILE_LOCAL_STATE, &local_state_path); + FilePath local_state_path; + PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); command_line.AppendSwitchWithValue(switches::kParentProfile, - local_state_path); + local_state_path.ToWStringHack()); base::LaunchApp(command_line, false, false, NULL); } @@ -253,9 +243,8 @@ void UserDataManager::LaunchChromeForProfile(int index) const { void UserDataManager::GetProfiles(std::vector<std::wstring>* profiles) const { // This function should be called on the file thread. DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); - file_util::FileEnumerator file_enum( - FilePath::FromWStringHack(user_data_root_), - false, file_util::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator file_enum(user_data_root_, false, + file_util::FileEnumerator::DIRECTORIES); std::wstring folder_name; while (!(folder_name = file_enum.Next().ToWStringHack()).empty()) { folder_name = file_util::GetFilenameFromPath(folder_name); |