OLD | NEW |
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 <stdio.h> | |
8 | |
9 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
10 #include "base/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
12 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/profiles/profile_info_cache.h" | 13 #include "chrome/browser/profiles/profile_info_cache.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 15 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 if (index == std::string::npos) | 63 if (index == std::string::npos) |
66 return l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); | 64 return l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); |
67 | 65 |
68 // Using the --new-profile-management flag, there's a couple of rules | 66 // Using the --new-profile-management flag, there's a couple of rules |
69 // about what the avatar button displays. If there's a single, local | 67 // about what the avatar button displays. If there's a single, local |
70 // profile, with a default name (i.e. of the form Person %d), it should | 68 // profile, with a default name (i.e. of the form Person %d), it should |
71 // display IDS_SINGLE_PROFILE_DISPLAY_NAME. If this is a signed in profile, | 69 // display IDS_SINGLE_PROFILE_DISPLAY_NAME. If this is a signed in profile, |
72 // or the user has edited the profile name, or there are multiple profiles, | 70 // or the user has edited the profile name, or there are multiple profiles, |
73 // it will return the actual name of the profile. | 71 // it will return the actual name of the profile. |
74 base::string16 profile_name = cache.GetNameOfProfileAtIndex(index); | 72 base::string16 profile_name = cache.GetNameOfProfileAtIndex(index); |
75 std::string default_name_format = l10n_util::GetStringFUTF8( | 73 bool has_default_name = cache.ProfileIsUsingDefaultNameAtIndex(index); |
76 IDS_NEW_NUMBERED_PROFILE_NAME, base::string16()) + "%d"; | |
77 int generic_profile_number; // Unused. Just a placeholder for sscanf. | |
78 int assignments = sscanf(base::UTF16ToUTF8(profile_name).c_str(), | |
79 default_name_format.c_str(), | |
80 &generic_profile_number); | |
81 bool has_default_name = (assignments == 1); | |
82 | 74 |
83 if (cache.GetNumberOfProfiles() == 1 && has_default_name && | 75 if (cache.GetNumberOfProfiles() == 1 && has_default_name && |
84 cache.GetUserNameOfProfileAtIndex(index).empty()) { | 76 cache.GetUserNameOfProfileAtIndex(index).empty()) { |
85 display_name = l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); | 77 display_name = l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); |
86 } else { | 78 } else { |
87 display_name = profile_name; | 79 display_name = profile_name; |
88 } | 80 } |
89 } | 81 } |
90 return display_name; | 82 return display_name; |
91 } | 83 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 128 |
137 return accounts; | 129 return accounts; |
138 } | 130 } |
139 | 131 |
140 bool IsRegularOrGuestSession(Browser* browser) { | 132 bool IsRegularOrGuestSession(Browser* browser) { |
141 Profile* profile = browser->profile(); | 133 Profile* profile = browser->profile(); |
142 return profile->IsGuestSession() || !profile->IsOffTheRecord(); | 134 return profile->IsGuestSession() || !profile->IsOffTheRecord(); |
143 } | 135 } |
144 | 136 |
145 } // namespace profiles | 137 } // namespace profiles |
OLD | NEW |