summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorcmasone@google.com <cmasone@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 15:57:08 +0000
committercmasone@google.com <cmasone@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 15:57:08 +0000
commit943aed554c941f128a62f4addd807d1a519083f0 (patch)
tree382a40ddd4b3b4fc880f76e4bcad187ecdb5e559 /chrome/browser
parenta3473d975ec1188f5cae52cf260710f02c6f5f75 (diff)
downloadchromium_src-943aed554c941f128a62f4addd807d1a519083f0.zip
chromium_src-943aed554c941f128a62f4addd807d1a519083f0.tar.gz
chromium_src-943aed554c941f128a62f4addd807d1a519083f0.tar.bz2
Fix build failure from previous change.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=49503 Review URL: http://codereview.chromium.org/2796004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49535 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/profile_manager.cc32
-rw-r--r--chrome/browser/profile_manager.h7
-rw-r--r--chrome/browser/profile_manager_unittest.cc47
3 files changed, 72 insertions, 14 deletions
diff --git a/chrome/browser/profile_manager.cc b/chrome/browser/profile_manager.cc
index c755cfe..1e948a3 100644
--- a/chrome/browser/profile_manager.cc
+++ b/chrome/browser/profile_manager.cc
@@ -93,8 +93,8 @@ FilePath ProfileManager::GetProfilePrefsPath(
return default_prefs_path;
}
-Profile* ProfileManager::GetDefaultProfile(const FilePath& user_data_dir) {
- FilePath default_profile_dir(user_data_dir);
+FilePath ProfileManager::GetCurrentProfileDir() {
+ FilePath relative_profile_dir;
#if defined(OS_CHROMEOS)
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (logged_in_) {
@@ -109,15 +109,24 @@ Profile* ProfileManager::GetDefaultProfile(const FilePath& user_data_dir) {
} else {
// We should never be logged in with no profile dir.
NOTREACHED();
- return NULL;
+ return FilePath("");
}
- default_profile_dir = default_profile_dir.Append(profile_dir);
- return GetProfile(default_profile_dir);
- } else {
- // If not logged in on cros, always return the incognito profile
- default_profile_dir = default_profile_dir.Append(
- FilePath::FromWStringHack(chrome::kNotSignedInProfile));
+ relative_profile_dir = relative_profile_dir.Append(profile_dir);
+ return relative_profile_dir;
+ }
+#endif
+ relative_profile_dir = relative_profile_dir.Append(
+ FilePath::FromWStringHack(chrome::kNotSignedInProfile));
+ return relative_profile_dir;
+}
+
+Profile* ProfileManager::GetDefaultProfile(const FilePath& user_data_dir) {
+ FilePath default_profile_dir(user_data_dir);
+ default_profile_dir = default_profile_dir.Append(GetCurrentProfileDir());
+#if defined(OS_CHROMEOS)
+ if (!logged_in_) {
Profile* profile;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
// For cros, return the OTR profile so we never accidentally keep
// user data in an unencrypted profile. But doing this makes
@@ -134,11 +143,8 @@ Profile* ProfileManager::GetDefaultProfile(const FilePath& user_data_dir) {
}
return profile;
}
-#else
- default_profile_dir = default_profile_dir.Append(
- FilePath::FromWStringHack(chrome::kNotSignedInProfile));
- return GetProfile(default_profile_dir);
#endif
+ return GetProfile(default_profile_dir);
}
Profile* ProfileManager::GetProfile(const FilePath& profile_dir) {
diff --git a/chrome/browser/profile_manager.h b/chrome/browser/profile_manager.h
index 0542f7d..707024b 100644
--- a/chrome/browser/profile_manager.h
+++ b/chrome/browser/profile_manager.h
@@ -97,6 +97,10 @@ class ProfileManager : public NonThreadSafe,
// first to see if the profile already exists.
Profile* GetProfile(const FilePath& profile_dir, bool init_extensions);
+ // Returns the directory where the currently active profile is
+ // stored, relative to the user data directory currently in use..
+ FilePath GetCurrentProfileDir();
+
// These allow iteration through the current list of profiles.
typedef std::vector<Profile*> ProfileVector;
typedef ProfileVector::iterator iterator;
@@ -120,7 +124,8 @@ class ProfileManager : public NonThreadSafe,
// ------------------ static utility functions -------------------
- // Returns the path to the profile directory based on the user data directory.
+ // Returns the path to the default profile directory, based on the given
+ // user data directory.
static FilePath GetDefaultProfileDir(const FilePath& user_data_dir);
// Returns the path to the preferences file given the user profile directory.
diff --git a/chrome/browser/profile_manager_unittest.cc b/chrome/browser/profile_manager_unittest.cc
index 0f339f7..48fc179 100644
--- a/chrome/browser/profile_manager_unittest.cc
+++ b/chrome/browser/profile_manager_unittest.cc
@@ -2,14 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "app/system_monitor.h"
+#include "base/command_line.h"
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/path_service.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/profile_manager.h"
+#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -67,6 +73,47 @@ TEST_F(ProfileManagerTest, CreateProfile) {
#endif
}
+TEST_F(ProfileManagerTest, DefaultProfileDir) {
+ CommandLine *cl = CommandLine::ForCurrentProcess();
+ SystemMonitor dummy;
+ ProfileManager profile_manager;
+ std::string profile_dir("my_user");
+
+ cl->AppendSwitch(switches::kTestType);
+
+ FilePath expected_default =
+ FilePath::FromWStringHack(chrome::kNotSignedInProfile);
+ EXPECT_EQ(expected_default.value(),
+ profile_manager.GetCurrentProfileDir().value());
+}
+
+#if defined(OS_CHROMEOS)
+// This functionality only exists on Chrome OS.
+TEST_F(ProfileManagerTest, LoggedInProfileDir) {
+ CommandLine *cl = CommandLine::ForCurrentProcess();
+ SystemMonitor dummy;
+ ProfileManager profile_manager;
+ std::string profile_dir("my_user");
+
+ cl->AppendSwitchWithValue(switches::kLoginProfile, profile_dir);
+ cl->AppendSwitch(switches::kTestType);
+
+ FilePath expected_default =
+ FilePath::FromWStringHack(chrome::kNotSignedInProfile);
+ EXPECT_EQ(expected_default.value(),
+ profile_manager.GetCurrentProfileDir().value());
+
+ profile_manager.Observe(NotificationType::LOGIN_USER_CHANGED,
+ NotificationService::AllSources(),
+ NotificationService::NoDetails());
+ FilePath expected_logged_in(profile_dir);
+ EXPECT_EQ(expected_logged_in.value(),
+ profile_manager.GetCurrentProfileDir().value());
+ LOG(INFO) << test_dir_.Append(profile_manager.GetCurrentProfileDir()).value();
+}
+
+#endif
+
// TODO(timsteele): This is disabled while I try to track down a purify
// regression (http://crbug.com/10553).
TEST_F(ProfileManagerTest, DISABLED_CreateAndUseTwoProfiles) {