summaryrefslogtreecommitdiffstats
path: root/chrome/browser/profiles
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/profiles')
-rw-r--r--chrome/browser/profiles/profiles_state.cc26
-rw-r--r--chrome/browser/profiles/profiles_state.h6
2 files changed, 30 insertions, 2 deletions
diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc
index 72e1295..3165271 100644
--- a/chrome/browser/profiles/profiles_state.cc
+++ b/chrome/browser/profiles/profiles_state.cc
@@ -7,9 +7,16 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/prefs/pref_registry_simple.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_info_cache.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/user_manager.h"
@@ -33,8 +40,7 @@ bool IsNewProfileManagementEnabled() {
switches::kNewProfileManagement);
}
-base::FilePath GetDefaultProfileDir(
- const base::FilePath& user_data_dir) {
+base::FilePath GetDefaultProfileDir(const base::FilePath& user_data_dir) {
base::FilePath default_profile_dir(user_data_dir);
default_profile_dir =
default_profile_dir.AppendASCII(chrome::kInitialProfile);
@@ -54,4 +60,20 @@ void RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterListPref(prefs::kProfilesLastActive);
}
+string16 GetActiveProfileDisplayName(Browser* browser) {
+ string16 profile_name;
+ Profile* profile = browser->profile();
+
+ if (profile->IsGuestSession()) {
+ profile_name = l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME);
+ } else {
+ ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
+ size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
+ if (index != std::string::npos)
+ profile_name = cache.GetNameOfProfileAtIndex(index);
+ }
+ return profile_name;
+}
+
} // namespace profiles
diff --git a/chrome/browser/profiles/profiles_state.h b/chrome/browser/profiles/profiles_state.h
index 2858e62..3f6debc 100644
--- a/chrome/browser/profiles/profiles_state.h
+++ b/chrome/browser/profiles/profiles_state.h
@@ -5,6 +5,9 @@
#ifndef CHROME_BROWSER_PROFILES_PROFILES_STATE_H_
#define CHROME_BROWSER_PROFILES_PROFILES_STATE_H_
+#include "base/strings/string16.h"
+
+class Browser;
class PrefRegistrySimple;
namespace base { class FilePath; }
@@ -26,6 +29,9 @@ base::FilePath GetProfilePrefsPath(const base::FilePath& profile_dir);
// Register multi-profile related preferences in Local State.
void RegisterPrefs(PrefRegistrySimple* registry);
+// Returns the display name of the active on-the-record profile (or guest).
+string16 GetActiveProfileDisplayName(Browser* browser);
+
} // namespace profiles
#endif // CHROME_BROWSER_PROFILES_PROFILES_STATE_H_