Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/browser/profiles/profiles_state.cc

Issue 24647003: Redesign of the avatar menu button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better fix for app/popup browser crash Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/profiles/profiles_state.h ('k') | chrome/browser/ui/view_ids.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/profiles/profiles_state.h" 5 #include "chrome/browser/profiles/profiles_state.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_info_cache.h"
13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/ui/browser.h"
10 #include "chrome/common/chrome_constants.h" 15 #include "chrome/common/chrome_constants.h"
11 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "grit/generated_resources.h"
19 #include "ui/base/l10n/l10n_util.h"
13 20
14 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
15 #include "chrome/browser/chromeos/login/user_manager.h" 22 #include "chrome/browser/chromeos/login/user_manager.h"
16 #endif 23 #endif
17 24
18 namespace profiles { 25 namespace profiles {
19 26
20 bool IsMultipleProfilesEnabled() { 27 bool IsMultipleProfilesEnabled() {
21 #if defined(OS_ANDROID) 28 #if defined(OS_ANDROID)
22 return false; 29 return false;
23 #endif 30 #endif
24 #if defined(OS_CHROMEOS) 31 #if defined(OS_CHROMEOS)
25 return chromeos::UserManager::IsMultipleProfilesAllowed(); 32 return chromeos::UserManager::IsMultipleProfilesAllowed();
26 #endif 33 #endif
27 34
28 return true; 35 return true;
29 } 36 }
30 37
31 bool IsNewProfileManagementEnabled() { 38 bool IsNewProfileManagementEnabled() {
32 return CommandLine::ForCurrentProcess()->HasSwitch( 39 return CommandLine::ForCurrentProcess()->HasSwitch(
33 switches::kNewProfileManagement); 40 switches::kNewProfileManagement);
34 } 41 }
35 42
36 base::FilePath GetDefaultProfileDir( 43 base::FilePath GetDefaultProfileDir(const base::FilePath& user_data_dir) {
37 const base::FilePath& user_data_dir) {
38 base::FilePath default_profile_dir(user_data_dir); 44 base::FilePath default_profile_dir(user_data_dir);
39 default_profile_dir = 45 default_profile_dir =
40 default_profile_dir.AppendASCII(chrome::kInitialProfile); 46 default_profile_dir.AppendASCII(chrome::kInitialProfile);
41 return default_profile_dir; 47 return default_profile_dir;
42 } 48 }
43 49
44 base::FilePath GetProfilePrefsPath( 50 base::FilePath GetProfilePrefsPath(
45 const base::FilePath &profile_dir) { 51 const base::FilePath &profile_dir) {
46 base::FilePath default_prefs_path(profile_dir); 52 base::FilePath default_prefs_path(profile_dir);
47 default_prefs_path = default_prefs_path.Append(chrome::kPreferencesFilename); 53 default_prefs_path = default_prefs_path.Append(chrome::kPreferencesFilename);
48 return default_prefs_path; 54 return default_prefs_path;
49 } 55 }
50 56
51 void RegisterPrefs(PrefRegistrySimple* registry) { 57 void RegisterPrefs(PrefRegistrySimple* registry) {
52 registry->RegisterStringPref(prefs::kProfileLastUsed, std::string()); 58 registry->RegisterStringPref(prefs::kProfileLastUsed, std::string());
53 registry->RegisterIntegerPref(prefs::kProfilesNumCreated, 1); 59 registry->RegisterIntegerPref(prefs::kProfilesNumCreated, 1);
54 registry->RegisterListPref(prefs::kProfilesLastActive); 60 registry->RegisterListPref(prefs::kProfilesLastActive);
55 } 61 }
56 62
63 string16 GetActiveProfileDisplayName(Browser* browser) {
64 string16 profile_name;
65 Profile* profile = browser->profile();
66
67 if (profile->IsGuestSession()) {
68 profile_name = l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME);
69 } else {
70 ProfileInfoCache& cache =
71 g_browser_process->profile_manager()->GetProfileInfoCache();
72 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
73 if (index != std::string::npos)
74 profile_name = cache.GetNameOfProfileAtIndex(index);
75 }
76 return profile_name;
77 }
78
57 } // namespace profiles 79 } // namespace profiles
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profiles_state.h ('k') | chrome/browser/ui/view_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698